mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
bug fix
This commit is contained in:
parent
ec02676267
commit
42611d207a
2 changed files with 17 additions and 4 deletions
|
@ -715,9 +715,7 @@ function _point_dist(path,pathseg_unit,pathseg_len,pt) =
|
|||
|
||||
function _offset_region(region, r, delta, chamfer, check_valid, quality,closed,return_faces,firstface_index,flip_faces) =
|
||||
let(
|
||||
//dg= echo(region=region),
|
||||
reglist = [for(R=region_parts(region)) is_path(R) ? [R] : R],
|
||||
//fdsa= echo(reglist),
|
||||
ofsregs = [for(R=reglist)
|
||||
[for(i=idx(R)) offset(R[i], r=u_mul(i>0?-1:1,r), delta=u_mul(i>0?-1:1,delta), chamfer=chamfer, check_valid=check_valid,
|
||||
quality=quality,closed=true)]]
|
||||
|
@ -993,8 +991,9 @@ function _tag_subpaths(region1, region2, eps=EPSILON, SUtags=true) =
|
|||
points = flatten(region1),
|
||||
tree = len(points)>0 ? vector_search_tree(points): undef
|
||||
)
|
||||
[for(path=region1)
|
||||
[for(p=region1)
|
||||
let(
|
||||
path = deduplicate(p),
|
||||
self_int = is_undef(tree)?[]:[for(i=idx(path)) if (len(vector_search(path[i], eps, tree))>1) [i,0]],
|
||||
subpaths = split_path_at_region_crossings(path, region2, eps=eps, extra=self_int)
|
||||
)
|
||||
|
@ -1108,7 +1107,6 @@ function difference(regions=[],b=undef,c=undef,eps=EPSILON) =
|
|||
// for (shape = [shape1,shape2]) color("red") stroke(shape, width=0.5, closed=true);
|
||||
// color("green") region(intersection(shape1,shape2));
|
||||
function intersection(regions=[],b=undef,c=undef,eps=EPSILON) =
|
||||
// echo(regions=regions)
|
||||
b!=undef? intersection(concat([regions],[b],c==undef?[]:[c]),eps=eps)
|
||||
: len(regions)==0 ? []
|
||||
: len(regions)==1? regions[0]
|
||||
|
|
|
@ -35,6 +35,21 @@ module test_difference() {
|
|||
R4 = [square(9,center=true), square(3,center=true)];
|
||||
assert(are_regions_equal(difference(R5,R4),
|
||||
[square(10,center=true), square(9, center=true), square(3,center=true)]));
|
||||
|
||||
pathA = [
|
||||
[-9,12], [-6,2], [-3,12], [0,2], [3,10], [5,10], [19,-4], [-8,-4], [-12,0]
|
||||
];
|
||||
|
||||
pathB = [
|
||||
[-12,8], [7,8], [9,6], [7,5], [-3,5], [-5,-6], [-2,-6], [0,-4],
|
||||
[6,-4], [2,-8], [-7,-8], [-15,0]
|
||||
];
|
||||
|
||||
|
||||
right=[[[-10, 8], [-9, 12], [-7.8, 8]], [[0, -4], [-4.63636363636, -4], [-3, 5], [-0.9, 5], [0, 2], [1.125, 5], [7, 5], [9, 6], [19, -4], [6, -4]], [[-4.2, 8], [-1.8, 8], [-3, 12]], [[2.25, 8], [3, 10], [5, 10], [7, 8]]];
|
||||
assert(are_regions_equal(difference(pathA,pathB),right));
|
||||
|
||||
|
||||
}
|
||||
test_difference();
|
||||
|
||||
|
|
Loading…
Reference in a new issue