diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h b/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h index 6b5eb3d48f20ada69d60abf71c53e942913527bd..60241c48c4599a06840c8fde9d78cbd9aa00537a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h @@ -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(); diff --git a/Framework/DataHandling/src/LoadBinaryStl.cpp b/Framework/DataHandling/src/LoadBinaryStl.cpp index 5e8d96df66940a7ad03189935de30897c3a9ac80..5a2885442dc26f6f2b4237ea3d5981b01b468f9a 100644 --- a/Framework/DataHandling/src/LoadBinaryStl.cpp +++ b/Framework/DataHandling/src/LoadBinaryStl.cpp @@ -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 diff --git a/Framework/DataHandling/test/LoadBinaryStlTest.h b/Framework/DataHandling/test/LoadBinaryStlTest.h index 386b26bf4e7d999078d60205ddf3a49ff43b31fd..d00f1045a88b331cc95eef3e08fea26fc32b7812 100644 --- a/Framework/DataHandling/test/LoadBinaryStlTest.h +++ b/Framework/DataHandling/test/LoadBinaryStlTest.h @@ -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())); } };