[OpenSCAD] Drawing a horn torus and the dreaded "winding order" error
Triffid Hunter
triffid.hunter at gmail.com
Wed Aug 17 11:02:06 CEST 2011
The problem is that a 3d mesh can do anything it likes. A "manifold"
mesh is a /special type/ of mesh that describes the surface of a 3d
solid.
A 3d solid has a number of specific properties when represented as a
mesh, namely that every edge has exactly two adjacent faces, no faces
intersect except at edges/vertices, the normals of the faces adjacent
to each edge consistently describe an inside and an outside such that
the object as a whole also has a consistent inside and outside. This
is not an exhaustive list, there may be more.
Openscad uses a CSG library that represents solids as meshes. It can't
always work out how to /keep/ the mesh describing a 3d solid.
When your torus self-intersects in the middle, you have faces where
both sides are 'inside' the object, and it is therefore no longer a 3d
solid, but something from an escher drawing. This produces all sorts
of errors when you try to treat it like a 3d solid!
We can mentally remove these faces to maintain manifoldness and draw
new edges along the intersections, but it's a shade trickier getting a
computer to know that it needs to do the same. Another possible
solution is to draw new edges at the intersections, and flip the inner
faces so that the overlap section is 'outside' like a bubble. How can
your computer know which is correct? Currently, it picks neither
solution and leaves the faces as they are because it assumes that
you'd tell it if you were doing crazy stuff like that.
Simplest workaround is to remove the offending section, and plug it
with something simple if you don't want a hole there, e.g.; union with
a 10x10x1 cube or something.
Beware: coplanar faces (such as tangents) cause similar issues with
manifoldness, but they're better and more widely described, and have
simpler workarounds.
On Wed, Aug 17, 2011 at 6:26 PM, Jez Weston <jezweston at yahoo.com> wrote:
>
> That's a cunning idea. It seems to be working.
> ________________________________
> From: Triffid Hunter <triffid.hunter at gmail.com>
> To: Jez Weston <jezweston at yahoo.com>; openscad at rocklinux.org
> Sent: Wednesday, 17 August 2011, 19:14
> Subject: Re: [OpenSCAD] Drawing a horn torus and the dreaded "winding order"
> error
>
> perhaps subtract a small cylinder from the center of your torus, so the self
> intersecting part is removed?
>
> On 17/08/2011 4:11 PM, "Jez Weston" <jezweston at yahoo.com> wrote:
>
>
> Ok, the geometry below attempts to use a torus to smooth a joint between two
> cylinders at right angles to each other. When the major radius of the torus
> is greater than twice the minor radius, the geometry is created just fine.
> If the major radius is less than twice, then CSG works, but CGAL causes
> problems. When using a union() statement , I get the "ERROR: Illegal
> polygonal object - make sure all polygons are defined with the same winding
> order. Skipping affected object." and the torus is not drawn. Without the
> union statement (i.e. just drawing the two cylinders and the torus) I get a
> C++ exception and a crash.
> I think this must be something to do with the torus intersecting itself, but
> I'm buggered if I know what to do about it. I've tried changing the
> qualityfn and convexity numbers, to no avail.
>
> Any ideas on how can I either get this code to work or to draw a similar
> shape?
>
> Jez
>
>
> -----------------------------------------------------------
> // Model specific parameters
> qualityfn = 36;
> convexityn = 10;
> cylinder_radius = 7; // Radius of cylinders and minor radius of torus
> join_radius = 13.9; // Major radius of torus and radius of blend between
> cylinders
> // 13.9 or smaller is ok in CSG but crashes CGAL
> // 14.1 works fine for both
> SmoothJoinCylinders ( 70, 130, cylinder_radius, join_radius);
> module SmoothJoinCylinders ( w, l, r1, r2 ) {
> union() {
> // Bottom edge
> translate ([r2, r1, 0])
> rotate ( a = 90, v = [0,1,0])
> cylinder ( h = w-r2-r2, r= r1, $fn = qualityfn );
> // Bottom left corner
> translate ([ r2, r2, 0 ])
> rotate_extrude (convexity = convexityn, $fn = qualityfn)
> translate ([ r2-r1, 0, 0 ])
> circle (r = r1 );
> // Left edge
> translate ([r1, r2, 0])
> rotate ( a = -90, v = [1,0,0])
> cylinder ( h = l-r2-r2, r = r1, $fn = qualityfn );
> }
> }
> -----------------------------------------------------------
>
>
>
>
>
> ________________________________
> From: Jez Weston <jezweston at yahoo.com>
> To: "openscad at rocklinux.org" <openscad at rocklinux.org>
> Sent: Wednesday, 10 August 2011, 23:04
> Subject: Re: [OpenSCAD] Drawing a horn torus and the dreaded "winding order"
> error
>
> Hmm... I'm finding that for some geometry, my fudge factor needs to be much
> larger than that, mill...
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad
>
>
More information about the OpenSCAD
mailing list