Hello,
importing in meshlab 1.3.3 (32 bits version on Linux) a STL of a simple cylinder genrated from openscad fails.
The openscad code I use is simply the following, with fn varying, starting from 3:
cylinder(10, 10, 10, $fn=3);
With any number of faces different from 4, the import fails with the error message "Premature End of file". With $fn = 4, the import "succeeds" but only the top and bottom square are imported (4 faces as each square consists of 2 triangles).
Using admesh to attempt to fix the STL from openscad produces an STL that meshlab manage to import but the resulting mesh has no vertice nor face.
Regards,
Colin
I attach the STL produced for $fn=3, 4 and 5.
Here is the file for $fn=3 "fixed" by admesh. As said in initial post, it is imported but the result is empty.
And here are the files for $fn=4 and $fn=5. Sorry, I only found now how to attach multiple files at once :-)
I found what the issue is !
It's a problem of locale.
I'm french and therefore the locale makes scanf interpret numbers using ',' as decimal separator, not '.'.
When running meshlab with LANG=en_US environment variable instead of LANG=fr_FR.utf8 this works well.
The thing that is funny is that when I call ImporterSTL from a test program, it works well, ignoring my locale. I don't understand why this works differently when running meshlab.
I'll continue to dig into this.
Regards,
Colin
I don't find any call to setlocale in the code.
In main.cpp of meshlab, I find the line:
QLocale::setDefault(QLocale::C);
but from the doc, I understand it only impacts QT objects and methods.
Calling setlocale in ImporterSTL::OpenAscii to query the values of LC_ALL and LC_NUMERIC:
In my test program, I have:
OpenAscii(/home/colin/Navlab/Cylinder3.stl): LC_ALL=C, LC_NUMERIC=C
Whereas in meshlab, I have:
OpenAscii(/home/colin/Navlab/Cylinder3.stl): LC_ALL=fr_FR.utf8, LC_NUMERIC=fr_FR.utf8
Maybe it's QT or another external library that set the locales based on LANG environment variable ?
This seems to be the explanation:
http://stackoverflow.com/questions/25661295/why-does-qcoreapplication-call-setlocalelc-all-by-default-on-unix-linux
So basically, a call to setlocale(LC_ALL, "C") in main.cpp after creating the application object should solve the problem.
I tried it, and it does work !
Find attached the patch to apply in meshlab svn repository top directory with:
patch -p 0 < fix_local_stl_import.patch
Regards,
Colin
Similar issue reported previously: https://sourceforge.net/p/meshlab/bugs/127/