mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
cleaning
This commit is contained in:
parent
0b38bc463f
commit
cb5cd93f25
1 changed files with 4 additions and 10 deletions
14
hull.scad
14
hull.scad
|
@ -202,17 +202,15 @@ function hull3d_faces(points) =
|
||||||
|
|
||||||
|
|
||||||
// Adds the remaining points one by one to the convex hull
|
// Adds the remaining points one by one to the convex hull
|
||||||
function _hull3d_iterative(points, triangles, planes, remaining, _i=0) =
|
function _hull3d_iterative(points, triangles, planes, remaining, _i=0) = //let( EPSILON=1e-12 )
|
||||||
_i >= len(remaining) ? triangles :
|
_i >= len(remaining) ? triangles :
|
||||||
let (
|
let (
|
||||||
// pick a point
|
// pick a point
|
||||||
i = remaining[_i],
|
i = remaining[_i],
|
||||||
// evaluate the triangle plane equations at point i
|
// evaluate the triangle plane equations at point i
|
||||||
// xx=[for(i=[0:len(planes)-1],p=[planes[i]]) if(len(p)!=4) echo(i=i,len(p))0 ],//echo([each points[i], -1]),
|
|
||||||
// planeq_val = [for(p=planes) p*[each points[i], -1]],
|
|
||||||
planeq_val = planes*[each points[i], -1],
|
planeq_val = planes*[each points[i], -1],
|
||||||
// find the triangles that are in conflict with the point (point not inside)
|
// find the triangles that are in conflict with the point (point not inside)
|
||||||
conflicts = [ for (i = [0:1:len(planes)-1]) if (planeq_val[i]>EPSILON) i ],
|
conflicts = [for (i = [0:1:len(planeq_val)-1]) if (planeq_val[i]>EPSILON) i ],
|
||||||
// collect the halfedges of all triangles that are in conflict
|
// collect the halfedges of all triangles that are in conflict
|
||||||
halfedges = [
|
halfedges = [
|
||||||
for(c = conflicts, i = [0:2])
|
for(c = conflicts, i = [0:2])
|
||||||
|
@ -222,18 +220,15 @@ function _hull3d_iterative(points, triangles, planes, remaining, _i=0) =
|
||||||
horizon = _remove_internal_edges(halfedges),
|
horizon = _remove_internal_edges(halfedges),
|
||||||
// generate new triangles connecting point i to each horizon halfedge vertices
|
// generate new triangles connecting point i to each horizon halfedge vertices
|
||||||
tri2add = [ for (h = horizon) concat(h,i) ],
|
tri2add = [ for (h = horizon) concat(h,i) ],
|
||||||
// w=[for(t=tri2add) if(collinear(points[t[0]],points[t[1]],points[t[2]])) echo(t)],
|
|
||||||
// add tria2add and remove conflict triangles
|
// add tria2add and remove conflict triangles
|
||||||
new_triangles =
|
new_triangles =
|
||||||
concat( tri2add,
|
concat( tri2add,
|
||||||
[ for (i = [0:1:len(planes)-1]) if (planeq_val[i]<=EPSILON) triangles[i] ]
|
[ for (i = [0:1:len(planes)-1]) if (planeq_val[i]<=EPSILON) triangles[i] ]
|
||||||
),
|
),
|
||||||
// y=[for(t=tri2add) if([]==plane3pt_indexed(points,t[0],t[1],t[2])) echo(tri2add=t,pts=[for(ti=t) points[ti]])],
|
|
||||||
// add the plane equations of new added triangles and remove the plane equations of the conflict ones
|
// add the plane equations of new added triangles and remove the plane equations of the conflict ones
|
||||||
new_planes =
|
new_planes =
|
||||||
concat( [ for (t = tri2add) plane3pt_indexed(points, t[0], t[1], t[2]) ],
|
[ for (t = tri2add) plane3pt_indexed(points, t[0], t[1], t[2]) ,
|
||||||
[ for (i = [0:1:len(planes)-1]) if (planeq_val[i]<=EPSILON) planes[i] ]
|
for (i = [0:1:len(planes)-1]) if (planeq_val[i]<=EPSILON) planes[i] ]
|
||||||
)
|
|
||||||
) _hull3d_iterative(
|
) _hull3d_iterative(
|
||||||
points,
|
points,
|
||||||
new_triangles,
|
new_triangles,
|
||||||
|
@ -249,7 +244,6 @@ function _remove_internal_edges(halfedges) = [
|
||||||
h
|
h
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function _find_first_noncoplanar(plane, points, i=0) =
|
function _find_first_noncoplanar(plane, points, i=0) =
|
||||||
(i >= len(points) || !points_on_plane([points[i]],plane))? i :
|
(i >= len(points) || !points_on_plane([points[i]],plane))? i :
|
||||||
_find_first_noncoplanar(plane, points, i+1);
|
_find_first_noncoplanar(plane, points, i+1);
|
||||||
|
|
Loading…
Reference in a new issue