@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.
Files changed (36) hide show
  1. package/components/SolverDebugger3d.tsx +2 -2
  2. package/dist/index.d.ts +23 -3
  3. package/dist/index.js +236 -60
  4. package/lib/RectDiffPipeline.ts +62 -22
  5. package/lib/fixtures/twoNodeExpansionFixture.ts +10 -2
  6. package/lib/rectdiff-visualization.ts +2 -1
  7. package/lib/solvers/RectDiffExpansionSolver/RectDiffExpansionSolver.ts +8 -3
  8. package/lib/solvers/RectDiffGridSolverPipeline/RectDiffGridSolverPipeline.ts +48 -9
  9. package/lib/solvers/RectDiffGridSolverPipeline/buildObstacleIndexes.ts +14 -6
  10. package/lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts +41 -5
  11. package/lib/solvers/RectDiffSeedingSolver/computeInverseRects.ts +37 -1
  12. package/lib/solvers/RectDiffSeedingSolver/layers.ts +9 -5
  13. package/lib/utils/expandRectFromSeed.ts +11 -5
  14. package/lib/utils/finalizeRects.ts +17 -9
  15. package/lib/utils/padRect.ts +11 -0
  16. package/lib/utils/renderObstacleClearance.ts +50 -0
  17. package/package.json +1 -1
  18. package/pages/bugreport11.page.tsx +1 -0
  19. package/test-assets/bugreport-c7537683-stalling.json +1107 -0
  20. package/tests/board-outline.test.ts +1 -1
  21. package/tests/bugreport-stalling.test.ts +102 -0
  22. package/tests/fixtures/makeSimpleRouteOutlineGraphics.ts +5 -1
  23. package/tests/should-expand-node.test.ts +9 -1
  24. package/tests/solver/__snapshots__/rectDiffGridSolverPipeline.snap.svg +2 -2
  25. package/tests/solver/bugreport11-b2de3c/__snapshots__/bugreport11-b2de3c-clearance.snap.svg +44 -0
  26. package/tests/solver/bugreport11-b2de3c/__snapshots__/bugreport11-b2de3c.snap.svg +2 -2
  27. package/tests/solver/bugreport11-b2de3c/bugreport11-b2de3c-clearance.test.ts +97 -0
  28. package/tests/solver/bugreport26-66b0b2/__snapshots__/bugreport26-66b0b2.snap.svg +2 -2
  29. package/tests/solver/bugreport27-dd3734/__snapshots__/bugreport27-dd3734.snap.svg +2 -2
  30. package/tests/solver/bugreport28-18a9ef/__snapshots__/bugreport28-18a9ef.snap.svg +2 -2
  31. package/tests/solver/bugreport29-7deae8/__snapshots__/bugreport29-7deae8.snap.svg +2 -2
  32. package/tests/solver/bugreport30-2174c8/__snapshots__/bugreport30-2174c8.snap.svg +2 -2
  33. package/tests/solver/bugreport33-213d45/__snapshots__/bugreport33-213d45.snap.svg +2 -2
  34. package/tests/solver/bugreport34-e9dea2/__snapshots__/bugreport34-e9dea2.snap.svg +2 -2
  35. package/tests/solver/bugreport35-191db9/__snapshots__/bugreport35-191db9.snap.svg +2 -2
  36. 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/rectdiff",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -8,6 +8,7 @@ export default () => {
8
8
  () =>
9
9
  new RectDiffPipeline({
10
10
  simpleRouteJson: simpleRouteJson.simple_route_json,
11
+ obstacleClearance: 0.015,
11
12
  }),
12
13
  [],
13
14
  )