Discussion:
[OpenSCAD] Polyhedron rendering with missing faces
matt_391
2018-11-30 14:09:19 UTC
Permalink
Hi All

I'm new to OpenSCAD, so apologies if this is a rookie error or a know issue,
but I haven't been able to find any references to searching the forum or
github bug tracker. I'm posting here to try and find out if this is a true
bug or if I'm making a mistake!

My issue is that a polyhedron will often render missing some faces; consider
the following minimal example (screenshot of my result at the bottom):

polyhedron( points = [[0,0,0] , [10,0,0] , [0,10,0] , [0,0,10]] , faces =
[[0,1,2],[0,1,3],[0,2,3],[1,2,3]]);
translate([20,0,0]) cube(5);

Note that if I render the polyhedron without the cube afterward (i.e. just
the first line), it renders correctly. My workaround has been two wrap the
polyhedron in a "hull", but this seems dangerous; what if a more complex
polyhedron fails such that one of the vertices has no faces meeting it? It
would get miss off the hull, I suspect.

Thanks in advance for any help or advice.

screenshot:
<Loading Image...>



--
Sent from: http://forum.openscad.org/
a***@arnholm.org
2018-11-30 14:54:35 UTC
Permalink
Post by matt_391
polyhedron( points = [[0,0,0] , [10,0,0] , [0,10,0] , [0,0,10]] , faces =
[[0,1,2],[0,1,3],[0,2,3],[1,2,3]]);
translate([20,0,0]) cube(5);
Note that if I render the polyhedron without the cube afterward (i.e. just
the first line), it renders correctly.
Actually, it does not. Press F12 (View -> Thrown Together) to see if any
faces are inside-out, indicated by red color. In this case the triangle
in the XZ-plane and the one that touches each global axis are both
inside-out, making it an invalid polyhedron. All face normals should
point out of the polyhedron to make it valid. To achieve this, the face
vertices must be listed in CW order as seen from outside the polyhedron
(this is opposite convention to other software, but anyway).

Wrapping the polyhedron in a hull will work in this case as the hull
will discard the faces and define new ones with proper orientations.
This will be ok as long as the polyhedron is convex, but will as you
undicate not work for polyhedra with concavities.

Regards
Carsten Arnholm
matt_391
2018-11-30 15:08:08 UTC
Permalink
Hi Carsten

Thanks for the help! I guess I'll have to be more careful defining my faces
in future...

Cheers



--
Sent from: http://forum.openscad.org/
matt_391
2018-11-30 15:08:39 UTC
Permalink
Hi Carsten

Thanks for the help! I guess I'll have to be more careful defining my faces
in future...

Cheers



--
Sent from: http://forum.openscad.org/

Loading...