Imported STL render problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Imported STL render problem

Adam Milner
I was working on using OpenSCAD to create an array of objects, and
anyway, forget the back story.

I'm having problems rendering an imported STL.  It compiles fine and
both Meshlab and Netfabb can't find any problems with it.  The "Thrown
Together" display option also doesn't show any problems.  Is this a
known bug?

My minimal test script is:
file_name = "M3_f.stl";
file_convexity = 4;
import_stl(file_name, convexity = file_convexity);

and the stl is at http://www.thingiverse.com/thing:5704

I'm running release 2010.05 on Windows 7 32 bit.

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: Imported STL render problem

kintel
Administrator
On Apr 29, 2011, at 17:37 PM, Adam Milner wrote:

> I'm having problems rendering an imported STL.  It compiles fine and
> both Meshlab and Netfabb can't find any problems with it.

This is a problem related to an underlying library we use (CGAL), which requires all polygons in an imported model to have the same winding order. This has been discussed multiple times on the mailing list, but I don't really have a solution for it atm.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Imported STL render problem

wayne_gramlich
On 04/29/2011 02:57 PM, Marius Kintel wrote:
> On Apr 29, 2011, at 17:37 PM, Adam Milner wrote:
>
>> I'm having problems rendering an imported STL.  It compiles fine and
>> both Meshlab and Netfabb can't find any problems with it.
>
> This is a problem related to an underlying library we use (CGAL),
 > which requires all polygons in an imported model to have the same
 > winding order. This has been discussed multiple times on the mailing
 > list, but I don't really have a solution for it atm.

Forgive me it this has been discussed before, but if you know the
correct winding of one triangle, you can set the neighboring triangles
so that their edge windings are opposite.  If you do this recursively,
you will get all triangles in a consistent winding order.

If you find a point with the largest Z value (there may be more than
one), and look at all of the triangle attached to that point.  Each
triangle can have two normals depending upon winding order.  Search
all the normal pairs looking for the one that is closest to vertical
(again, there may be multiple triangles with the same normal closest
to vertical.)   The normal closest to vertical is the normal of a
triangle that is properly wound.  You can use this triangle along
with the recursive algorithm in the paragraph above to get all
triangles properly wound.

-Wayne