From 27928eac700e68d122753c4c136160da4a94eb90 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Tue, 13 Apr 2021 20:21:19 -0400 Subject: [PATCH] bug fixes for caps and style --- skin.scad | 11 ++++++----- tests/test_skin.scad | 6 +++--- vnf.scad | 26 ++++++++++++++------------ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/skin.scad b/skin.scad index 446a938..d00fe2a 100644 --- a/skin.scad +++ b/skin.scad @@ -379,8 +379,8 @@ // } module skin(profiles, slices, refine=1, method="direct", sampling, caps, closed=false, z, style="min_edge", convexity=10, anchor="origin",cp,spin=0, orient=UP, extent=false) -{ - vnf = skin(profiles, slices, refine, method, sampling, caps, closed, z, style); +{ + vnf = skin(profiles, slices, refine, method, sampling, caps, closed, z, style=style); attachable(anchor=anchor, spin=spin, orient=orient, vnf=vnf, extent=extent, cp=is_def(cp) ? cp : vnf_centroid(vnf)) { vnf_polyhedron(vnf,convexity=convexity); @@ -390,6 +390,7 @@ module skin(profiles, slices, refine=1, method="direct", sampling, caps, closed= function skin(profiles, slices, refine=1, method="direct", sampling, caps, closed=false, z, style="min_edge") = + let(a=echo(style=style)) assert(is_def(slices),"The slices argument must be specified.") assert(is_list(profiles) && len(profiles)>1, "Must provide at least two profiles") let( bad = [for(i=idx(profiles)) if (!(is_path(profiles[i]) && len(profiles[i])>2)) i]) @@ -484,7 +485,7 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close ) each subdivide_and_slice(pair,slices[i], nsamples, method=sampling)] ) - vnf_vertex_array(full_list, caps=fullcaps, col_wrap=true, style=style); + vnf_vertex_array(full_list, cap1=fullcaps[0], cap2=fullcaps[1], col_wrap=true, style=style); @@ -928,7 +929,7 @@ function sweep(shape, transforms, closed=false, caps, style="min_edge") = ) vnf : assert(len(shape)>=3, "shape must be a path of at least 3 non-colinear points") vnf_vertex_array([for(i=[0:len(transforms)-(closed?0:1)]) apply(transforms[i%len(transforms)],path3d(shape))], - caps=fullcaps,col_wrap=true,style=style); + cap1=fullcaps[0],cap2=fullcaps[1],col_wrap=true,style=style); module sweep(shape, transforms, closed=false, caps, style="min_edge", convexity=10, @@ -1419,7 +1420,7 @@ function path_sweep2d(shape, path, closed=false, caps, quality=1, style="min_edg vnf_vertex_array([ each proflist, if (closed) proflist[0] - ],caps=fullcaps,col_wrap=true,style=style); + ],cap1=fullcaps[0],cap1=fullcaps[1],col_wrap=true,style=style); module path_sweep2d(profile, path, closed=false, caps, quality=1, style="min_edge", convexity=10, diff --git a/tests/test_skin.scad b/tests/test_skin.scad index c4a231d..ec0fc52 100644 --- a/tests/test_skin.scad +++ b/tests/test_skin.scad @@ -8,10 +8,10 @@ module test_skin() { [[-100,-100,100], [-100,100,100], [100,100,100], [100,-100,100]], ]; vnf1 = skin(profiles, slices=0, caps=false, method="distance"); - assert_equal(vnf1, [[[-100,-100,0],[0,100,0],[0,100,0],[100,-100,0],[-100,-100,100],[-100,100,100],[100,100,100],[100,-100,100]],[[0,5,4],[0,1,5],[1,6,5],[1,2,6],[2,3,6],[3,7,6],[3,4,7],[3,0,4]]]); + assert_equal(vnf1, [[[-100,-100,0],[0,100,0],[0,100,0],[100,-100,0],[-100,-100,100],[-100,100,100],[100,100,100],[100,-100,100]],[[0,5,4],[0,1,5],[5,2,6],[2,3,6],[6,3,7],[3,0,7],[7,0,4]]]); + vnf2 = skin(profiles, slices=0, caps=true, method="distance"); - assert_equal(vnf2, [[[-100,-100,0],[0,100,0],[0,100,0],[100,-100,0],[-100,-100,100],[-100,100,100],[100,100,100],[100,-100,100]],[[0,5,4],[0,1,5],[1,6,5],[1,2,6],[2,3,6],[3,7,6],[3,4,7],[3,0,4],[3,2,1,0],[4,5,6,7]]]); - vnf_polyhedron(vnf2); + assert_equal(vnf2,[[[-100,-100,0],[0,100,0],[0,100,0],[100,-100,0],[-100,-100,100],[-100,100,100],[100,100,100],[100,-100,100]],[[0,5,4],[0,1,5],[5,2,6],[2,3,6],[6,3,7],[3,0,7],[7,0,4],[3,2,1,0],[4,5,6,7]]]); } test_skin(); diff --git a/vnf.scad b/vnf.scad index d893929..452743e 100644 --- a/vnf.scad +++ b/vnf.scad @@ -155,17 +155,19 @@ function vnf_merge(vnfs, cleanup=false) = ) [ [for (vnf=vnfs) each vnf[0]], [ - for (i = idx(vnfs)) let( - vnf = vnfs[i], - verts = vnf[0], - faces = vnf[1] - ) - for (face = faces) let( - dface = !cleanup ? face : - deduplicate_indexed(verts, face, closed=true) - ) - if (len(dface) >= 3) - [ for (j = dface) offs[i] + j ] + for (i = idx(vnfs)) + let( + vnf = vnfs[i], + verts = vnf[0], + faces = vnf[1] + ) + for (face = faces) + let( + dface = !cleanup ? face + : deduplicate_indexed(verts, face, closed=true) + ) + if (len(dface) >= 3) + [ for (j = dface) offs[i] + j ] ] ]; @@ -348,7 +350,7 @@ function vnf_vertex_array( : [[i1,i3,i2],[i1,i4,i3]] ) shortface - : style=="convex"? + : style=="convex"? // This style bombs on degenerate faces let( fsets = [ [[i1,i4,i2],[i2,i4,i3]],