fix(junction): reject collapsed core boundary edges
This commit is contained in:
1 parent
c4902cd4c8
commit
e5d805a369
2 files changed
+14
-1
No files matched your search
@@ -174,6 +174,12 @@ function buildCoreClosure(topology, graph, center) {
|
||||
Math.atan2(second.point[1] - center[1], second.point[0] - center[0]),
|
||||
);
|
||||
const ring = [...points.map((item) => item.point), points[0]?.point].filter(Boolean);
|
||||
const hasZeroLengthEdge = ring.slice(1).some((point, index) => {
|
||||
const previous = ring[index];
|
||||
const dx = point[0] - previous[0];
|
||||
const dy = point[1] - previous[1];
|
||||
return dx * dx + dy * dy <= 1e-24;
|
||||
});
|
||||
const pairedEdges = new Map();
|
||||
points.forEach((item, index) => {
|
||||
if (!pairedEdges.has(item.edgeRef)) pairedEdges.set(item.edgeRef, []);
|
||||
@@ -183,7 +189,7 @@ function buildCoreClosure(topology, graph, center) {
|
||||
if (indexes.length !== 2) return false;
|
||||
return Math.abs(indexes[0] - indexes[1]) === 1 || (indexes[0] === 0 && indexes[1] === points.length - 1);
|
||||
});
|
||||
if (ring.length < 7 || !paired || Math.abs(signedArea(ring)) < 1e-14 || ringSelfIntersects(ring))
|
||||
if (ring.length < 7 || hasZeroLengthEdge || !paired || Math.abs(signedArea(ring)) < 1e-14 || ringSelfIntersects(ring))
|
||||
return { status: 'unsupported', reason: 'core-closure-invalid' };
|
||||
if (graph.exclusionRegions.some((region) => ringsOverlap(region.ring, ring)))
|
||||
return { status: 'unsupported', reason: 'known-exclusion-region' };
|
||||
|
||||
Reference in new issue
Block a user