@tscircuit/rectdiff 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -19
- package/dist/index.js +175 -97
- package/lib/fixtures/twoNodeExpansionFixture.ts +59 -0
- package/lib/solvers/RectDiffExpansionSolver/RectDiffExpansionSolver.ts +50 -106
- package/lib/solvers/RectDiffGridSolverPipeline/RectDiffGridSolverPipeline.ts +22 -7
- package/lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts +3 -9
- package/lib/utils/expandRectFromSeed.ts +86 -2
- package/lib/utils/isSelfRect.ts +15 -0
- package/lib/utils/searchStrip.ts +50 -0
- package/package.json +1 -1
- package/pages/features/should-expand-node.page.tsx +13 -0
- package/tests/__snapshots__/should-expand-node.snap.svg +2 -2
- package/tests/fixtures/makeSimpleRouteOutlineGraphics.ts +41 -0
- package/tests/incremental-solver.test.ts +1 -1
- package/tests/should-expand-node.test.ts +12 -18
- package/tests/solver/__snapshots__/rectDiffGridSolverPipeline.snap.svg +3 -3
- package/tests/solver/rectDiffGridSolverPipeline.test.ts +5 -1
- package/pages/gap-fill-h-shape-should-expand-node.page.tsx +0 -23
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
import { expect, test } from "bun:test"
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import type { CapacityMeshNode } from "lib/types/capacity-mesh-types"
|
|
2
|
+
import { getSvgFromGraphicsObject, mergeGraphics } from "graphics-debug"
|
|
3
|
+
import { RectDiffExpansionSolver } from "lib/solvers/RectDiffExpansionSolver/RectDiffExpansionSolver"
|
|
4
|
+
import { createTwoNodeExpansionInput } from "lib/fixtures/twoNodeExpansionFixture"
|
|
6
5
|
import { makeCapacityMeshNodeWithLayerInfo } from "./fixtures/makeCapacityMeshNodeWithLayerInfo"
|
|
6
|
+
import { makeSimpleRouteOutlineGraphics } from "./fixtures/makeSimpleRouteOutlineGraphics"
|
|
7
7
|
|
|
8
|
-
test("
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
})
|
|
8
|
+
test("RectDiff expansion reproduces the two-node gap fixture", async () => {
|
|
9
|
+
const input = createTwoNodeExpansionInput()
|
|
10
|
+
const solver = new RectDiffExpansionSolver(input)
|
|
12
11
|
|
|
13
12
|
solver.solve()
|
|
14
13
|
|
|
15
|
-
const {
|
|
14
|
+
const { meshNodes } = solver.getOutput()
|
|
15
|
+
expect(meshNodes.length).toBeGreaterThanOrEqual(2)
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
const finalGraphics = makeCapacityMeshNodeWithLayerInfo(outputNodes)
|
|
17
|
+
const finalGraphics = makeCapacityMeshNodeWithLayerInfo(meshNodes)
|
|
18
|
+
const outline = makeSimpleRouteOutlineGraphics(input.srj)
|
|
22
19
|
const svg = getSvgFromGraphicsObject(
|
|
23
|
-
{ rects: finalGraphics.values().toArray().flat() },
|
|
20
|
+
mergeGraphics({ rects: finalGraphics.values().toArray().flat() }, outline),
|
|
24
21
|
{
|
|
25
22
|
svgWidth: 640,
|
|
26
23
|
svgHeight: 480,
|
|
27
24
|
},
|
|
28
25
|
)
|
|
29
26
|
|
|
30
|
-
// More means we have added new nodes to fill the gap
|
|
31
|
-
// expect(outputNodes.length).toEqual(3)
|
|
32
|
-
|
|
33
27
|
await expect(svg).toMatchSvgSnapshot(import.meta.path)
|
|
34
28
|
})
|