discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

One polyhedron works but two fails

L
Leea
Sun, Jun 9, 2019 3:08 PM

I have two identical polyhedrons that do not touch. If I comment out either
one it will render just fine. But with both it fails render. I can't figure
out why. My searching would indicate a face issue but then should it fail on
just one of them. Must be some stupid typo and I have stared at it.

translate ([95.9,10,0])

polyhedron (
points = [
[0,0,0],
[7,0,0],
[0,0,6],
[0,1,0],
[7,1,0],
[0,1,6]
], 
faces = [
[0,1,4,3],  //bot
[0,1,2], //side
[3,4,5], // side
[1,2,5,4], //angle
[0,2,5,3], //back
]);

translate ([95.9,24,0])

polyhedron (
points = [
[0,0,0],
[7,0,0],
[0,0,6],
[0,1,0],
[7,1,0],
[0,1,6]
], 
faces = [
[0,1,4,3],  //bot
[0,1,2], //side
[3,4,5], // side
[1,2,5,4], //angle
[0,2,5,3], //back
]);

thanks much
Lee

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

I have two identical polyhedrons that do not touch. If I comment out either one it will render just fine. But with both it fails render. I can't figure out why. My searching would indicate a face issue but then should it fail on just one of them. Must be some stupid typo and I have stared at it. translate ([95.9,10,0]) polyhedron ( points = [ [0,0,0], [7,0,0], [0,0,6], [0,1,0], [7,1,0], [0,1,6] ], faces = [ [0,1,4,3], //bot [0,1,2], //side [3,4,5], // side [1,2,5,4], //angle [0,2,5,3], //back ]); translate ([95.9,24,0]) polyhedron ( points = [ [0,0,0], [7,0,0], [0,0,6], [0,1,0], [7,1,0], [0,1,6] ], faces = [ [0,1,4,3], //bot [0,1,2], //side [3,4,5], // side [1,2,5,4], //angle [0,2,5,3], //back ]); thanks much Lee -- Sent from: http://forum.openscad.org/
AC
A. Craig West
Sun, Jun 9, 2019 3:14 PM

If there is only one polyhedron, it is rendered with opengl, if there is
more than one I believe it uses opencsg. I had the same problem myself, it
turned out one of my faces was backwards

On Sun, 9 Jun 2019, 11:09 Leea, 683lee@337lee.com wrote:

I have two identical polyhedrons that do not touch. If I comment out either
one it will render just fine. But with both it fails render. I can't figure
out why. My searching would indicate a face issue but then should it fail
on
just one of them. Must be some stupid typo and I have stared at it.

translate ([95.9,10,0])

 polyhedron (
 points = [
 [0,0,0],
 [7,0,0],
 [0,0,6],
 [0,1,0],
 [7,1,0],
 [0,1,6]
 ],
 faces = [
 [0,1,4,3],  //bot
 [0,1,2], //side
 [3,4,5], // side
 [1,2,5,4], //angle
 [0,2,5,3], //back
 ]);

 translate ([95.9,24,0])

 polyhedron (
 points = [
 [0,0,0],
 [7,0,0],
 [0,0,6],
 [0,1,0],
 [7,1,0],
 [0,1,6]
 ],
 faces = [
 [0,1,4,3],  //bot
 [0,1,2], //side
 [3,4,5], // side
 [1,2,5,4], //angle
 [0,2,5,3], //back
 ]);

thanks much
Lee

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

If there is only one polyhedron, it is rendered with opengl, if there is more than one I believe it uses opencsg. I had the same problem myself, it turned out one of my faces was backwards On Sun, 9 Jun 2019, 11:09 Leea, <683lee@337lee.com> wrote: > I have two identical polyhedrons that do not touch. If I comment out either > one it will render just fine. But with both it fails render. I can't figure > out why. My searching would indicate a face issue but then should it fail > on > just one of them. Must be some stupid typo and I have stared at it. > > translate ([95.9,10,0]) > > polyhedron ( > points = [ > [0,0,0], > [7,0,0], > [0,0,6], > [0,1,0], > [7,1,0], > [0,1,6] > ], > faces = [ > [0,1,4,3], //bot > [0,1,2], //side > [3,4,5], // side > [1,2,5,4], //angle > [0,2,5,3], //back > ]); > > translate ([95.9,24,0]) > > polyhedron ( > points = [ > [0,0,0], > [7,0,0], > [0,0,6], > [0,1,0], > [7,1,0], > [0,1,6] > ], > faces = [ > [0,1,4,3], //bot > [0,1,2], //side > [3,4,5], // side > [1,2,5,4], //angle > [0,2,5,3], //back > ]); > > thanks much > Lee > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
A
adrianv
Sun, Jun 9, 2019 3:16 PM

You have backwards faces.  Use the "thrown together" option as suggested my
the manual and you will see them in purple.

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

You have backwards faces. Use the "thrown together" option as suggested my the manual and you will see them in purple. -- Sent from: http://forum.openscad.org/
AC
A. Craig West
Sun, Jun 9, 2019 3:24 PM

I didn't know it did that, that's cool. I wrote a library function to show
the normals of the faces of my polyhedrons

On Sun, 9 Jun 2019, 11:17 adrianv, avm4@cornell.edu wrote:

You have backwards faces.  Use the "thrown together" option as suggested my
the manual and you will see them in purple.

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I didn't know it did that, that's cool. I wrote a library function to show the normals of the faces of my polyhedrons On Sun, 9 Jun 2019, 11:17 adrianv, <avm4@cornell.edu> wrote: > You have backwards faces. Use the "thrown together" option as suggested my > the manual and you will see them in purple. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
JL
Jean-Paul Louis
Sun, Jun 9, 2019 3:32 PM

Not sure what’s wrong, but easy fix is:

module OBJ()
polyhedron (
points = [
[0,0,0],
[7,0,0],
[0,0,6],
[0,1,0],
[7,1,0],
[0,1,6]
],
faces = [
[0,1,4,3],  //bot
[0,1,2], //side
[3,4,5], // side
[1,2,5,4], //angle
[0,2,5,3], //back
]);

translate ([95.9,10,0]) OBJ();

translate ([95.9,24,0]) OBJ();

The preview works fine, but the rendering warns
that the object is not a valid 2-manifold. it is missing one face.

CGAL cache size in bytes: 23200
Total rendering time: 0 hours, 0 minutes, 0 seconds
Top level object is a 3D object:
Simple: no
Vertices: 12
Halfedges: 32
Edges: 16
Halffacets: 12
Facets: 6
Volumes: 1
WARNING: Object may not be a valid 2-manifold and may need repair!
Rendering finished.

On Jun 9, 2019, at 11:08 AM, Leea 683lee@337lee.com wrote:

I have two identical polyhedrons that do not touch. If I comment out either
one it will render just fine. But with both it fails render. I can't figure
out why. My searching would indicate a face issue but then should it fail on
just one of them. Must be some stupid typo and I have stared at it.

translate ([95.9,10,0])

polyhedron (
points = [
[0,0,0],
[7,0,0],
[0,0,6],
[0,1,0],
[7,1,0],
[0,1,6]
], 
faces = [
[0,1,4,3],  //bot
[0,1,2], //side
[3,4,5], // side
[1,2,5,4], //angle
[0,2,5,3], //back
]);

translate ([95.9,24,0])

polyhedron (
points = [
[0,0,0],
[7,0,0],
[0,0,6],
[0,1,0],
[7,1,0],
[0,1,6]
], 
faces = [
[0,1,4,3],  //bot
[0,1,2], //side
[3,4,5], // side
[1,2,5,4], //angle
[0,2,5,3], //back
]);

thanks much
Lee

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Not sure what’s wrong, but easy fix is: module OBJ() polyhedron ( points = [ [0,0,0], [7,0,0], [0,0,6], [0,1,0], [7,1,0], [0,1,6] ], faces = [ [0,1,4,3], //bot [0,1,2], //side [3,4,5], // side [1,2,5,4], //angle [0,2,5,3], //back ]); translate ([95.9,10,0]) OBJ(); translate ([95.9,24,0]) OBJ(); The preview works fine, but the rendering warns that the object is not a valid 2-manifold. it is missing one face. CGAL cache size in bytes: 23200 Total rendering time: 0 hours, 0 minutes, 0 seconds Top level object is a 3D object: Simple: no Vertices: 12 Halfedges: 32 Edges: 16 Halffacets: 12 Facets: 6 Volumes: 1 WARNING: Object may not be a valid 2-manifold and may need repair! Rendering finished. > On Jun 9, 2019, at 11:08 AM, Leea <683lee@337lee.com> wrote: > > I have two identical polyhedrons that do not touch. If I comment out either > one it will render just fine. But with both it fails render. I can't figure > out why. My searching would indicate a face issue but then should it fail on > just one of them. Must be some stupid typo and I have stared at it. > > translate ([95.9,10,0]) > > polyhedron ( > points = [ > [0,0,0], > [7,0,0], > [0,0,6], > [0,1,0], > [7,1,0], > [0,1,6] > ], > faces = [ > [0,1,4,3], //bot > [0,1,2], //side > [3,4,5], // side > [1,2,5,4], //angle > [0,2,5,3], //back > ]); > > translate ([95.9,24,0]) > > polyhedron ( > points = [ > [0,0,0], > [7,0,0], > [0,0,6], > [0,1,0], > [7,1,0], > [0,1,6] > ], > faces = [ > [0,1,4,3], //bot > [0,1,2], //side > [3,4,5], // side > [1,2,5,4], //angle > [0,2,5,3], //back > ]); > > thanks much > Lee > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
TP
Torsten Paul
Sun, Jun 9, 2019 3:37 PM

The only way to fix this is to flip the 2 faces with wrong
winding order:

faces = [
[0,1,4,3],  //bot
[0,2,1], //side      <-- this one
[3,4,5], // side
[1,2,5,4], //angle
[3,5,2,0], //back    <-- and that one
])

ciao,
Torsten.

The only way to fix this is to flip the 2 faces with wrong winding order: faces = [ [0,1,4,3], //bot [0,2,1], //side <-- this one [3,4,5], // side [1,2,5,4], //angle [3,5,2,0], //back <-- and that one ]) ciao, Torsten.
L
Leea
Sun, Jun 9, 2019 4:22 PM

Thanks guys.
I was leery of polyhedrons before and now I think I am afraid. At least I
know why my test one worked and then why my duplicate failed. I am printing
my part right now.
Is there a technique for when they get complicated to keep them orientated
correctly.
Lee

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

Thanks guys. I was leery of polyhedrons before and now I think I am afraid. At least I know why my test one worked and then why my duplicate failed. I am printing my part right now. Is there a technique for when they get complicated to keep them orientated correctly. Lee -- Sent from: http://forum.openscad.org/
AC
A. Craig West
Sun, Jun 9, 2019 4:35 PM

Mostly make sure they are all consistently clockwise or consistently
counterclockwise as seen from the outside

On Sun, 9 Jun 2019, 12:23 Leea, 683lee@337lee.com wrote:

Thanks guys.
I was leery of polyhedrons before and now I think I am afraid. At least I
know why my test one worked and then why my duplicate failed. I am printing
my part right now.
Is there a technique for when they get complicated to keep them orientated
correctly.
Lee

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Mostly make sure they are all consistently clockwise or consistently counterclockwise as seen from the outside On Sun, 9 Jun 2019, 12:23 Leea, <683lee@337lee.com> wrote: > Thanks guys. > I was leery of polyhedrons before and now I think I am afraid. At least I > know why my test one worked and then why my duplicate failed. I am printing > my part right now. > Is there a technique for when they get complicated to keep them orientated > correctly. > Lee > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
A
adrianv
Sun, Jun 9, 2019 4:41 PM

It can be pretty tricky, especially if constructing a polyhedron by hand, to
ensure that all of the faces are in the correct orientation.  My suggestions
are first, don't use polyhedron() when a simpler method exists.  In your
case, you could have made the triangle with polygon() and used
linear_extrude().

Second, define your problem in a general way and write a routine that makes
the general polyhedron type you need automatically.  Doing things in a
general way with an algorithm rather than by hand may make it easier to
ensure that edges are correctly flipped.  And if they aren't you only have
to debug your code once.  Or consider using libraries written by others
(e.g. BOSL or dotSCAD) that implement the thing you need, so somebody else
has figured out the orientation.

Thirdly, if your polyhedron is convex then just define its vertices and make
the faces using a convex hull, either Linde's hull or the hack below, which
makes a bogus polyhedron from your vertex list and then makes a real shape
by computing the convex hull.

https://github.com/OskarLinde/scad-utils/blob/master/hull.scad

module fastpointhull(points){
extra = len(points)%3;
list = concat(
[[for(i=[0:extra+2])i]],
[for(i=[extra+3:3:len(points)-3])[i,i+1,i+2]]);
hull() polyhedron(points, faces=list);
}

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

It can be pretty tricky, especially if constructing a polyhedron by hand, to ensure that all of the faces are in the correct orientation. My suggestions are first, don't use polyhedron() when a simpler method exists. In your case, you could have made the triangle with polygon() and used linear_extrude(). Second, define your problem in a general way and write a routine that makes the general polyhedron type you need automatically. Doing things in a general way with an algorithm rather than by hand may make it easier to ensure that edges are correctly flipped. And if they aren't you only have to debug your code once. Or consider using libraries written by others (e.g. BOSL or dotSCAD) that implement the thing you need, so somebody else has figured out the orientation. Thirdly, if your polyhedron is convex then just define its vertices and make the faces using a convex hull, either Linde's hull or the hack below, which makes a bogus polyhedron from your vertex list and then makes a real shape by computing the convex hull. https://github.com/OskarLinde/scad-utils/blob/master/hull.scad module fastpointhull(points){ extra = len(points)%3; list = concat( [[for(i=[0:extra+2])i]], [for(i=[extra+3:3:len(points)-3])[i,i+1,i+2]]); hull() polyhedron(points, faces=list); } -- Sent from: http://forum.openscad.org/
HJ
Hugo Jackson
Mon, Jun 10, 2019 6:29 PM

Thanks for bring up the hull.scad code from scad-utils… unfortunately it’s older code now and generates some warnings…

DEPRECATED: The assign() module will be removed in future releases. Use a regular assignment instead. in file hull.scad, line 308
WARNING: len() parameter could not be converted, in file hull.scad, line 303
WARNING: len() parameter could not be converted, in file hull.scad, line 303
WARNING: len() parameter could not be converted, in file hull.scad, line 303
WARNING: len() parameter could not be converted, in file hull.scad, line 303
WARNING: len() parameter could not be converted, in file hull.scad, line 303
Compiling design (CSG Products generation)...
WARNING: PolySet has degenerate polygons
WARNING: PolySet has degenerate polygons

Fairly easy to fix the assign deprecation… and I I think I solved the len() parameter warning by substituting is_list for the tests on line 303…
BUT fixing all of those doesn’t make the

WARNING: PolySet has degenerate polygons

Go away… can anyone familiar with this code point me in the right direction?

On Jun 9, 2019, at 9:41 AM, adrianv avm4@cornell.edu wrote:

It can be pretty tricky, especially if constructing a polyhedron by hand, to
ensure that all of the faces are in the correct orientation.  My suggestions
are first, don't use polyhedron() when a simpler method exists.  In your
case, you could have made the triangle with polygon() and used
linear_extrude().

Second, define your problem in a general way and write a routine that makes
the general polyhedron type you need automatically.  Doing things in a
general way with an algorithm rather than by hand may make it easier to
ensure that edges are correctly flipped.  And if they aren't you only have
to debug your code once.  Or consider using libraries written by others
(e.g. BOSL or dotSCAD) that implement the thing you need, so somebody else
has figured out the orientation.

Thirdly, if your polyhedron is convex then just define its vertices and make
the faces using a convex hull, either Linde's hull or the hack below, which
makes a bogus polyhedron from your vertex list and then makes a real shape
by computing the convex hull.

https://github.com/OskarLinde/scad-utils/blob/master/hull.scad

module fastpointhull(points){
extra = len(points)%3;
list = concat(
[[for(i=[0:extra+2])i]],
[for(i=[extra+3:3:len(points)-3])[i,i+1,i+2]]);
hull() polyhedron(points, faces=list);
}

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Thanks for bring up the hull.scad code from scad-utils… unfortunately it’s older code now and generates some warnings… DEPRECATED: The assign() module will be removed in future releases. Use a regular assignment instead. in file hull.scad, line 308 WARNING: len() parameter could not be converted, in file hull.scad, line 303 WARNING: len() parameter could not be converted, in file hull.scad, line 303 WARNING: len() parameter could not be converted, in file hull.scad, line 303 WARNING: len() parameter could not be converted, in file hull.scad, line 303 WARNING: len() parameter could not be converted, in file hull.scad, line 303 Compiling design (CSG Products generation)... WARNING: PolySet has degenerate polygons WARNING: PolySet has degenerate polygons Fairly easy to fix the assign deprecation… and I I think I solved the len() parameter warning by substituting is_list for the tests on line 303… BUT fixing all of those doesn’t make the WARNING: PolySet has degenerate polygons Go away… can anyone familiar with this code point me in the right direction? > On Jun 9, 2019, at 9:41 AM, adrianv <avm4@cornell.edu> wrote: > > It can be pretty tricky, especially if constructing a polyhedron by hand, to > ensure that all of the faces are in the correct orientation. My suggestions > are first, don't use polyhedron() when a simpler method exists. In your > case, you could have made the triangle with polygon() and used > linear_extrude(). > > Second, define your problem in a general way and write a routine that makes > the general polyhedron type you need automatically. Doing things in a > general way with an algorithm rather than by hand may make it easier to > ensure that edges are correctly flipped. And if they aren't you only have > to debug your code once. Or consider using libraries written by others > (e.g. BOSL or dotSCAD) that implement the thing you need, so somebody else > has figured out the orientation. > > Thirdly, if your polyhedron is convex then just define its vertices and make > the faces using a convex hull, either Linde's hull or the hack below, which > makes a bogus polyhedron from your vertex list and then makes a real shape > by computing the convex hull. > > https://github.com/OskarLinde/scad-utils/blob/master/hull.scad > > module fastpointhull(points){ > extra = len(points)%3; > list = concat( > [[for(i=[0:extra+2])i]], > [for(i=[extra+3:3:len(points)-3])[i,i+1,i+2]]); > hull() polyhedron(points, faces=list); > } > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org