X-Git-Url: https://git.sur5r.net/?p=fstl;a=blobdiff_plain;f=src%2Floader.cpp;h=38bd2ddc66796ba7498eb3ece007e445d2f564ce;hp=b5a2f04b9a43580cfbfda4ede4bd08c40549df22;hb=refs%2Fheads%2Fupstream;hpb=0da9fdf2b9623665a991990e57485a007645eba6 diff --git a/src/loader.cpp b/src/loader.cpp index b5a2f04..38bd2dd 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -127,14 +127,12 @@ Mesh* Loader::load_stl() file.seek(0); return read_stl_ascii(file); } - confusing_stl = true; - } - else - { - confusing_stl = false; + // Otherwise, this STL is a binary stl but contains 'solid' as + // the first five characters. This is a bad life choice, but + // we can gracefully handle it by falling through to the binary + // STL reader below. } - // Otherwise, skip the rest of the header material and read as binary file.seek(0); return read_stl_binary(file); } @@ -161,7 +159,7 @@ Mesh* Loader::read_stl_binary(QFile& file) QVector verts(tri_count*3); // Dummy array, because readRawData is faster than skipRawData - std::unique_ptr buffer(new uint8_t[tri_count * 50]); + std::unique_ptr buffer(new uint8_t[tri_count * 50]); data.readRawData((char*)buffer.get(), tri_count * 50); // Store vertices in the array, processing one triangle at a time. @@ -171,7 +169,7 @@ Mesh* Loader::read_stl_binary(QFile& file) // Load vertex data from .stl file into vertices for (unsigned i=0; i < 3; ++i) { - memcpy(&v[i], b, 3*sizeof(float)); + qFromLittleEndian(b, 3, &v[i]); b += 3 * sizeof(float); } @@ -179,11 +177,6 @@ Mesh* Loader::read_stl_binary(QFile& file) b += 3 * sizeof(float) + sizeof(uint16_t); } - if (confusing_stl) - { - emit warning_confusing_stl(); - } - return mesh_from_verts(tri_count, verts); }