@tscircuit/rectdiff 0.0.3 → 0.0.5
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 +112 -3
- package/dist/index.js +869 -142
- package/index.html +2 -2
- package/lib/solvers/RectDiffSolver.ts +125 -24
- package/lib/solvers/rectdiff/candidates.ts +150 -104
- package/lib/solvers/rectdiff/engine.ts +72 -53
- package/lib/solvers/rectdiff/gapfill/detection/deduplicateGaps.ts +28 -0
- package/lib/solvers/rectdiff/gapfill/detection/findAllGaps.ts +83 -0
- package/lib/solvers/rectdiff/gapfill/detection/findGapsOnLayer.ts +100 -0
- package/lib/solvers/rectdiff/gapfill/detection/mergeUncoveredCells.ts +75 -0
- package/lib/solvers/rectdiff/gapfill/detection.ts +3 -0
- package/lib/solvers/rectdiff/gapfill/engine/addPlacement.ts +27 -0
- package/lib/solvers/rectdiff/gapfill/engine/calculateCoverage.ts +44 -0
- package/lib/solvers/rectdiff/gapfill/engine/findUncoveredPoints.ts +43 -0
- package/lib/solvers/rectdiff/gapfill/engine/getGapFillProgress.ts +42 -0
- package/lib/solvers/rectdiff/gapfill/engine/initGapFillState.ts +57 -0
- package/lib/solvers/rectdiff/gapfill/engine/stepGapFill.ts +128 -0
- package/lib/solvers/rectdiff/gapfill/engine/tryExpandGap.ts +78 -0
- package/lib/solvers/rectdiff/gapfill/engine.ts +7 -0
- package/lib/solvers/rectdiff/gapfill/types.ts +60 -0
- package/lib/solvers/rectdiff/geometry.ts +23 -11
- package/lib/solvers/rectdiff/subsolvers/GapFillSubSolver.ts +253 -0
- package/lib/solvers/rectdiff/types.ts +1 -1
- package/main.tsx +1 -0
- package/package.json +11 -8
- package/tests/obstacle-extra-layers.test.ts +1 -1
- package/tests/obstacle-zlayers.test.ts +1 -1
- package/tests/rect-diff-solver.test.ts +1 -4
- package/utils/README.md +21 -0
- package/utils/rectsEqual.ts +18 -0
- package/utils/rectsOverlap.ts +18 -0
- package/vite.config.ts +7 -0
|
@@ -29,7 +29,7 @@ test("RectDiffSolver maps obstacle layers to numeric zLayers", () => {
|
|
|
29
29
|
],
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const solver = new RectDiffSolver({ simpleRouteJson: srj
|
|
32
|
+
const solver = new RectDiffSolver({ simpleRouteJson: srj })
|
|
33
33
|
solver.setup()
|
|
34
34
|
|
|
35
35
|
expect(srj.obstacles[0]?.zLayers).toEqual([0])
|
|
@@ -27,7 +27,6 @@ test("RectDiffSolver creates mesh nodes with grid-based approach", () => {
|
|
|
27
27
|
|
|
28
28
|
const solver = new RectDiffSolver({
|
|
29
29
|
simpleRouteJson,
|
|
30
|
-
mode: "grid",
|
|
31
30
|
})
|
|
32
31
|
|
|
33
32
|
solver.solve()
|
|
@@ -62,7 +61,6 @@ test("RectDiffSolver handles multi-layer spans", () => {
|
|
|
62
61
|
|
|
63
62
|
const solver = new RectDiffSolver({
|
|
64
63
|
simpleRouteJson,
|
|
65
|
-
mode: "grid",
|
|
66
64
|
gridOptions: {
|
|
67
65
|
minSingle: { width: 0.4, height: 0.4 },
|
|
68
66
|
minMulti: { width: 1.0, height: 1.0, minLayers: 2 },
|
|
@@ -105,7 +103,6 @@ test("RectDiffSolver respects single-layer minimums", () => {
|
|
|
105
103
|
|
|
106
104
|
const solver = new RectDiffSolver({
|
|
107
105
|
simpleRouteJson,
|
|
108
|
-
mode: "grid",
|
|
109
106
|
gridOptions: {
|
|
110
107
|
minSingle: { width: minWidth, height: minHeight },
|
|
111
108
|
minMulti: { width: 1.0, height: 1.0, minLayers: 2 },
|
|
@@ -131,7 +128,7 @@ test("disruptive placement resizes single-layer nodes", () => {
|
|
|
131
128
|
layerCount: 3,
|
|
132
129
|
minTraceWidth: 0.2,
|
|
133
130
|
}
|
|
134
|
-
const solver = new RectDiffSolver({ simpleRouteJson: srj
|
|
131
|
+
const solver = new RectDiffSolver({ simpleRouteJson: srj })
|
|
135
132
|
solver.setup()
|
|
136
133
|
|
|
137
134
|
// Manually seed a soft, single-layer node occupying center (simulate early placement)
|
package/utils/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Project Utilities
|
|
2
|
+
|
|
3
|
+
This directory contains global utility functions that can be reused across different parts of the application.
|
|
4
|
+
|
|
5
|
+
## Geometry
|
|
6
|
+
|
|
7
|
+
### `rectsOverlap(a: XYRect, b: XYRect): boolean`
|
|
8
|
+
|
|
9
|
+
- **Description:** Checks if two rectangles overlap.
|
|
10
|
+
- **Parameters:**
|
|
11
|
+
- `a`: The first rectangle (`XYRect`).
|
|
12
|
+
- `b`: The second rectangle (`XYRect`).
|
|
13
|
+
- **Returns:** `true` if the rectangles overlap, `false` otherwise.
|
|
14
|
+
|
|
15
|
+
### `rectsEqual(a: XYRect, b: XYRect): boolean`
|
|
16
|
+
|
|
17
|
+
- **Description:** Checks if two rectangles are equal within a small tolerance (EPS).
|
|
18
|
+
- **Parameters:**
|
|
19
|
+
- `a`: The first rectangle (`XYRect`).
|
|
20
|
+
- `b`: The second rectangle (`XYRect`).
|
|
21
|
+
- **Returns:** `true` if the rectangles are equal, `false` otherwise.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// utils/rectsEqual.ts
|
|
2
|
+
import type { XYRect } from "../lib/solvers/rectdiff/types"
|
|
3
|
+
import { EPS } from "../lib/solvers/rectdiff/geometry"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if two rectangles are equal within a small tolerance (EPS).
|
|
7
|
+
* @param a The first rectangle.
|
|
8
|
+
* @param b The second rectangle.
|
|
9
|
+
* @returns True if the rectangles are equal, false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export function rectsEqual(a: XYRect, b: XYRect): boolean {
|
|
12
|
+
return (
|
|
13
|
+
Math.abs(a.x - b.x) < EPS &&
|
|
14
|
+
Math.abs(a.y - b.y) < EPS &&
|
|
15
|
+
Math.abs(a.width - b.width) < EPS &&
|
|
16
|
+
Math.abs(a.height - b.height) < EPS
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// utils/rectsOverlap.ts
|
|
2
|
+
import type { XYRect } from "../lib/solvers/rectdiff/types"
|
|
3
|
+
import { EPS } from "../lib/solvers/rectdiff/geometry"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if two rectangles overlap.
|
|
7
|
+
* @param a The first rectangle.
|
|
8
|
+
* @param b The second rectangle.
|
|
9
|
+
* @returns True if the rectangles overlap, false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export function rectsOverlap(a: XYRect, b: XYRect): boolean {
|
|
12
|
+
return !(
|
|
13
|
+
a.x + a.width <= b.x + EPS ||
|
|
14
|
+
b.x + b.width <= a.x + EPS ||
|
|
15
|
+
a.y + a.height <= b.y + EPS ||
|
|
16
|
+
b.y + b.height <= a.y + EPS
|
|
17
|
+
)
|
|
18
|
+
}
|