From 6bd78639f4ec16cecd6450da3adc47730c5fd005 Mon Sep 17 00:00:00 2001 From: Ahmed Alshaybani Date: Wed, 14 Oct 2026 03:31:36 +0200 Subject: [PATCH] Avoid gap-fill nodes narrower than traces --- lib/RectDiffPipeline.ts | 2 + .../ExpandEdgesToEmptySpaceSolver.ts | 11 +- .../GapFillSolver/GapFillSolverPipeline.ts | 2 + tests/gap-fill-board-bounds.test.ts | 1 + .../rectDiffGridSolverPipeline.snap.svg | 2 +- ...no-uno-inner2-ground-bottom-power.snap.svg | 2 +- ...no-uno-inner2-ground-inner1-power.snap.svg | 2 +- .../__snapshots__/bugreport01-be84eb.snap.svg | 2 +- .../__snapshots__/bugreport03-fe4a17.snap.svg | 2 +- .../__snapshots__/bugreport09-618e09.snap.svg | 2 +- .../__snapshots__/bugreport10-71239a.snap.svg | 2 +- .../__snapshots__/bugreport11-b2de3c.snap.svg | 2 +- .../__snapshots__/bugreport13-b9a758.snap.svg | 2 +- .../__snapshots__/bugreport16-d95f38.snap.svg | 2 +- .../__snapshots__/bugreport19.snap.svg | 2 +- .../__snapshots__/bugreport24-05597c.snap.svg | 2 +- .../__snapshots__/bugreport26-66b0b2.snap.svg | 2 +- .../__snapshots__/bugreport27-dd3734.snap.svg | 2 +- .../__snapshots__/bugreport28-18a9ef.snap.svg | 2 +- .../__snapshots__/bugreport29-7deae8.snap.svg | 2 +- .../__snapshots__/bugreport30-2174c8.snap.svg | 2 +- .../__snapshots__/bugreport33-213d45.snap.svg | 2 +- .../__snapshots__/bugreport34-e9dea2.snap.svg | 2 +- .../__snapshots__/bugreport35-191db9.snap.svg | 2 +- .../__snapshots__/bugreport36-bf8303.snap.svg | 2 +- .../bugreport37-srj18-sample002.snap.svg | 24480 ++++++++-------- .../__snapshots__/bugreport84-726193.snap.svg | 8 +- .../merge-single-layer-node.snap.svg | 2 +- .../pmp22650-unroutable-gap-fill.snap.svg | 2 +- .../pmp22650-unroutable-gap-fill.test.ts | 7 +- .../__snapshots__/transitivity.snap.svg | 2 +- 31 files changed, 11957 insertions(+), 12602 deletions(-) diff --git a/lib/RectDiffPipeline.ts b/lib/RectDiffPipeline.ts index 055986a..994952d 100644 --- a/lib/RectDiffPipeline.ts +++ b/lib/RectDiffPipeline.ts @@ -77,6 +77,8 @@ export class RectDiffPipeline extends BasePipelineSolver rectDiffPipeline.inputProblem.simpleRouteJson.layerCount || 0, }, maxGapFillPasses: rectDiffPipeline.inputProblem.maxGapFillPasses, + minTraceWidth: + rectDiffPipeline.inputProblem.simpleRouteJson.minTraceWidth, }, ], ), diff --git a/lib/solvers/GapFillSolver/ExpandEdgesToEmptySpaceSolver.ts b/lib/solvers/GapFillSolver/ExpandEdgesToEmptySpaceSolver.ts index b4ca2d3..508b99c 100644 --- a/lib/solvers/GapFillSolver/ExpandEdgesToEmptySpaceSolver.ts +++ b/lib/solvers/GapFillSolver/ExpandEdgesToEmptySpaceSolver.ts @@ -79,6 +79,7 @@ const getDistanceToBoardEdge = ( export type ExpandEdgesToEmptySpaceSolverInput = { /** Optional for standalone callers; the full board pipeline always supplies it. */ bounds?: Bounds + minTraceWidth?: number inputMeshNodes: CapacityMeshNode[] segmentsWithAdjacentEmptySpace: Array boardVoid?: { @@ -261,6 +262,11 @@ export class ExpandEdgesToEmptySpaceSolver extends BaseSolver { const nodeWidth = nodeBounds.maxX - nodeBounds.minX const nodeHeight = nodeBounds.maxY - nodeBounds.minY + const minRoutableDimension = Math.max(EPS, this.input.minTraceWidth ?? 0) + if (nodeWidth < minRoutableDimension || nodeHeight < minRoutableDimension) { + return + } + const expandedSegment = { segment, newNode: { @@ -274,11 +280,6 @@ export class ExpandEdgesToEmptySpaceSolver extends BaseSolver { } this.lastExpandedSegment = expandedSegment - if (nodeWidth < EPS || nodeHeight < EPS) { - // Node is too small, skipping - return - } - this.expandedSegments.push(expandedSegment) this.rectSpatialIndex.insert({ ...expandedSegment.newNode, diff --git a/lib/solvers/GapFillSolver/GapFillSolverPipeline.ts b/lib/solvers/GapFillSolver/GapFillSolverPipeline.ts index 6a59188..683ba99 100644 --- a/lib/solvers/GapFillSolver/GapFillSolverPipeline.ts +++ b/lib/solvers/GapFillSolver/GapFillSolverPipeline.ts @@ -27,6 +27,7 @@ type GapFillSolverInput = { * expanded nodes; values below 1 are clamped to 1. */ maxGapFillPasses: number + minTraceWidth: number } type GapFillOutput = { @@ -75,6 +76,7 @@ export class GapFillSolverPipeline extends BasePipelineSolverLayer z=0Layer z=1Layer z=2Layer z=3