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

Re #23574 made constant names consistent

parent 4808ea1e
No related branches found
No related tags found
No related merge requests found
...@@ -10,8 +10,9 @@ namespace DataHandling { ...@@ -10,8 +10,9 @@ namespace DataHandling {
class DLLExport LoadBinaryStl { class DLLExport LoadBinaryStl {
public: public:
static constexpr int HEADER_SIZE = 80; static constexpr int HEADER_SIZE = 80;
static constexpr uint32_t SIZE_OF_TRIANGLE = 50; static constexpr uint32_t TRIANGLE_DATA_SIZE = 50;
static constexpr uint32_t NUM_OF_TRIANGLES = 4; static constexpr uint32_t TRIANGLE_COUNT_DATA_SIZE = 4;
static constexpr uint32_t VECTOR_DATA_SIZE = 12;
LoadBinaryStl(std::string filename) : m_filename(filename) {} LoadBinaryStl(std::string filename) : m_filename(filename) {}
std::unique_ptr<Geometry::MeshObject> readStl(); std::unique_ptr<Geometry::MeshObject> readStl();
bool isBinarySTL(); bool isBinarySTL();
......
...@@ -12,7 +12,7 @@ namespace DataHandling { ...@@ -12,7 +12,7 @@ namespace DataHandling {
bool LoadBinaryStl::isBinarySTL() { bool LoadBinaryStl::isBinarySTL() {
Poco::File stlFile = Poco::File(m_filename); Poco::File stlFile = Poco::File(m_filename);
auto fileSize = stlFile.getSize(); auto fileSize = stlFile.getSize();
if (fileSize < HEADER_SIZE + NUM_OF_TRIANGLES) { if (fileSize < HEADER_SIZE + TRIANGLE_COUNT_DATA_SIZE) {
// File is smaller than header plus number of triangles, cannot be binary // File is smaller than header plus number of triangles, cannot be binary
// format stl // format stl
return false; return false;
...@@ -22,8 +22,8 @@ bool LoadBinaryStl::isBinarySTL() { ...@@ -22,8 +22,8 @@ bool LoadBinaryStl::isBinarySTL() {
Kernel::BinaryStreamReader streamReader = Kernel::BinaryStreamReader(myFile); Kernel::BinaryStreamReader streamReader = Kernel::BinaryStreamReader(myFile);
numberTrianglesLong = getNumberTriangles(streamReader); numberTrianglesLong = getNumberTriangles(streamReader);
myFile.close(); myFile.close();
if (!(fileSize == (HEADER_SIZE + NUM_OF_TRIANGLES + if (!(fileSize == (HEADER_SIZE + TRIANGLE_COUNT_DATA_SIZE +
(numberTrianglesLong * SIZE_OF_TRIANGLE)))) { (numberTrianglesLong * TRIANGLE_DATA_SIZE)))) {
// File is not the Header plus the number of triangles it claims to be long, // File is not the Header plus the number of triangles it claims to be long,
// invalid binary Stl // invalid binary Stl
return false; return false;
...@@ -45,18 +45,17 @@ LoadBinaryStl::getNumberTriangles(Kernel::BinaryStreamReader streamReader) { ...@@ -45,18 +45,17 @@ LoadBinaryStl::getNumberTriangles(Kernel::BinaryStreamReader streamReader) {
std::unique_ptr<Geometry::MeshObject> LoadBinaryStl::readStl() { std::unique_ptr<Geometry::MeshObject> LoadBinaryStl::readStl() {
std::ifstream myFile(m_filename.c_str(), std::ios::in | std::ios::binary); std::ifstream myFile(m_filename.c_str(), std::ios::in | std::ios::binary);
const uint32_t SIZE_OF_NORMAL = 12;
Kernel::BinaryStreamReader streamReader = Kernel::BinaryStreamReader(myFile); Kernel::BinaryStreamReader streamReader = Kernel::BinaryStreamReader(myFile);
const auto numberTrianglesLong = getNumberTriangles(streamReader); const auto numberTrianglesLong = getNumberTriangles(streamReader);
uint32_t nextToRead = HEADER_SIZE + NUM_OF_TRIANGLES + SIZE_OF_NORMAL; uint32_t nextToRead = HEADER_SIZE + TRIANGLE_COUNT_DATA_SIZE + VECTOR_DATA_SIZE;
// now read in all the triangles // now read in all the triangles
for (uint32_t i = 0; i < numberTrianglesLong; i++) { for (uint32_t i = 0; i < numberTrianglesLong; i++) {
// find next triangle, skipping the normal and attribute // find next triangle, skipping the normal and attribute
streamReader.moveStreamToPosition(nextToRead); streamReader.moveStreamToPosition(nextToRead);
readTriangle(streamReader); readTriangle(streamReader);
nextToRead += SIZE_OF_TRIANGLE; nextToRead += TRIANGLE_DATA_SIZE;
} }
myFile.close(); myFile.close();
std::unique_ptr<Geometry::MeshObject> retVal = std::unique_ptr<Geometry::MeshObject> retVal =
......
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