diff --git a/src/compile/junction-boundary-graph.js b/src/compile/junction-boundary-graph.js index 71a7714..c2bd27e 100644 --- a/src/compile/junction-boundary-graph.js +++ b/src/compile/junction-boundary-graph.js @@ -204,11 +204,25 @@ function buildCoreClosure(topology, graph, center) { return { status: 'unsupported', reason: 'core-closure-invalid' }; if (graph.exclusionRegions.some((region) => ringsOverlap(region.ring, ring))) return { status: 'unsupported', reason: 'known-exclusion-region' }; + const seamErrorMeters = graph.sections.reduce((maximum, section) => { + const leftIndex = ring.findIndex( + (point) => point[0] === section.inner.left[0] && point[1] === section.inner.left[1], + ); + const rightIndex = ring.findIndex( + (point) => point[0] === section.inner.right[0] && point[1] === section.inner.right[1], + ); + const contiguous = + leftIndex >= 0 && + rightIndex >= 0 && + (Math.abs(leftIndex - rightIndex) === 1 || Math.abs(leftIndex - rightIndex) === ring.length - 2); + return Math.max(maximum, contiguous ? 0 : Infinity); + }, 0); return { status: 'supported', ring, sharedEdgeRefs: [...pairedEdges.keys()].sort(), closureCount: graph.sections.length, + maxSharedSeamErrorMeters: seamErrorMeters, }; } diff --git a/test/junction-build-plan-counterexamples.js b/test/junction-build-plan-counterexamples.js index 73a1ae7..9f55214 100644 --- a/test/junction-build-plan-counterexamples.js +++ b/test/junction-build-plan-counterexamples.js @@ -573,3 +573,8 @@ const zeroWidthGraph = buildJunctionBoundaryGraph( zeroWidth.helpers, ); assert.equal(zeroWidthGraph.sections[0].ringStatus, 'invalid'); + +assert.ok( + buildCoreClosure(tee.topology, teeBoundaryGraph, point(0, 0)).maxSharedSeamErrorMeters <= 0.01, + 'shared core seams must remain within the 1 cm tolerance', +);