Added assert to catch triangulation of self-crossing face perimeters.

This commit is contained in:
Revar Desmera 2020-04-06 18:46:12 -07:00
parent ea20f59c44
commit 503c0495d3
2 changed files with 9 additions and 5 deletions

View file

@ -47,9 +47,10 @@ function find_convex_vertex(points, face, facenorm, i=0) =
p1=points[face[(i+1)%count]],
p2=points[face[(i+2)%count]]
)
(len(face)>i)?
(cross(p1-p0, p2-p1)*facenorm>0)? (i+1)%count : find_convex_vertex(points, face, facenorm, i+1)
: //This should never happen since there is at least 1 convex vertex.
(len(face)>i)? (
(cross(p1-p0, p2-p1)*facenorm>0)? (i+1)%count :
find_convex_vertex(points, face, facenorm, i+1)
) : //This should never happen since there is at least 1 convex vertex.
undef
;
@ -138,7 +139,10 @@ function triangulate_face(points, face) =
(count == 3)? [face] :
let(
facenorm=face_normal(points, face),
cv=find_convex_vertex(points, face, facenorm),
cv=find_convex_vertex(points, face, facenorm)
)
assert(!is_undef(cv), "Cannot triangulate self-crossing face perimeters.")
let(
pv=(count+cv-1)%count,
nv=(cv+1)%count,
p0=points[face[pv]],

View file

@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,254];
BOSL_VERSION = [2,0,255];
// Section: BOSL Library Version Functions