Make most path functions accept singleton regions

Replace check_and_fix_path with force_path
This commit is contained in:
Adrian Mariano
2021-10-29 19:29:51 -04:00
parent 9cf991bb29
commit 052200433b
6 changed files with 150 additions and 74 deletions

View File

@@ -829,8 +829,8 @@ function path_sweep(shape, path, method="incremental", normal, closed=false, twi
assert(!closed || twist % (360/symmetry)==0, str("For a closed sweep, twist must be a multiple of 360/symmetry = ",360/symmetry))
assert(closed || symmetry==1, "symmetry must be 1 when closed is false")
assert(is_integer(symmetry) && symmetry>0, "symmetry must be a positive integer")
// let(shape = check_and_fix_path(shape,valid_dim=2,closed=true,name="shape"))
assert(is_path(path), "input path is not a path")
let(path = force_path(path))
assert(is_path(path,[2,3]), "input path is not a 2D or 3D path")
assert(!closed || !approx(path[0],last(path)), "Closed path includes start point at the end")
let(
path = path3d(path),
@@ -973,8 +973,11 @@ function path_sweep2d(shape, path, closed=false, caps, quality=1, style="min_edg
: closed ? false : true,
capsOK = is_bool(caps) || is_bool_list(caps,2),
fullcaps = is_bool(caps) ? [caps,caps] : caps,
shape = check_and_fix_path(shape,valid_dim=2,closed=true,name="shape")
shape = force_path(shape,"shape"),
path = force_path(path)
)
assert(is_path(shape,2), "shape must be a 2D path")
assert(is_path(path,2), "path must be a 2D path")
assert(capsOK, "caps must be boolean or a list of two booleans")
assert(!closed || !caps, "Cannot make closed shape with caps")
let(
@@ -1222,6 +1225,7 @@ function _smooth(data,len,closed=false,angle=false) =
)
result;
// Function: rot_resample()
// Usage:
// rlist = rot_resample(rotlist, N, [method], [twist], [scale], [smoothlen], [long], [turns], [closed])