mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-01-16 13:50:23 +01:00
add deduplicate to rect(), add deduplicate to is_path_simple
add epsilon to degenerate bezier patch detection
This commit is contained in:
parent
75f7a75ac2
commit
5435bb1fc2
@ -1252,8 +1252,8 @@ function bezier_vnf_degenerate_patch(patch, splinesteps=16, reverse=false, retur
|
|||||||
assert(is_bezier_patch(patch), "Input is not a Bezier patch")
|
assert(is_bezier_patch(patch), "Input is not a Bezier patch")
|
||||||
assert(is_int(splinesteps) && splinesteps>0, "splinesteps must be a positive integer")
|
assert(is_int(splinesteps) && splinesteps>0, "splinesteps must be a positive integer")
|
||||||
let(
|
let(
|
||||||
row_degen = [for(row=patch) all_equal(row)],
|
row_degen = [for(row=patch) all_equal(row,eps=EPSILON)],
|
||||||
col_degen = [for(col=transpose(patch)) all_equal(col)],
|
col_degen = [for(col=transpose(patch)) all_equal(col,eps=EPSILON)],
|
||||||
top_degen = row_degen[0],
|
top_degen = row_degen[0],
|
||||||
bot_degen = last(row_degen),
|
bot_degen = last(row_degen),
|
||||||
left_degen = col_degen[0],
|
left_degen = col_degen[0],
|
||||||
|
@ -581,6 +581,9 @@ function is_path_simple(path, closed, eps=EPSILON) =
|
|||||||
let(closed=default(closed,false))
|
let(closed=default(closed,false))
|
||||||
assert(is_path(path, 2),"Must give a 2D path")
|
assert(is_path(path, 2),"Must give a 2D path")
|
||||||
assert(is_bool(closed))
|
assert(is_bool(closed))
|
||||||
|
let(
|
||||||
|
path = deduplicate(path,closed=closed,eps=eps)
|
||||||
|
)
|
||||||
// check for path reversals
|
// check for path reversals
|
||||||
[for(i=[0:1:len(path)-(closed?2:3)])
|
[for(i=[0:1:len(path)-(closed?2:3)])
|
||||||
let(v1=path[i+1]-path[i],
|
let(v1=path[i+1]-path[i],
|
||||||
|
@ -214,7 +214,7 @@ function rect(size=1, rounding=0, chamfer=0, atype="box", anchor=CENTER, spin=0,
|
|||||||
assert(is_undef(cornerpt) || len(cornerpt)==1,"Cannot find corner point to anchor")
|
assert(is_undef(cornerpt) || len(cornerpt)==1,"Cannot find corner point to anchor")
|
||||||
[move(cp, p=qrpts), is_undef(cornerpt)? undef : move(cp,p=cornerpt[0])]
|
[move(cp, p=qrpts), is_undef(cornerpt)? undef : move(cp,p=cornerpt[0])]
|
||||||
],
|
],
|
||||||
path = flatten(column(corners,0)),
|
path = deduplicate(flatten(column(corners,0)),closed=true),
|
||||||
override = [for(i=[0:3])
|
override = [for(i=[0:3])
|
||||||
let(quad=quadorder[i])
|
let(quad=quadorder[i])
|
||||||
if (is_def(corners[i][1])) [quadpos[quad], [corners[i][1], min(chamfer[quad],rounding[quad])<0 ? [quadpos[quad].x,0] : undef]]]
|
if (is_def(corners[i][1])) [quadpos[quad], [corners[i][1], min(chamfer[quad],rounding[quad])<0 ? [quadpos[quad].x,0] : undef]]]
|
||||||
|
@ -298,5 +298,11 @@ test_path_torsion();
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//echo(fmt_float(sampled));
|
module test_is_path_simple(){
|
||||||
|
assert(is_path_simple([[0,0],[1,1],[1,1],[2,1]]));
|
||||||
|
assert(is_path_simple([[0,0],[10,0],[0,20],[10,20]],closed=false));
|
||||||
|
assert(!is_path_simple([[0,0],[10,0],[0,20],[10,20]],closed=true));
|
||||||
|
assert(is_path_simple(circle($fn=20, r=10)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user