From b0042882c9a87de6df7108823bf488a6d57b1015 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Sat, 21 Jan 2023 13:36:33 -0500 Subject: [PATCH] fix vnf_vertex_array bug where zero area faces don't get removed --- skin.scad | 33 ++------------------------------- vnf.scad | 5 ++--- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/skin.scad b/skin.scad index 19187f5..4d9dbcf 100644 --- a/skin.scad +++ b/skin.scad @@ -2585,9 +2585,9 @@ function associate_vertices(polygons, split, curpoly=0) = // Another serious limitation is more subtle. In the 2D examples above, it is obvious how to connect the // dots together. But in 3D example we need to triangulate the points on a grid, and this triangulation is not unique. // The `style` argument lets you specify how the points are triangulated using the styles supported by {{vnf_vertex_array()}}. -// In the example below we have expanded the 2D example into 3D: [[0,0,0,0],[0,1,1,0],[0,1,1,0],[0,0,0,0]], and we show the +// In the example below we have expanded the 2D example into 3D: `[[0,0,0,0],[0,1,1,0],[0,1,1,0],[0,0,0,0]]`, and we show the // 3D triangulations produced by the different styles: -// Figure(Big, NoAxes, VPR = [39.2, 0, 13.3], VPT = [3.76242, -5.50969, 4.51854], VPD = 32.0275): +// Figure(Big,NoAxes,VPR=[39.2,0,13.3],VPT=[3.76242,-5.50969,4.51854],VPD=32.0275): // tex = [ // [0,0,0,0,0], // [0,1,1,0,0], @@ -3432,35 +3432,6 @@ function _textured_linear_sweep( ) reorient(anchor,spin,orient, vnf=final_vnf, extent=true, anchors=anchors, p=final_vnf); -module _textured_linear_sweep( - path, texture, tex_size=[5,5], h, - inset=false, rot=false, tex_scale=1, - twist, scale, shift, samples, caps=true, - style="min_edge", l, - height, length, counts, - anchor=CENTER, spin=0, orient=UP, - convexity=10 -) { - h = first_defined([h, l, height, length, 1]); - vnf = _textured_linear_sweep( - path, texture, h=h, caps=caps, - tex_size=tex_size, counts=counts, - inset=inset, rot=rot, tex_scale=tex_scale, - twist=twist, scale=scale, shift=shift, - samples=samples, style=style, - anchor=CENTER, spin=0, orient=UP - ); - cent = centroid(path); - anchors = [ - named_anchor("centroid_top", point3d(cent, h/2), UP), - named_anchor("centroid", point3d(cent), UP), - named_anchor("centroid_bot", point3d(cent,-h/2), DOWN) - ]; - attachable(anchor,spin,orient, vnf=vnf, extent=true, anchors=anchors) { - vnf_polyhedron(vnf, convexity=convexity); - children(); - } -} function _find_vnf_tile_edge_path(vnf, val) = let( diff --git a/vnf.scad b/vnf.scad index b4c52e8..1f34297 100644 --- a/vnf.scad +++ b/vnf.scad @@ -206,9 +206,8 @@ function vnf_vertex_array( : [[i1,i3,i2],[i1,i4,i3]], // remove degenerate faces culled_faces= [for(face=faces) - if (norm(verts[face[0]]-verts[face[1]])>EPSILON && - norm(verts[face[1]]-verts[face[2]])>EPSILON && - norm(verts[face[2]]-verts[face[0]])>EPSILON) + if (norm(cross(verts[face[1]]-verts[face[0]], + verts[face[2]]-verts[face[0]]))>EPSILON) face ], rfaces = reverse? [for (face=culled_faces) reverse(face)] : culled_faces