@tscircuit/rectdiff 0.0.21 → 0.0.23
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/components/SolverDebugger3d.tsx +2 -2
- package/dist/index.d.ts +23 -3
- package/dist/index.js +236 -60
- package/lib/RectDiffPipeline.ts +62 -22
- package/lib/fixtures/twoNodeExpansionFixture.ts +10 -2
- package/lib/rectdiff-visualization.ts +2 -1
- package/lib/solvers/RectDiffExpansionSolver/RectDiffExpansionSolver.ts +8 -3
- package/lib/solvers/RectDiffGridSolverPipeline/RectDiffGridSolverPipeline.ts +48 -9
- package/lib/solvers/RectDiffGridSolverPipeline/buildObstacleIndexes.ts +14 -6
- package/lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts +41 -5
- package/lib/solvers/RectDiffSeedingSolver/computeInverseRects.ts +37 -1
- package/lib/solvers/RectDiffSeedingSolver/layers.ts +9 -5
- package/lib/utils/expandRectFromSeed.ts +11 -5
- package/lib/utils/finalizeRects.ts +17 -9
- package/lib/utils/padRect.ts +11 -0
- package/lib/utils/renderObstacleClearance.ts +50 -0
- package/package.json +1 -1
- package/pages/bugreport11.page.tsx +1 -0
- package/test-assets/bugreport-c7537683-stalling.json +1107 -0
- package/tests/board-outline.test.ts +1 -1
- package/tests/bugreport-stalling.test.ts +102 -0
- package/tests/fixtures/makeSimpleRouteOutlineGraphics.ts +5 -1
- package/tests/should-expand-node.test.ts +9 -1
- package/tests/solver/__snapshots__/rectDiffGridSolverPipeline.snap.svg +2 -2
- package/tests/solver/bugreport11-b2de3c/__snapshots__/bugreport11-b2de3c-clearance.snap.svg +44 -0
- package/tests/solver/bugreport11-b2de3c/__snapshots__/bugreport11-b2de3c.snap.svg +2 -2
- package/tests/solver/bugreport11-b2de3c/bugreport11-b2de3c-clearance.test.ts +97 -0
- package/tests/solver/bugreport26-66b0b2/__snapshots__/bugreport26-66b0b2.snap.svg +2 -2
- package/tests/solver/bugreport27-dd3734/__snapshots__/bugreport27-dd3734.snap.svg +2 -2
- package/tests/solver/bugreport28-18a9ef/__snapshots__/bugreport28-18a9ef.snap.svg +2 -2
- package/tests/solver/bugreport29-7deae8/__snapshots__/bugreport29-7deae8.snap.svg +2 -2
- package/tests/solver/bugreport30-2174c8/__snapshots__/bugreport30-2174c8.snap.svg +2 -2
- package/tests/solver/bugreport33-213d45/__snapshots__/bugreport33-213d45.snap.svg +2 -2
- package/tests/solver/bugreport34-e9dea2/__snapshots__/bugreport34-e9dea2.snap.svg +2 -2
- package/tests/solver/bugreport35-191db9/__snapshots__/bugreport35-191db9.snap.svg +2 -2
- package/tests/solver/bugreport36-bf8303/__snapshots__/bugreport36-bf8303.snap.svg +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { XYRect } from "../rectdiff-types"
|
|
2
|
+
|
|
3
|
+
export const padRect = (rect: XYRect, clearance: number): XYRect => {
|
|
4
|
+
if (!clearance || clearance <= 0) return rect
|
|
5
|
+
return {
|
|
6
|
+
x: rect.x - clearance,
|
|
7
|
+
y: rect.y - clearance,
|
|
8
|
+
width: rect.width + 2 * clearance,
|
|
9
|
+
height: rect.height + 2 * clearance,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { SimpleRouteJson } from "lib/types/srj-types"
|
|
2
|
+
import type { GraphicsObject } from "graphics-debug"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pure helper that returns clearance rect graphics; does not mutate inputs.
|
|
6
|
+
*/
|
|
7
|
+
export const buildObstacleClearanceGraphics = (params: {
|
|
8
|
+
srj: SimpleRouteJson
|
|
9
|
+
clearance: number | undefined
|
|
10
|
+
}): GraphicsObject => {
|
|
11
|
+
const { srj, clearance } = params
|
|
12
|
+
const c = clearance ?? 0
|
|
13
|
+
if (c <= 0) {
|
|
14
|
+
return {
|
|
15
|
+
title: "Obstacle Clearance",
|
|
16
|
+
coordinateSystem: "cartesian",
|
|
17
|
+
rects: [],
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const rects: NonNullable<GraphicsObject["rects"]> = []
|
|
22
|
+
|
|
23
|
+
for (const obstacle of srj.obstacles ?? []) {
|
|
24
|
+
if (obstacle.type !== "rect" && obstacle.type !== "oval") continue
|
|
25
|
+
const expanded = {
|
|
26
|
+
x: obstacle.center.x - obstacle.width / 2 - c,
|
|
27
|
+
y: obstacle.center.y - obstacle.height / 2 - c,
|
|
28
|
+
width: obstacle.width + 2 * c,
|
|
29
|
+
height: obstacle.height + 2 * c,
|
|
30
|
+
}
|
|
31
|
+
rects.push({
|
|
32
|
+
center: {
|
|
33
|
+
x: expanded.x + expanded.width / 2,
|
|
34
|
+
y: expanded.y + expanded.height / 2,
|
|
35
|
+
},
|
|
36
|
+
width: expanded.width,
|
|
37
|
+
height: expanded.height,
|
|
38
|
+
stroke: "rgba(202, 138, 4, 0.9)",
|
|
39
|
+
fill: "rgba(234, 179, 8, 0.15)",
|
|
40
|
+
layer: "obstacle-clearance",
|
|
41
|
+
label: `clearance\nz:${(obstacle.zLayers ?? []).join(",") || "all"}`,
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
title: "Obstacle Clearance",
|
|
47
|
+
coordinateSystem: "cartesian",
|
|
48
|
+
rects,
|
|
49
|
+
}
|
|
50
|
+
}
|
package/package.json
CHANGED