mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-04 03:09:45 +00:00
Added assert to catch triangulation of self-crossing face perimeters.
This commit is contained in:
parent
ea20f59c44
commit
503c0495d3
2 changed files with 9 additions and 5 deletions
|
@ -47,9 +47,10 @@ function find_convex_vertex(points, face, facenorm, i=0) =
|
||||||
p1=points[face[(i+1)%count]],
|
p1=points[face[(i+1)%count]],
|
||||||
p2=points[face[(i+2)%count]]
|
p2=points[face[(i+2)%count]]
|
||||||
)
|
)
|
||||||
(len(face)>i)?
|
(len(face)>i)? (
|
||||||
(cross(p1-p0, p2-p1)*facenorm>0)? (i+1)%count : find_convex_vertex(points, face, facenorm, i+1)
|
(cross(p1-p0, p2-p1)*facenorm>0)? (i+1)%count :
|
||||||
: //This should never happen since there is at least 1 convex vertex.
|
find_convex_vertex(points, face, facenorm, i+1)
|
||||||
|
) : //This should never happen since there is at least 1 convex vertex.
|
||||||
undef
|
undef
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -138,7 +139,10 @@ function triangulate_face(points, face) =
|
||||||
(count == 3)? [face] :
|
(count == 3)? [face] :
|
||||||
let(
|
let(
|
||||||
facenorm=face_normal(points, face),
|
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,
|
pv=(count+cv-1)%count,
|
||||||
nv=(cv+1)%count,
|
nv=(cv+1)%count,
|
||||||
p0=points[face[pv]],
|
p0=points[face[pv]],
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,254];
|
BOSL_VERSION = [2,0,255];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue