Welcome! Log In Create A New Profile

Advanced

STL export should contain single precision floats

Posted by 3D-ES 
STL export should contain single precision floats
December 25, 2018 03:05PM
Hello!

I am designing 3D KiCAD PCB parts using OpenSCAD and Wings3D

When I import an OpenSCAD STL file in Wings3D, the program always crashes,
after repairing the file using meshconv, the STL file no longer crashes Wings3D.

Meshconv only changed the normal and vertex locations to floating point values...

The STL file format specifies:

Quote

The numerical data in the facet normal and vertex lines are single precision floats, for example, 1.23456E+789.

Currently the STL file contains only integers when testing with a cube(10);

I made the following changes in /src/export_stl.cc:
 std::string toString(const Vector3d &v)

-   return OSS(v[0] << " " << v[1] << " " << v[2]);
+   return OSS(std::scientific << v[0] << " " << v[1] << " " << v[2]);

 void append_stl(const PolySet &ps, std:: ostream &output)

    if (is_finite(normal) && !is_nan(normal)) {
-       output << normal[0] << " " << normal[1] << " " << normal[2] << "\n";
+       output << std::scientific << normal[0] << " " << normal[1] << " " << normal[2] << "\n";
    }
    else {
-       output << "0 0 0\n";
+       output << "0.000000e+00 0.000000e+00 0.000000e+00\n";
    }
After these changes Wings3D accepts (my very simple) OpenSCAD STL files.

Should the code be changed (this way or another) or is there a reason things are this way?


RS-Online Ormerod #263, Kossel mini with Minitronics, Prusa i3 MK2
Re: STL export should contain single precision floats
December 25, 2018 09:30PM
You should post this in [github.com]

If you're using the 2015.03-2 version, try the development snapshot version.
Re: STL export should contain single precision floats
December 26, 2018 04:17AM
You are absolutely right, sorry for my confusing post! smiling smiley


RS-Online Ormerod #263, Kossel mini with Minitronics, Prusa i3 MK2
Sorry, only registered users may post in this forum.

Click here to login