From fbbc0f079698b1ac4961bf760cb5528bb84ec20e Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 28 Feb 2020 15:17:59 +0800 Subject: [PATCH] add closed param --- examples/hollow_out/hollow_torus_knot.scad | 2 +- src/experimental/hollow_out_sweep.scad | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/hollow_out/hollow_torus_knot.scad b/examples/hollow_out/hollow_torus_knot.scad index 41e2f42c..19910fab 100644 --- a/examples/hollow_out/hollow_torus_knot.scad +++ b/examples/hollow_out/hollow_torus_knot.scad @@ -46,5 +46,5 @@ module hollow_out_torus_knot(shape, p, q, phi_step, thickness, line_style) { pts = torus_knot(p, q, phi_step); sects = sects_by_path(shape, pts); - hollow_out_sweep(concat(sects, [sects[0]]), thickness, line_style); + hollow_out_sweep(sects, thickness, closed = true, style = line_style); } \ No newline at end of file diff --git a/src/experimental/hollow_out_sweep.scad b/src/experimental/hollow_out_sweep.scad index 3882bdf9..ac42397b 100644 --- a/src/experimental/hollow_out_sweep.scad +++ b/src/experimental/hollow_out_sweep.scad @@ -4,11 +4,11 @@ use ; use ; // style: LINES or HULL_LINES -module hollow_out_sweep(sections, thickness, style = "LINES") { +module hollow_out_sweep(sections, thickness, closed = false, style = "LINES") { function rects(sects) = let( - sects_leng = len(sections), - shape_pt_leng = len(sections[0]) + sects_leng = len(sects), + shape_pt_leng = len(sects[0]) ) [ for(i = [0:sects_leng - 2]) @@ -29,8 +29,9 @@ module hollow_out_sweep(sections, thickness, style = "LINES") { [[rect[0], rect[1], rect[2]], [rect[0], rect[2], rect[3]]] : [[rect[1], rect[2], rect[3]], [rect[1], rect[3], rect[0]]]; + sects = closed ? concat(sections, [sections[0]]) : sections; lines = [ - for(rect = rects(sections)) + for(rect = rects(sects)) for(tri = rand_tris(rect)) each tri_bisectors(tri) ];