mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Added cleanup_path() and cleanup_region()
This commit is contained in:
parent
4a72997fb8
commit
52ab40b4f5
1 changed files with 19 additions and 3 deletions
|
@ -449,7 +449,7 @@ function is_path(x) = is_list(x) && is_vector(x.x) && len(x)>1;
|
||||||
function is_closed_path(path, eps=EPSILON) = approx(path[0], path[len(path)-1], eps=eps);
|
function is_closed_path(path, eps=EPSILON) = approx(path[0], path[len(path)-1], eps=eps);
|
||||||
|
|
||||||
|
|
||||||
// Function: close_path(path)
|
// Function: close_path()
|
||||||
// Usage:
|
// Usage:
|
||||||
// close_path(path);
|
// close_path(path);
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -457,7 +457,15 @@ function is_closed_path(path, eps=EPSILON) = approx(path[0], path[len(path)-1],
|
||||||
function close_path(path, eps=EPSILON) = is_closed_path(path,eps=eps)? path : concat(path,[path[0]]);
|
function close_path(path, eps=EPSILON) = is_closed_path(path,eps=eps)? path : concat(path,[path[0]]);
|
||||||
|
|
||||||
|
|
||||||
// Function path_subselect()
|
// Function: cleanup_path()
|
||||||
|
// Usage:
|
||||||
|
// cleanup_path(path);
|
||||||
|
// Description:
|
||||||
|
// If a path's last point coincides with its first point, deletes the last point in the path.
|
||||||
|
function cleanup_path(path, eps=EPSILON) = is_closed_path(path,eps=eps)? select(path,0,-2) : path;
|
||||||
|
|
||||||
|
|
||||||
|
// Function: path_subselect()
|
||||||
// Usage:
|
// Usage:
|
||||||
// path_subselect(path,s1,u1,s2,u2):
|
// path_subselect(path,s1,u1,s2,u2):
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -695,7 +703,7 @@ function polygon_clockwise(path) =
|
||||||
function is_region(x) = is_list(x) && is_path(x.x);
|
function is_region(x) = is_list(x) && is_path(x.x);
|
||||||
|
|
||||||
|
|
||||||
// Function: close_region(path)
|
// Function: close_region()
|
||||||
// Usage:
|
// Usage:
|
||||||
// close_region(region);
|
// close_region(region);
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -703,6 +711,14 @@ function is_region(x) = is_list(x) && is_path(x.x);
|
||||||
function close_region(region, eps=EPSILON) = [for (path=region) close_path(path, eps=eps)];
|
function close_region(region, eps=EPSILON) = [for (path=region) close_path(path, eps=eps)];
|
||||||
|
|
||||||
|
|
||||||
|
// Function: cleanup_region()
|
||||||
|
// Usage:
|
||||||
|
// cleanup_region(region);
|
||||||
|
// Description:
|
||||||
|
// For all paths in the given region, if the last point coincides with the first point, removes the last point.
|
||||||
|
function cleanup_region(region, eps=EPSILON) = [for (path=region) cleanup_path(path, eps=eps)];
|
||||||
|
|
||||||
|
|
||||||
// Function: region_path_crossings()
|
// Function: region_path_crossings()
|
||||||
// Usage:
|
// Usage:
|
||||||
// region_path_crossings(path, region);
|
// region_path_crossings(path, region);
|
||||||
|
|
Loading…
Reference in a new issue