@tscircuit/schematic-trace-solver 0.0.96 → 0.0.97
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.js +216 -177
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +55 -14
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions.ts +31 -0
- package/package.json +1 -1
- package/tests/repros/__snapshots__/repro-rp2040-gamepad-trace-alignment.snap.svg +178 -0
- package/tests/repros/__snapshots__/repro-rp2040-zero-crystal-fallback-netlabels.snap.svg +54 -0
- package/tests/repros/assets/repro-rp2040-gamepad-trace-alignment.input.json +237 -0
- package/tests/repros/assets/repro-rp2040-zero-crystal-fallback-netlabels.input.json +121 -0
- package/tests/repros/repro-rp2040-gamepad-trace-alignment.test.ts +14 -0
- package/tests/repros/repro-rp2040-zero-crystal-fallback-netlabels.test.ts +16 -0
- package/tests/solvers/SchematicTraceSingleLineSolver2/segment-intersects-rect-interior.test.ts +15 -0
- package/tests/solvers/SchematicTraceSingleLineSolver2/segment-overlaps-rect-boundary-boundary.test.ts +18 -0
- package/tests/solvers/SchematicTraceSingleLineSolver2/segment-overlaps-rect-boundary-interior.test.ts +18 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chips": [
|
|
3
|
+
{
|
|
4
|
+
"chipId": "schematic_component_0",
|
|
5
|
+
"center": {
|
|
6
|
+
"x": 1.105,
|
|
7
|
+
"y": 0.67
|
|
8
|
+
},
|
|
9
|
+
"width": 0.9699999999999998,
|
|
10
|
+
"height": 0.6,
|
|
11
|
+
"pins": [
|
|
12
|
+
{
|
|
13
|
+
"pinId": "R8.1",
|
|
14
|
+
"x": 1.07,
|
|
15
|
+
"y": 0.97
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"pinId": "R8.2",
|
|
19
|
+
"x": 1.07,
|
|
20
|
+
"y": 0.37000000000000005
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"chipId": "schematic_component_1",
|
|
26
|
+
"center": {
|
|
27
|
+
"x": 1.1725,
|
|
28
|
+
"y": -0.66
|
|
29
|
+
},
|
|
30
|
+
"width": 1.045,
|
|
31
|
+
"height": 0.76,
|
|
32
|
+
"pins": [
|
|
33
|
+
{
|
|
34
|
+
"pinId": "C17.1",
|
|
35
|
+
"x": 1.1,
|
|
36
|
+
"y": -0.28,
|
|
37
|
+
"_facingDirection": "y+"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"pinId": "C17.2",
|
|
41
|
+
"x": 1.1,
|
|
42
|
+
"y": -1.04,
|
|
43
|
+
"_facingDirection": "y-"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"chipId": "schematic_component_2",
|
|
49
|
+
"center": {
|
|
50
|
+
"x": -1.07,
|
|
51
|
+
"y": 0.47
|
|
52
|
+
},
|
|
53
|
+
"width": 2.0000000000000004,
|
|
54
|
+
"height": 0.6000000000000001,
|
|
55
|
+
"pins": [
|
|
56
|
+
{
|
|
57
|
+
"pinId": "X1.1",
|
|
58
|
+
"x": -2.0700000000000003,
|
|
59
|
+
"y": 0.57
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"pinId": "X1.2",
|
|
63
|
+
"x": -2.0700000000000003,
|
|
64
|
+
"y": 0.37
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"pinId": "X1.3",
|
|
68
|
+
"x": -0.06999999999999984,
|
|
69
|
+
"y": 0.37
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"pinId": "X1.4",
|
|
73
|
+
"x": -0.06999999999999984,
|
|
74
|
+
"y": 0.57
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"directConnections": [
|
|
80
|
+
{
|
|
81
|
+
"pinIds": [
|
|
82
|
+
"X1.3",
|
|
83
|
+
"C17.1"
|
|
84
|
+
],
|
|
85
|
+
"netId": ".X1 > .XTAL2 to C17.pin1"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"pinIds": [
|
|
89
|
+
"X1.3",
|
|
90
|
+
"R8.2"
|
|
91
|
+
],
|
|
92
|
+
"netId": ".X1 > .XTAL2 to R8.pin2"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"netConnections": [],
|
|
96
|
+
"textBoxes": [
|
|
97
|
+
{
|
|
98
|
+
"chipId": "schematic_component_2",
|
|
99
|
+
"center": {
|
|
100
|
+
"x": -1.0100000000000002,
|
|
101
|
+
"y": 0.039999999999999925
|
|
102
|
+
},
|
|
103
|
+
"width": 1.3199999999999998,
|
|
104
|
+
"height": 0.18,
|
|
105
|
+
"text": "ABM8_272_T3"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"chipId": "schematic_component_2",
|
|
109
|
+
"center": {
|
|
110
|
+
"x": -1.5500000000000003,
|
|
111
|
+
"y": 0.885
|
|
112
|
+
},
|
|
113
|
+
"width": 0.3600000000000001,
|
|
114
|
+
"height": 0.25,
|
|
115
|
+
"text": "X1"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"availableNetLabelOrientations": {},
|
|
119
|
+
"maxMspPairDistance": 2.4,
|
|
120
|
+
"_hideRatsNet": false
|
|
121
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import "tests/fixtures/matcher"
|
|
4
|
+
import inputProblem from "./assets/repro-rp2040-gamepad-trace-alignment.input.json"
|
|
5
|
+
|
|
6
|
+
test("reproduces RP2040 gamepad trace routing", () => {
|
|
7
|
+
const solver = new SchematicTracePipelineSolver(inputProblem as any, {
|
|
8
|
+
hideRatsNet: true,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
solver.solve()
|
|
12
|
+
|
|
13
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
14
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import "tests/fixtures/matcher"
|
|
4
|
+
import inputProblem from "./assets/repro-rp2040-zero-crystal-fallback-netlabels.input.json"
|
|
5
|
+
|
|
6
|
+
test("rp2040-zero crystal connection routes both branches", () => {
|
|
7
|
+
const solver = new SchematicTracePipelineSolver(inputProblem as any)
|
|
8
|
+
|
|
9
|
+
solver.solve()
|
|
10
|
+
|
|
11
|
+
expect(solver.schematicTraceLinesSolver?.solvedTracePaths).toHaveLength(2)
|
|
12
|
+
expect(solver.schematicTraceLinesSolver?.failedConnectionPairs).toHaveLength(
|
|
13
|
+
0,
|
|
14
|
+
)
|
|
15
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
16
|
+
})
|
package/tests/solvers/SchematicTraceSingleLineSolver2/segment-intersects-rect-interior.test.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { segmentIntersectsRect } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions"
|
|
3
|
+
|
|
4
|
+
const rect = {
|
|
5
|
+
minX: 0,
|
|
6
|
+
maxX: 2,
|
|
7
|
+
minY: 0,
|
|
8
|
+
maxY: 2,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
test("interior crossings remain collisions", () => {
|
|
12
|
+
expect(segmentIntersectsRect({ x: -1, y: 1 }, { x: 1, y: 1 }, rect)).toBe(
|
|
13
|
+
true,
|
|
14
|
+
)
|
|
15
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { segmentOverlapsRectBoundary } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions"
|
|
3
|
+
|
|
4
|
+
const rect = {
|
|
5
|
+
minX: 0,
|
|
6
|
+
maxX: 2,
|
|
7
|
+
minY: 0,
|
|
8
|
+
maxY: 2,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
test("detects segments that overlap rectangle boundaries", () => {
|
|
12
|
+
expect(
|
|
13
|
+
segmentOverlapsRectBoundary({ x: -1, y: 0 }, { x: 1, y: 0 }, rect),
|
|
14
|
+
).toBe(true)
|
|
15
|
+
expect(
|
|
16
|
+
segmentOverlapsRectBoundary({ x: 2, y: -1 }, { x: 2, y: 1 }, rect),
|
|
17
|
+
).toBe(true)
|
|
18
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { segmentOverlapsRectBoundary } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions"
|
|
3
|
+
|
|
4
|
+
const rect = {
|
|
5
|
+
minX: 0,
|
|
6
|
+
maxX: 2,
|
|
7
|
+
minY: 0,
|
|
8
|
+
maxY: 2,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
test("does not treat interior crossings as boundary overlaps", () => {
|
|
12
|
+
expect(
|
|
13
|
+
segmentOverlapsRectBoundary({ x: -1, y: 1 }, { x: 1, y: 1 }, rect),
|
|
14
|
+
).toBe(false)
|
|
15
|
+
expect(
|
|
16
|
+
segmentOverlapsRectBoundary({ x: 1, y: -1 }, { x: 1, y: 1 }, rect),
|
|
17
|
+
).toBe(false)
|
|
18
|
+
})
|