From c3b1c4dd5ba1b30280f3bbb156d31d315c5fb935 Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Fri, 26 Aug 2022 14:10:37 -0700 Subject: [PATCH 1/5] Enable taper lookup tables. --- shapes3d.scad | 1 + skin.scad | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/shapes3d.scad b/shapes3d.scad index 122d1e7..ae94e91 100644 --- a/shapes3d.scad +++ b/shapes3d.scad @@ -1194,6 +1194,7 @@ function cylinder(h, r1, r2, center, l, r, d, d1, d2, anchor, spin=0, orient=UP) // tex_scale = Scaling multiplier for the texture depth. // tex_samples = Minimum number of "bend points" to have in VNF texture tiles. Default: 8 // tex_style = {{vnf_vertex_array()}} style used to triangulate heightfield textures. Default: "min_edge" +// tex_taper = If given as a number, tapers the texture height to zero over the first and last given percentage of the path. If given as a lookup table with indices between 0 and 100, uses the percentage lookup table to ramp the texture heights. Default: `undef` (no taper) // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` diff --git a/skin.scad b/skin.scad index b5d345b..73c11be 100644 --- a/skin.scad +++ b/skin.scad @@ -3211,7 +3211,7 @@ function _find_vnf_tile_edge_path(vnf, val) = /// rot = If true, rotates the texture 90ยบ. /// shift = [X,Y] amount to translate the top, relative to the bottom. Default: [0,0] /// closed = If false, and shape is given as a path, then the revolved path will be sealed to the axis of rotation with untextured caps. Default: `true` -/// taper = If given, and `closed=false`, tapers the texture height to zero over the first and last given percentage of the path. Default: `undef` (no taper) +/// taper = If given, and `closed=false`, tapers the texture height to zero over the first and last given percentage of the path. If given as a lookup table with indices between 0 and 100, uses the percentage lookup table to ramp the texture heights. Default: `undef` (no taper) /// angle = The number of degrees counter-clockwise from X+ to revolve around the Z axis. Default: `360` /// style = The triangulation style used. See {{vnf_vertex_array()}} for valid styles. Used only with heightfield type textures. Default: `"min_edge"` /// counts = If given instead of tex_size, gives the tile repetition counts for textures over the surface length and height. @@ -3239,7 +3239,8 @@ function _textured_revolution( assert(counts==undef || is_vector(counts,2)) assert(tex_size==undef || is_vector(tex_size,2)) assert(is_bool(rot) || in_list(rot,[0,90,180,270])) - assert(is_undef(taper) || (is_finite(taper) && taper>=0 && taper<50)) + let( taper_is_ok = is_undef(taper) || (is_finite(taper) && taper>=0 && taper<50) || is_path(taper,2) ) + assert(taper_is_ok, "Bad taper= value.") assert(in_list(atype, _ANCHOR_TYPES), "Anchor type must be \"hull\" or \"intersect\"") let( regions = !is_path(shape,2)? region_parts(shape) : @@ -3324,7 +3325,16 @@ function _textured_revolution( ? max(1,round(angle/360*circumf/tex_size.x)) : ceil(6*angle/360*circumf/h), taper_lup = closed || is_undef(taper)? [[-1,1],[2,1]] : - [[-1,0], [0,0], [taper/100+EPSILON,1], [1-taper/100-EPSILON,1], [1,0], [2,0]], + is_num(taper)? [[-1,0], [0,0], [taper/100+EPSILON,1], [1-taper/100-EPSILON,1], [1,0], [2,0]] : + is_path(taper,2)? let( + retaper = [ + for (t=taper) + assert(t[0]>=0 && t[0]<=100, "taper lookup indices must be betweem 0 and 100 inclusive.") + [t[0]/100, t[1]] + ], + taperout = [[-1,retaper[0][1]], each retaper, [2,last(retaper)[1]]] + ) taperout : + assert(false, "Bad taper= argument value."), full_vnf = vnf_join([ for (rgn = regions) let( rgn_wall_vnf = vnf_join([ From f3261c5eaf14a125dc68cd4481901d1e1c3d8073 Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Tue, 30 Aug 2022 19:45:14 -0700 Subject: [PATCH 2/5] Added a clay pattern roller example to cyl() --- shapes3d.scad | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/shapes3d.scad b/shapes3d.scad index ae94e91..5afa3e0 100644 --- a/shapes3d.scad +++ b/shapes3d.scad @@ -1287,6 +1287,38 @@ function cylinder(h, r1, r2, center, l, r, d, d1, d2, anchor, spin=0, orient=UP) // cyl(d1=25, d2=20, h=30, rounding=5, // texture="trunc_ribs", tex_taper=10, // tex_size=[5,1]); +// +// Example: Making a Clay Pattern Roller +// tex = [ +// [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,], +// [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,], +// [1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,], +// [1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,], +// [0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,], +// [0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,], +// [0,1,1,0,0,1,1,0,0,1,1,1,1,1,1,0,], +// [0,1,1,0,0,1,1,0,0,1,1,1,1,1,1,0,], +// [0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,], +// [0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,], +// [0,1,1,0,0,1,1,1,1,1,1,0,0,1,1,0,], +// [0,1,1,0,0,1,1,1,1,1,1,0,0,1,1,0,], +// [0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,], +// [0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,], +// [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,], +// [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,], +// [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,], +// ]; +// diff() +// cyl(d=20*10/PI, h=10, chamfer=0, +// texture=tex, tex_counts=[20,1], tex_scale=-1, +// tex_taper=undef, tex_style="concave") { +// attach([TOP,BOT]) { +// cyl(d1=20*10/PI, d2=30, h=5, anchor=BOT) +// attach(TOP) { +// tag("remove") zscale(0.5) up(3) sphere(d=15); +// } +// } +// } function cyl( h, r, center, From ec2827eb83a003df689e2f69cef6402d4b687678 Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Sat, 3 Sep 2022 17:00:11 -0700 Subject: [PATCH 3/5] Added find_modular_asserts.sh --- scripts/find_modular_asserts.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/find_modular_asserts.sh diff --git a/scripts/find_modular_asserts.sh b/scripts/find_modular_asserts.sh new file mode 100755 index 0000000..e737a75 --- /dev/null +++ b/scripts/find_modular_asserts.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +awk ' + /^module/{ + m=1 + split($2,narr,"(") + module=narr[1]"()" + } + /^function/{ + m=0 + module="" + } + /[^=] *assert\(/{ + if(m) { + if(fname!=FILENAME) { + fname=FILENAME + print "File",fname + } + if(prevmodule!=module) { + prevmodule=module + print " Module",module + } + assertline=$0 + sub(/^ */, "", assertline) + print " ",FNR,":",assertline + } + } +' *.scad + From feac6804fd6994c4f5757b89de1b55ba718e9030 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Wed, 14 Sep 2022 17:31:09 -0700 Subject: [PATCH 4/5] Fix for issue #935: rotate_sweep() heightfield texture caps were bad. --- skin.scad | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/skin.scad b/skin.scad index 73c11be..01095e7 100644 --- a/skin.scad +++ b/skin.scad @@ -3309,15 +3309,9 @@ function _textured_revolution( ) _vnf_sort_vertices(utex, idx=[0,1]), vertzs = is_vnf(texture)? group_sort(tile[0], idx=0) : undef, bpath = is_vnf(tile) - ? _find_vnf_tile_edge_path(tile,0) - : let( - row = tile[0], - rlen = len(row) - ) [for (i = [0:1:rlen]) [i/rlen, row[i%rlen]]], - tpath = is_vnf(tile) ? _find_vnf_tile_edge_path(tile,1) : let( - row = last(tile), + row = tile[0], rlen = len(row) ) [for (i = [0:1:rlen]) [i/rlen, row[i%rlen]]], counts_x = is_vector(counts,2)? counts.x : @@ -3470,7 +3464,7 @@ function _textured_revolution( base = select(bases,j), norm = unit(select(norms,j)), ppath = [ - for (vert = tpath) let( + for (vert = bpath) let( uang = vert.x / counts_x, tex_scale = tex_scale * lookup([0,1][j+1], taper_lup), texh = (vert.y - inset) * tex_scale * (base.x / maxx), From a2bf99cd64c87a69e2b24c874624393c7db477f7 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sat, 17 Sep 2022 12:40:15 -0700 Subject: [PATCH 5/5] Fixed Figure line. --- screws.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screws.scad b/screws.scad index fb7b86d..85e7764 100644 --- a/screws.scad +++ b/screws.scad @@ -170,7 +170,7 @@ Torx values: https://www.stanleyengineeredfastening.com/-/media/web/sef/resourc // . // The anchors and anchor types refer to various parts of the screw, which are labeled below. The "screw" anchor type (the default) is simply // the whole screw and the "head" anchor is the head. These anchors will anchor to bounding cylinder for the specified screw part, so -// Figure(2D,VPD = 113.4, VPT = [16.9671, 14.9021, -3.59741], VPR = [0, 0, 0],NoAxes) +// Figure(2D,VPD = 113.4, VPT = [16.9671, 14.9021, -3.59741], VPR = [0, 0, 0],NoAxes): // rpos=33; // fsize=2.5; // projection(cut=true) xrot(-90)screw("M8", head="socket", length=25, thread_len=10);