Skip to content
Snippets Groups Projects
Commit 060f3e20 authored by Sam Jenkins's avatar Sam Jenkins
Browse files

Re #23574 clang format

parent bda2a87e
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,9 @@ namespace DataHandling {
class DLLExport LoadBinaryStl {
public:
LoadBinaryStl(std::string filename) : m_filename(filename), M_HEADER_SIZE(80), M_SIZE_OF_TRIANGLE(50), M_NUM_OF_TRIANGLES(4) {}
LoadBinaryStl(std::string filename)
: m_filename(filename), M_HEADER_SIZE(80), M_SIZE_OF_TRIANGLE(50),
M_NUM_OF_TRIANGLES(4) {}
std::unique_ptr<Geometry::MeshObject> readStl();
bool isBinarySTL();
......
......@@ -11,7 +11,7 @@ namespace DataHandling {
bool LoadBinaryStl::isBinarySTL() {
// each triangle is 50 bytes
Poco::File stlFile = Poco::File(m_filename);
auto fileSize = stlFile.getSize();
if (fileSize < M_HEADER_SIZE + M_NUM_OF_TRIANGLES) {
......@@ -24,7 +24,8 @@ bool LoadBinaryStl::isBinarySTL() {
Kernel::BinaryStreamReader streamReader = Kernel::BinaryStreamReader(myFile);
numberTrianglesLong = getNumberTriangles(streamReader);
myFile.close();
if (!(fileSize == (M_HEADER_SIZE + M_NUM_OF_TRIANGLES + (numberTrianglesLong * M_SIZE_OF_TRIANGLE)))) {
if (!(fileSize == (M_HEADER_SIZE + M_NUM_OF_TRIANGLES +
(numberTrianglesLong * M_SIZE_OF_TRIANGLE)))) {
// File is not the Header plus the number of triangles it claims to be long,
// invalid binary Stl
return false;
......@@ -36,7 +37,7 @@ bool LoadBinaryStl::isBinarySTL() {
uint32_t
LoadBinaryStl::getNumberTriangles(Kernel::BinaryStreamReader streamReader) {
uint32_t numberTrianglesLong;
// skip header
streamReader.moveStreamToPosition(M_HEADER_SIZE);
// Read the number of triangles
......@@ -52,7 +53,6 @@ std::unique_ptr<Geometry::MeshObject> LoadBinaryStl::readStl() {
const auto numberTrianglesLong = getNumberTriangles(streamReader);
uint32_t nextToRead = M_HEADER_SIZE + M_NUM_OF_TRIANGLES + SIZE_OF_NORMAL;
// now read in all the triangles
for (uint32_t i = 0; i < numberTrianglesLong; i++) {
// find next triangle, skipping the normal and attribute
......
......@@ -27,7 +27,8 @@ public:
void testInit() {}
void test_cube() {
std::string path = FileFinder::Instance().getFullPath("cubeBin.stl");
std::unique_ptr<LoadBinaryStl> loader = std::make_unique<LoadBinaryStl>(path);
std::unique_ptr<LoadBinaryStl> loader =
std::make_unique<LoadBinaryStl>(path);
auto cube = loader->readStl();
TS_ASSERT(cube->hasValidShape());
TS_ASSERT_EQUALS(cube->numberOfVertices(), 8);
......@@ -37,7 +38,8 @@ public:
void test_cylinder() {
std::string path = FileFinder::Instance().getFullPath("cylinderBin.stl");
std::unique_ptr<LoadBinaryStl> loader = std::make_unique<LoadBinaryStl>(path);
std::unique_ptr<LoadBinaryStl> loader =
std::make_unique<LoadBinaryStl>(path);
auto cylinder = loader->readStl();
TS_ASSERT(cylinder->hasValidShape());
TS_ASSERT_EQUALS(cylinder->numberOfVertices(), 722);
......@@ -47,7 +49,8 @@ public:
void test_tube() {
std::string path = FileFinder::Instance().getFullPath("tubeBin.stl");
std::unique_ptr<LoadBinaryStl> loader = std::make_unique<LoadBinaryStl>(path);
std::unique_ptr<LoadBinaryStl> loader =
std::make_unique<LoadBinaryStl>(path);
auto tube = loader->readStl();
TS_ASSERT(tube->hasValidShape());
TS_ASSERT_EQUALS(tube->numberOfVertices(), 1080);
......@@ -59,7 +62,8 @@ public:
void test_fail_invalid_vertex() {
std::string path =
FileFinder::Instance().getFullPath("invalid_vertexBin.stl");
std::unique_ptr<LoadBinaryStl> loader = std::make_unique<LoadBinaryStl>(path);
std::unique_ptr<LoadBinaryStl> loader =
std::make_unique<LoadBinaryStl>(path);
TS_ASSERT(!(loader->isBinarySTL()));
}
// check that isBinaryStl returns false if the file contains an incomplete
......@@ -67,13 +71,15 @@ public:
void test_fail_invalid_triangle() {
std::string path =
FileFinder::Instance().getFullPath("invalid_triangleBin.stl");
std::unique_ptr<LoadBinaryStl> loader = std::make_unique<LoadBinaryStl>(path);
std::unique_ptr<LoadBinaryStl> loader =
std::make_unique<LoadBinaryStl>(path);
TS_ASSERT(!(loader->isBinarySTL()));
}
void test_fail_ascii_stl() {
std::string path = FileFinder::Instance().getFullPath("cube.stl");
std::unique_ptr<LoadBinaryStl> loader = std::make_unique<LoadBinaryStl>(path);
std::unique_ptr<LoadBinaryStl> loader =
std::make_unique<LoadBinaryStl>(path);
TS_ASSERT(!(loader->isBinarySTL()));
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment