@flatten-js/core
Advanced tools
Comparing version 1.5.1 to 1.5.2
{ | ||
"name": "@flatten-js/core", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Javascript library for 2d geometry", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.cjs", |
@@ -37,3 +37,3 @@ /** | ||
if (resp_edges.length == 0) { | ||
if (resp_edges.length === 0) { | ||
return Flatten.OUTSIDE; | ||
@@ -49,2 +49,4 @@ } | ||
let faces = [...polygon.faces]; | ||
// 3. Calculate intersections | ||
@@ -62,3 +64,4 @@ let intersections = []; | ||
pt: ip, | ||
edge: edge | ||
edge: edge, | ||
face_index: faces.indexOf(edge.face) | ||
}); | ||
@@ -76,2 +79,14 @@ } | ||
} | ||
if (i1.face_index < i2.face_index) { | ||
return -1 | ||
} | ||
if (i1.face_index > i2.face_index) { | ||
return 1 | ||
} | ||
if (i1.edge.arc_length < i2.edge.arc_length) { | ||
return -1 | ||
} | ||
if (i1.edge.arc_length > i2.edge.arc_length) { | ||
return 1 | ||
} | ||
return 0; | ||
@@ -85,8 +100,11 @@ }); | ||
let intersection = intersections[i]; | ||
if (intersection.pt.equalTo(intersection.edge.shape.start)) { | ||
/* skip same point between same edges if already counted */ | ||
if (i > 0 && intersection.pt.equalTo(intersections[i - 1].pt) && | ||
intersection.face_index === intersections[i - 1].face_index && | ||
intersection.edge.prev === intersections[i - 1].edge) { | ||
continue; | ||
} | ||
let prev_edge = intersection.edge.prev; | ||
@@ -111,5 +129,7 @@ while (Utils.EQ_0(prev_edge.length)) { | ||
if (i > 0 && intersection.pt.equalTo(intersections[i - 1].pt) && | ||
intersection.face_index === intersections[i-1].face_index && | ||
intersection.edge.next === intersections[i - 1].edge) { | ||
continue; | ||
} | ||
let next_edge = intersection.edge.next; | ||
@@ -131,3 +151,3 @@ while (Utils.EQ_0(next_edge.length)) { | ||
} | ||
} else { /* intersection point is not a coincident with a vertex */ | ||
} else { /* intersection point is not a vertex */ | ||
if (intersection.edge.shape instanceof Flatten.Segment) { | ||
@@ -147,5 +167,4 @@ counter++; | ||
// 6. Odd or even? | ||
contains = counter % 2 == 1 ? Constants.INSIDE : Constants.OUTSIDE; | ||
contains = counter % 2 === 1 ? Constants.INSIDE : Constants.OUTSIDE; | ||
return contains; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1201100
30804