# Polyhedron: degenerated triangles are allowed, but quads...

7 messages
Open this post in threaded view
|

## Polyhedron: degenerated triangles are allowed, but quads...

 Consider the following code of a prism degenerated in a tetrahedron: v = [ [0,0,0], [50,0,0], [0,50,0],       [0,0,50], [0,0,50], [0,0,50] ]; f1 = [ [0,1,2],   //base        [1,0,3,4], // three degenerated quads -> triangles        [2,1,4,5],        [0,2,5,3],        [3,4,5] ]; // triangle degenerated to a point f2 = [ [0,1,2],         // base        [0,4,1], [0,3,4],  // one degenerated triangle        [1,5,2], [1,4,5],  // one degenerated triangle        [2,3,0], [2,5,3],  // one degenerated triangle        [3,4,5]  ]; // triangle degenerated in a point polyhedron(v,f1); translate([60,0,0]) polyhedron(v,f2); translate([0,70,0]) cube(10); The´polyhedron (v,f1) has a triangular face ([3,4,5]) degenerated to a point and 3 quads degenerated in triangles. The polyhedron (v,f2) has the same degenerated triangular face and 3 other triangular faces degenerated in line segments. The surprising result is: (v,f2) is previewed and rendered (with (v,f1) commented) correctly even with the presence of the cube; but (v,f2) preview and render has 3 missing faces even when it is alone. In short: degenerated triangles are allowed in polyhedron, degenerated quads are suppressed. A preview: What is even more striking: if we insert three additional vertex in the edges of the tetrahedron base and change (v,f1) accordingly, the quad faces turns to degenerated pentagons and the model is previewed and rendered correctly!!! v3 = [ [0,0,0], [50,0,0], [0,50,0],        [0,0,50], [0,0,50], [0,0,50], [25,0,0], [25,25,0], [0,25,0] ]; f3 = [ [0,6,1,7,2,8],        [1,6,0,3,4], [2,7,1,4,5], [0,8,2,5,3], [3,4,5] ]; polyhedron(v3,f3); cube(); I have got the same results with versions 2015.03-2 and 2016.11.11. This is breaking some of my loft codes.
Open this post in threaded view
|

## Re: Polyhedron: degenerated triangles are allowed, but quads...

 It seems that polyhedron does some silent "repair" (exclusion) of degenerate triags, but not of degenerate quads or larger polygons. Despite that I wouldn't build on degenerated stuff like that and don't like silent repairs at all, you could try to turn your quads (and larger polygons) into triags and trust on polyhedron to filter your triag soup appropriately. But be sure to check the results at STL level. If you don't check by inserting a dummy boolean operation into your design, OpenSCAD for now also lets you create and export degenerate 3D objects like the following.   v = [ [0,0,0], [50,0,0], [0,50,0], [0,0,50] ]; polyhedron(v,[[0,1,2]]); polyhedron(v,[[0,2,3]]); polyhedron(v,[[0,3,1]]); polyhedron(v,[[1,3,2]]);   I don't see much reason why this should be a false approach, besides the little fact, that it is not specified for the language OpenSCAD to construct 3D Objects by a union of surfaces defined by polyhedrons. While the STL-Exporter creates some faulty thing out of this, the AMF-Exporter suprisingly does the job.
Open this post in threaded view
|

## Re: Polyhedron: degenerated triangles are allowed, but quads...

 I have found that degenerated triangles are discarded, quads degenerated in triangles are also discarded but pentagons degenerated in quads are not! And this seems to be a bug or, at least, an very idiosyncratic repair. Your example is also striking. After render, the console shows there are 2 volumes (which ones?). If any of the polyhedron is dropped, the render will warn for possible non-manifold and consider only one volume. I have checked the stl: it has 8 facets, two for each one you have defined with opposed normals and inverted circulation. The generated stl for just one of your polyhedron (just one facet) will have just one facet. A real mess. I surely can avoid degenerated quads by checking or I can triangulate every quad. But why I should do that (which will double the number of facets to send to polyhedron) if there is a automatic triangulation inside the OpenSCAD code? Either it works with all cases or it is worthless.
Open this post in threaded view
|

## Re: Polyhedron: degenerated triangles are allowed, but quads...

 the count of the rendered volumes generally seems to have an offset of 1. Try translate([0,70,0]) cube(10); translate([0,-70,0]) cube(10);
Open this post in threaded view
|

## Re: Polyhedron: degenerated triangles are allowed, but quads...

 In reply to this post by Ronaldo I have found more strange behaviors of the degenerated cases. When I render just the polyhedron (v,f1) ( the one that has degenerated quads) the result is the same of the preview: it displays just the base eliminating all quads. The generated stl has only one face. But if I render polyhedron (v,f1) and something else (like a cube) both are displayed correctly and the generated stl is also correct. This suggests that when the scene has just one model, OpenSCAD does "repairs" that are not done when there is more than one object in the scene. And the bug is just in this repair.