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' };
|
||||
|
||||
@@ -314,3 +314,10 @@ assert.deepEqual(
|
||||
reorderedTopology.arms.map((arm) => arm.key).sort(),
|
||||
sixArm.topology.arms.map((arm) => arm.key).sort(),
|
||||
);
|
||||
|
||||
// A collapsed inner seam is a geometric failure even if the remaining ring
|
||||
// still encloses a positive area. The closure must reject zero-length edges.
|
||||
const collapsedGraph = JSON.parse(JSON.stringify(teeBoundaryGraph));
|
||||
const collapsedSection = collapsedGraph.sections[0];
|
||||
collapsedSection.inner.right = collapsedSection.inner.left;
|
||||
assert.equal(buildCoreClosure(tee.topology, collapsedGraph, point(0, 0)).reason, 'core-closure-invalid');
|
||||
Reference in new issue
Block a user