diff --git a/vnf.scad b/vnf.scad index abc82f02..bc127f48 100644 --- a/vnf.scad +++ b/vnf.scad @@ -40,15 +40,18 @@ EMPTY_VNF = [[],[]]; // The standard empty VNF with no vertices or faces. // and creating the faces defined by those edges. You can optionally create the edges and faces to wrap the last column // back to the first column, or wrap the last row to the first. Endcaps can be added to either // the first and/or last rows. The style parameter determines how the quadrilaterals are divided into -// triangles. The default style is an arbitrary, systematic subdivision in the same direction. The "alt" style -// is the uniform subdivision in the other (alternate) direction. The "flip1" style is an arbitrary division that alternates the -// direction for any adjacent pair of quadrilaterals. The "flip2" style is the alternating division that is the opposite of "flip1". -// The "min_edge" style picks the shorter edge to -// subdivide for each quadrilateral, so the division may not be uniform across the shape. The "quincunx" style -// adds a vertex in the center of each quadrilateral and creates four triangles, and the "convex" and "concave" styles -// choose the locally convex/concave subdivision. The "min_area" option creates the triangulation with the minimal area. -// The "quad" style makes quadrilateral edges, which may not be coplanar, relying on OpensCAD to decide how to handle them. Degenerate faces -// are not included in the output, but if this results in unused vertices, those unused vertices do still appear in the output. +// triangles. The styles are: +// * "default" — arbitrary, systematic subdivision in the same direction +// * "alt" — uniform subdivision in the other (alternate) direction +// * "flip1" — arbitrary division that alternates the direction adjacent pairs of quadrilaterals. +// * "flip2" — the alternating division that is the opposite of "flip1". +// * "min_edge" — subdivide each quadrilateral on its shorter edge, so the division may not be uniform across the shape +// * "min_area" — creates the triangulation with the minimal area. +// * "quincunx" — adds a vertex in the center of each quadrilateral and creates four triangles +// * "convex" — choose the locally convex division +// * "concave" — choose the locally concave division +// * "quad" — makes quadrilateral edges, which may not be coplanar, relying on OpensCAD to decide how to handle them. +// Degenerate faces are not included in the output, but if this results in unused vertices, those unused vertices do still appear in the output. // . // You can apply a texture to the vertex array VNF using the usual texture parameters. // See [Texturing](skin.scad#section-texturing) for more details on how textures work. @@ -388,9 +391,6 @@ function vnf_vertex_array( style=="quincunx"? let(i5 = pcnt + r*colcnt + c) [[i1,i5,i2],[i2,i5,i3],[i3,i5,i4],[i4,i5,i1]] - : style=="alt" || (style=="flip1" && ((r+c)%2==0)) || (style=="flip2" && ((r+c)%2==1)) || (style=="random" && rands(0,1,1)[0]<.5)? - [[i1,i4,i2],[i2,i4,i3]] - : style=="default" ? [[i1,i3,i2],[i1,i4,i3]] : style=="min_area"? let( area42 = norm(cross(pts[i2]-pts[i1], pts[i4]-pts[i1]))+norm(cross(pts[i4]-pts[i3], pts[i2]-pts[i3])), @@ -429,7 +429,10 @@ function vnf_vertex_array( : [[i1,i3,i2],[i1,i4,i3]] ) concavefaces - : [[i1,i2,i3,i4]], + : style=="quad" ? [[i1,i2,i3,i4]] + : style=="alt" || (style=="flip1" && ((r+c)%2==0)) || (style=="flip2" && ((r+c)%2==1)) || (style=="random" && rands(0,1,1)[0]<.5)? + [[i1,i4,i2],[i2,i4,i3]] + : [[i1,i3,i2],[i1,i4,i3]], // remove degenerate faces culled_faces= [for(face=faces) if (norm(cross(verts[face[1]]-verts[face[0]],