mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
filter zero area polygons in vnf_from_polygons
This commit is contained in:
parent
ad504a5962
commit
dd02bb42c5
1 changed files with 7 additions and 4 deletions
11
vnf.scad
11
vnf.scad
|
@ -423,20 +423,23 @@ function vnf_join(vnfs) =
|
||||||
// Topics: VNF Generators, Lists
|
// Topics: VNF Generators, Lists
|
||||||
// See Also: vnf_tri_array(), vnf_join(), vnf_vertex_array(), vnf_from_region()
|
// See Also: vnf_tri_array(), vnf_join(), vnf_vertex_array(), vnf_from_region()
|
||||||
// Usage:
|
// Usage:
|
||||||
// vnf = vnf_from_polygons(polygons);
|
// vnf = vnf_from_polygons(polygons, [eps]);
|
||||||
// Description:
|
// Description:
|
||||||
// Given a list of 3D polygons, produces a VNF containing those polygons.
|
// Given a list of 3D polygons, produces a VNF containing those polygons.
|
||||||
// It is up to the caller to make sure that the points are in the correct order to make the face
|
// It is up to the caller to make sure that the points are in the correct order to make the face
|
||||||
// normals point outwards. No checking for duplicate vertices is done. If you want to
|
// normals point outwards. No checking for duplicate vertices is done. If you want to
|
||||||
// remove duplicate vertices use {{vnf_merge_points()}}.
|
// remove duplicate vertices use {{vnf_merge_points()}}. Polygons with zero area are discarded from the face list by default.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// polygons = The list of 3D polygons to turn into a VNF
|
// polygons = The list of 3D polygons to turn into a VNF
|
||||||
function vnf_from_polygons(polygons) =
|
// eps = Polygons with area small than this are discarded. Default: EPSILON
|
||||||
|
function vnf_from_polygons(polygons,eps=EPSILON) =
|
||||||
assert(is_list(polygons) && is_path(polygons[0]),"Input should be a list of polygons")
|
assert(is_list(polygons) && is_path(polygons[0]),"Input should be a list of polygons")
|
||||||
let(
|
let(
|
||||||
offs = cumsum([0, for(p=polygons) len(p)]),
|
offs = cumsum([0, for(p=polygons) len(p)]),
|
||||||
faces = [for(i=idx(polygons))
|
faces = [for(i=idx(polygons))
|
||||||
[for (j=idx(polygons[i])) offs[i]+j]
|
let(area=polygon_area(polygons[i]))
|
||||||
|
if (is_def(area) && area > eps)
|
||||||
|
[for (j=idx(polygons[i])) offs[i]+j]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
[flatten(polygons), faces];
|
[flatten(polygons), faces];
|
||||||
|
|
Loading…
Reference in a new issue