diff --git a/lib/fixtures/twoNodeExpansionFixture.ts b/lib/fixtures/twoNodeExpansionFixture.ts new file mode 100644 index 0000000..e641d8a --- /dev/null +++ b/lib/fixtures/twoNodeExpansionFixture.ts @@ -0,0 +1,66 @@ +import RBush from "rbush" +import type { + RectDiffExpansionSolverInput, + RectDiffExpansionSolverSnapshot, +} from "../solvers/RectDiffExpansionSolver/RectDiffExpansionSolver" +import type { SimpleRouteJson } from "../types/srj-types" +import type { XYRect } from "../rectdiff-types" +import type { RTreeRect } from "lib/types/capacity-mesh-types" + +/** + * Builds a minimal RectDiffExpansionSolver snapshot with exactly two nodes + * separated by empty space. This keeps the data close to the solver’s real + * input shape so we can reuse it for demos/tests that reproduce the gap issue. + */ +export const createTwoNodeExpansionInput = (): RectDiffExpansionSolverInput => { + const srj: SimpleRouteJson = { + bounds: { minX: 0, maxX: 12, minY: 0, maxY: 4 }, + layerCount: 1, + minTraceWidth: 0.2, + obstacles: [], + connections: [], + } + const layerCount = srj.layerCount ?? 1 + const bounds: XYRect = { + x: srj.bounds.minX, + y: srj.bounds.minY, + width: srj.bounds.maxX - srj.bounds.minX, + height: srj.bounds.maxY - srj.bounds.minY, + } + + const obstacleIndexByLayer = Array.from( + { length: layerCount }, + () => new RBush(), + ) + // Start with all-empty obstacle indexes for a "clean" scenario + + const initialSnapshot: RectDiffExpansionSolverSnapshot = { + srj, + layerNames: ["top"], + layerCount, + bounds, + options: { gridSizes: [1] }, + boardVoidRects: [], + gridIndex: 0, + candidates: [], + placed: [ + { + rect: { x: 0.5, y: 0.5, width: 2, height: 3 }, + zLayers: [0], + }, + { + rect: { x: 9.5, y: 0.5, width: 2, height: 3 }, + zLayers: [0], + }, + ], + expansionIndex: 0, + edgeAnalysisDone: true, + totalSeedsThisGrid: 0, + consumedSeedsThisGrid: 0, + } + + return { + initialSnapshot, + obstacleIndexByLayer, + } +} diff --git a/pages/features/should-expand-node.page.tsx b/pages/features/should-expand-node.page.tsx new file mode 100644 index 0000000..7798ce2 --- /dev/null +++ b/pages/features/should-expand-node.page.tsx @@ -0,0 +1,13 @@ +import { useMemo } from "react" +import { RectDiffExpansionSolver } from "lib/solvers/RectDiffExpansionSolver/RectDiffExpansionSolver" +import { createTwoNodeExpansionInput } from "lib/fixtures/twoNodeExpansionFixture" +import { SolverDebugger3d } from "../../components/SolverDebugger3d" + +export default () => { + const solver = useMemo( + () => new RectDiffExpansionSolver(createTwoNodeExpansionInput()), + [], + ) + + return +} diff --git a/pages/gap-fill-h-shape-should-expand-node.page.tsx b/pages/gap-fill-h-shape-should-expand-node.page.tsx deleted file mode 100644 index ce84755..0000000 --- a/pages/gap-fill-h-shape-should-expand-node.page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import fixture from "../test-assets/gap-fill-h-shape-should-expand-node.json" -import { GapFillSolverPipeline } from "../lib/solvers/GapFillSolver/GapFillSolverPipeline" -import type { CapacityMeshNode } from "../lib/types/capacity-mesh-types" -import { useMemo } from "react" -import { SolverDebugger3d } from "../components/SolverDebugger3d" - -export default () => { - const solver = useMemo( - () => - new GapFillSolverPipeline({ - meshNodes: fixture.meshNodes as CapacityMeshNode[], - }), - [], - ) - - return ( - - ) -} diff --git a/tests/__snapshots__/should-expand-node.snap.svg b/tests/__snapshots__/should-expand-node.snap.svg index 8282007..5268ba7 100644 --- a/tests/__snapshots__/should-expand-node.snap.svg +++ b/tests/__snapshots__/should-expand-node.snap.svg @@ -1,4 +1,4 @@ -