]> git.sur5r.net Git - fstl/blobdiff - src/loader.cpp
New upstream version 0.10.0
[fstl] / src / loader.cpp
index b5a2f04b9a43580cfbfda4ede4bd08c40549df22..38bd2ddc66796ba7498eb3ece007e445d2f564ce 100644 (file)
@@ -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<Vertex> verts(tri_count*3);
 
     // Dummy array, because readRawData is faster than skipRawData
-    std::unique_ptr<uint8_t> buffer(new uint8_t[tri_count * 50]);
+    std::unique_ptr<uint8_t[]> 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<float>(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);
 }