mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-30 00:09:37 +00:00
Enhanced sweep() to accept region input.
This commit is contained in:
parent
e4f2497863
commit
9d5d7cbc4f
3 changed files with 30 additions and 16 deletions
|
@ -285,8 +285,8 @@ function region_faces(region, transform, reverse=false, vnf=EMPTY_VNF) =
|
||||||
vnfs = [
|
vnfs = [
|
||||||
if (vnf != EMPTY_VNF) vnf,
|
if (vnf != EMPTY_VNF) vnf,
|
||||||
for (rgn = regions) let(
|
for (rgn = regions) let(
|
||||||
cleaved = _cleave_simple_region(rgn),
|
cleaved = path3d(_cleave_simple_region(rgn)),
|
||||||
face = is_undef(transform)? cleaved : apply(transform,path3d(cleaved)),
|
face = is_undef(transform)? cleaved : apply(transform,cleaved),
|
||||||
faceidxs = reverse? [for (i=[len(face)-1:-1:0]) i] : [for (i=[0:1:len(face)-1]) i]
|
faceidxs = reverse? [for (i=[len(face)-1:-1:0]) i] : [for (i=[0:1:len(face)-1]) i]
|
||||||
) [face, [faceidxs]]
|
) [face, [faceidxs]]
|
||||||
],
|
],
|
||||||
|
|
40
skin.scad
40
skin.scad
|
@ -873,19 +873,33 @@ function associate_vertices(polygons, split, curpoly=0) =
|
||||||
// sweep(shape, concat(outside,inside));
|
// sweep(shape, concat(outside,inside));
|
||||||
|
|
||||||
function sweep(shape, transformations, closed=false, caps) =
|
function sweep(shape, transformations, closed=false, caps) =
|
||||||
assert(is_list_of(transformations, ident(4)), "Input transformations must be a list of numeric 4x4 matrices in sweep")
|
assert(is_list_of(transformations, ident(4)), "Input transformations must be a list of numeric 4x4 matrices in sweep")
|
||||||
assert(is_path(shape,2), "Input shape must be a 2d path")
|
assert(is_path(shape,2) || is_region(shape), "Input shape must be a 2d path or a region.")
|
||||||
let(
|
let(
|
||||||
caps = is_def(caps) ? caps :
|
caps = is_def(caps) ? caps :
|
||||||
closed ? false : true,
|
closed ? false : true,
|
||||||
capsOK = is_bool(caps) || (is_list(caps) && len(caps)==2 && is_bool(caps[0]) && is_bool(caps[1])),
|
capsOK = is_bool(caps) || (is_list(caps) && len(caps)==2 && is_bool(caps[0]) && is_bool(caps[1])),
|
||||||
fullcaps = is_bool(caps) ? [caps,caps] : caps
|
fullcaps = is_bool(caps) ? [caps,caps] : caps
|
||||||
)
|
)
|
||||||
assert(len(transformations), "transformation must be length 2 or more")
|
assert(len(transformations), "transformation must be length 2 or more")
|
||||||
assert(len(shape)>=3, "shape must be a path of at least 3 points")
|
assert(capsOK, "caps must be boolean or a list of two booleans")
|
||||||
assert(capsOK, "caps must be boolean or a list of two booleans")
|
assert(!closed || !caps, "Cannot make closed shape with caps")
|
||||||
assert(!closed || !caps, "Cannot make closed shape with caps")
|
is_region(shape)? let(
|
||||||
_skin_core([for(i=[0:len(transformations)-(closed?0:1)]) apply(transformations[i%len(transformations)],path3d(shape))],caps=fullcaps);
|
regions = split_nested_region(shape),
|
||||||
|
rtrans = reverse(transformations),
|
||||||
|
vnfs = [
|
||||||
|
for (rgn=regions) each [
|
||||||
|
for (path=select(rgn,0,-1))
|
||||||
|
sweep(path, transformations, closed=closed, caps=false),
|
||||||
|
if (fullcaps[0]) region_faces(rgn, reverse=true),
|
||||||
|
if (fullcaps[1]) region_faces(rgn, transform=select(transformations,-1)),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
vnf = vnf_merge(vnfs)
|
||||||
|
) vnf :
|
||||||
|
assert(len(shape)>=3, "shape must be a path of at least 3 non-colinear points")
|
||||||
|
_skin_core([for(i=[0:len(transformations)-(closed?0:1)]) apply(transformations[i%len(transformations)],path3d(shape))],caps=fullcaps);
|
||||||
|
|
||||||
|
|
||||||
module sweep(shape, transformations, closed=false, caps, convexity=10,
|
module sweep(shape, transformations, closed=false, caps, convexity=10,
|
||||||
anchor="origin",cp,spin=0, orient=UP, extent=false)
|
anchor="origin",cp,spin=0, orient=UP, extent=false)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,466];
|
BOSL_VERSION = [2,0,467];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue