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 {
class DLLExport LoadBinaryStl {
public:
static constexpr int HEADER_SIZE = 80;
static constexpr uint32_t SIZE_OF_TRIANGLE = 50;
static constexpr uint32_t NUM_OF_TRIANGLES = 4;
static constexpr uint32_t TRIANGLE_DATA_SIZE = 50;
static constexpr uint32_t TRIANGLE_COUNT_DATA_SIZE = 4;
static constexpr uint32_t VECTOR_DATA_SIZE = 12;
LoadBinaryStl(std::string filename) : m_filename(filename) {}
std::unique_ptr<Geometry::MeshObject> readStl();
bool isBinarySTL();
......
......@@ -12,7 +12,7 @@ namespace DataHandling {
bool LoadBinaryStl::isBinarySTL() {
Poco::File stlFile = Poco::File(m_filename);
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
// format stl
return false;
......@@ -22,8 +22,8 @@ bool LoadBinaryStl::isBinarySTL() {
Kernel::BinaryStreamReader streamReader = Kernel::BinaryStreamReader(myFile);
numberTrianglesLong = getNumberTriangles(streamReader);
myFile.close();
if (!(fileSize == (HEADER_SIZE + NUM_OF_TRIANGLES +
(numberTrianglesLong * SIZE_OF_TRIANGLE)))) {
if (!(fileSize == (HEADER_SIZE + TRIANGLE_COUNT_DATA_SIZE +
(numberTrianglesLong * TRIANGLE_DATA_SIZE)))) {
// File is not the Header plus the number of triangles it claims to be long,
// invalid binary Stl
return false;
......@@ -45,18 +45,17 @@ LoadBinaryStl::getNumberTriangles(Kernel::BinaryStreamReader streamReader) {
std::unique_ptr<Geometry::MeshObject> LoadBinaryStl::readStl() {
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);
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
for (uint32_t i = 0; i < numberTrianglesLong; i++) {
// find next triangle, skipping the normal and attribute
streamReader.moveStreamToPosition(nextToRead);
readTriangle(streamReader);
nextToRead += SIZE_OF_TRIANGLE;
nextToRead += TRIANGLE_DATA_SIZE;
}
myFile.close();
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