@tscircuit/schematic-trace-solver 0.0.37 → 0.0.39
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 +25 -1
- package/dist/index.js +917 -10
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions.ts +17 -0
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/pathOps.ts +31 -12
- package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +40 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/TraceLabelOverlapAvoidanceSolver.ts +240 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/balanceLShapes.ts +207 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/countTurns.ts +18 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/detectTraceLabelOverlap.ts +38 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/hasCollisions.ts +22 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/hasCollisionsWithLabels.ts +19 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/index.ts +1 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/minimizeTurnsWithFilteredLabels.ts +66 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/rerouteCollidingTrace.ts +73 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/simplifyPath.ts +41 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/tryConnectPoints.ts +14 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/trySnipAndReconnect.ts +229 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/turnMinimization.ts +211 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/violation.ts +25 -0
- package/package.json +1 -1
- package/site/examples/example20.page.tsx +103 -0
- package/site/examples/example22.page.tsx +108 -0
- package/site/examples/example23.page.tsx +137 -0
- package/site/examples/example24.page.tsx +128 -0
- package/tests/examples/__snapshots__/example16.snap.svg +27 -27
- package/tests/examples/__snapshots__/example22.snap.svg +137 -0
- package/tests/examples/__snapshots__/example23.snap.svg +137 -0
- package/tests/examples/__snapshots__/example24.snap.svg +143 -0
- package/tests/examples/__snapshots__/example25.snap.svg +165 -0
- package/tests/examples/__snapshots__/example26.snap.svg +157 -0
- package/tests/examples/example22.test.tsx +109 -0
- package/tests/examples/example23.test.tsx +109 -0
- package/tests/examples/example24.test.tsx +114 -0
- package/tests/examples/example25.test.tsx +143 -0
- package/tests/examples/example26.test.tsx +134 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<svg width="640" height="640" viewBox="0 0 640 640" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="100%" height="100%" fill="white" />
|
|
3
|
+
<g>
|
|
4
|
+
<circle data-type="point" data-label="U1.1
|
|
5
|
+
x+" data-x="-1.7999999999999998" data-y="-0.30000000000000004" cx="201.92771084337352" cy="365.5421686746988" r="3" fill="hsl(319, 100%, 50%, 0.8)" />
|
|
6
|
+
</g>
|
|
7
|
+
<g>
|
|
8
|
+
<circle data-type="point" data-label="U1.2
|
|
9
|
+
x-" data-x="-4.2" data-y="-0.30000000000000004" cx="40" cy="365.5421686746988" r="3" fill="hsl(320, 100%, 50%, 0.8)" />
|
|
10
|
+
</g>
|
|
11
|
+
<g>
|
|
12
|
+
<circle data-type="point" data-label="U1.3
|
|
13
|
+
x+" data-x="-1.7999999999999998" data-y="0.09999999999999998" cx="201.92771084337352" cy="338.5542168674699" r="3" fill="hsl(321, 100%, 50%, 0.8)" />
|
|
14
|
+
</g>
|
|
15
|
+
<g>
|
|
16
|
+
<circle data-type="point" data-label="U1.4
|
|
17
|
+
x-" data-x="-4.2" data-y="0.30000000000000004" cx="40" cy="325.06024096385545" r="3" fill="hsl(322, 100%, 50%, 0.8)" />
|
|
18
|
+
</g>
|
|
19
|
+
<g>
|
|
20
|
+
<circle data-type="point" data-label="U1.5
|
|
21
|
+
x-" data-x="-4.2" data-y="0.10000000000000003" cx="40" cy="338.5542168674699" r="3" fill="hsl(323, 100%, 50%, 0.8)" />
|
|
22
|
+
</g>
|
|
23
|
+
<g>
|
|
24
|
+
<circle data-type="point" data-label="U1.6
|
|
25
|
+
x-" data-x="-4.2" data-y="-0.09999999999999998" cx="40" cy="352.04819277108436" r="3" fill="hsl(324, 100%, 50%, 0.8)" />
|
|
26
|
+
</g>
|
|
27
|
+
<g>
|
|
28
|
+
<circle data-type="point" data-label="U1.7
|
|
29
|
+
x+" data-x="-1.7999999999999998" data-y="-0.10000000000000003" cx="201.92771084337352" cy="352.04819277108436" r="3" fill="hsl(325, 100%, 50%, 0.8)" />
|
|
30
|
+
</g>
|
|
31
|
+
<g>
|
|
32
|
+
<circle data-type="point" data-label="U1.8
|
|
33
|
+
x+" data-x="-1.7999999999999998" data-y="0.30000000000000004" cx="201.92771084337352" cy="325.06024096385545" r="3" fill="hsl(326, 100%, 50%, 0.8)" />
|
|
34
|
+
</g>
|
|
35
|
+
<g>
|
|
36
|
+
<circle data-type="point" data-label="J1.1
|
|
37
|
+
x-" data-x="1.9" data-y="0.2" cx="451.566265060241" cy="331.8072289156627" r="3" fill="hsl(218, 100%, 50%, 0.8)" />
|
|
38
|
+
</g>
|
|
39
|
+
<g>
|
|
40
|
+
<circle data-type="point" data-label="J1.2
|
|
41
|
+
x-" data-x="1.9" data-y="0" cx="451.566265060241" cy="345.30120481927713" r="3" fill="hsl(219, 100%, 50%, 0.8)" />
|
|
42
|
+
</g>
|
|
43
|
+
<g>
|
|
44
|
+
<circle data-type="point" data-label="J1.3
|
|
45
|
+
x-" data-x="1.9" data-y="-0.2" cx="451.566265060241" cy="358.7951807228916" r="3" fill="hsl(220, 100%, 50%, 0.8)" />
|
|
46
|
+
</g>
|
|
47
|
+
<g>
|
|
48
|
+
<circle data-type="point" data-label="U2.3
|
|
49
|
+
y-" data-x="-0.4" data-y="0.5" cx="296.3855421686747" cy="311.566265060241" r="3" fill="hsl(202, 100%, 50%, 0.8)" />
|
|
50
|
+
</g>
|
|
51
|
+
<g>
|
|
52
|
+
<circle data-type="point" data-label="U2.4
|
|
53
|
+
y-" data-x="0.4" data-y="0.5" cx="350.3614457831325" cy="311.566265060241" r="3" fill="hsl(203, 100%, 50%, 0.8)" />
|
|
54
|
+
</g>
|
|
55
|
+
<g>
|
|
56
|
+
<circle data-type="point" data-label="" data-x="-0.8749999999999999" data-y="-0.30000000000000004" cx="264.33734939759034" cy="365.5421686746988" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
57
|
+
</g>
|
|
58
|
+
<g>
|
|
59
|
+
<circle data-type="point" data-label="" data-x="1.25" data-y="0.2" cx="407.71084337349396" cy="331.8072289156627" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
60
|
+
</g>
|
|
61
|
+
<g>
|
|
62
|
+
<circle data-type="point" data-label="" data-x="-0.4" data-y="0.5" cx="296.3855421686747" cy="311.566265060241" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
63
|
+
</g>
|
|
64
|
+
<g>
|
|
65
|
+
<circle data-type="point" data-label="" data-x="0.4" data-y="0.5" cx="350.3614457831325" cy="311.566265060241" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
66
|
+
</g>
|
|
67
|
+
<g>
|
|
68
|
+
<polyline data-points="-1.7999999999999998,-0.30000000000000004 1.9,-0.2" data-type="line" data-label="" points="201.92771084337352,365.5421686746988 451.566265060241,358.7951807228916" fill="none" stroke="hsl(328, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
69
|
+
</g>
|
|
70
|
+
<g>
|
|
71
|
+
<polyline data-points="1.9,0.2 -1.7999999999999998,0.09999999999999998" data-type="line" data-label="" points="451.566265060241,331.8072289156627 201.92771084337352,338.5542168674699" fill="none" stroke="hsl(210, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
72
|
+
</g>
|
|
73
|
+
<g>
|
|
74
|
+
<polyline data-points="-1.7999999999999998,-0.30000000000000004 0.050000000000000044,-0.30000000000000004 0.050000000000000044,-0.2 1.9,-0.2" data-type="line" data-label="" points="201.92771084337352,365.5421686746988 326.7469879518072,365.5421686746988 326.7469879518072,358.7951807228916 451.566265060241,358.7951807228916" fill="none" stroke="purple" stroke-width="1" />
|
|
75
|
+
</g>
|
|
76
|
+
<g>
|
|
77
|
+
<polyline data-points="1.9,0.2 0.6,0.2 0.6,-0.05099999999999996 -0.6,-0.05099999999999996 -0.6,0.09999999999999998 -1.7999999999999998,0.09999999999999998" data-type="line" data-label="" points="451.566265060241,331.8072289156627 363.855421686747,331.8072289156627 363.855421686747,348.7421686746988 282.89156626506025,348.7421686746988 282.89156626506025,338.5542168674699 201.92771084337352,338.5542168674699" fill="none" stroke="purple" stroke-width="1" />
|
|
78
|
+
</g>
|
|
79
|
+
<g>
|
|
80
|
+
<rect data-type="rect" data-label="schematic_component_0" data-x="-3" data-y="0" x="40" y="311.566265060241" width="161.92771084337352" height="67.46987951807228" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.01482142857142857" />
|
|
81
|
+
</g>
|
|
82
|
+
<g>
|
|
83
|
+
<rect data-type="rect" data-label="schematic_component_1" data-x="3" data-y="0" x="451.566265060241" y="318.3132530120482" width="148.433734939759" height="53.97590361445782" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.01482142857142857" />
|
|
84
|
+
</g>
|
|
85
|
+
<g>
|
|
86
|
+
<rect data-type="rect" data-label="schematic_component_2" data-x="0" data-y="1" x="289.6385542168675" y="244.0963855421687" width="67.46987951807228" height="67.4698795180723" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.01482142857142857" />
|
|
87
|
+
</g>
|
|
88
|
+
<g>
|
|
89
|
+
<rect data-type="rect" data-label="" data-x="-0.8749999999999999" data-y="-0.525" x="257.5903614457832" y="365.5421686746988" width="13.493975903614398" height="30.361445783132524" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.01482142857142857" />
|
|
90
|
+
</g>
|
|
91
|
+
<g>
|
|
92
|
+
<rect data-type="rect" data-label="" data-x="1.25" data-y="0.42500000000000004" x="400.96385542168673" y="301.44578313253015" width="13.493975903614455" height="30.361445783132524" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.01482142857142857" />
|
|
93
|
+
</g>
|
|
94
|
+
<g>
|
|
95
|
+
<rect data-type="rect" data-label="" data-x="-0.4" data-y="0.274" x="289.6385542168675" y="311.63373493975905" width="13.493975903614455" height="30.361445783132524" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.01482142857142857" />
|
|
96
|
+
</g>
|
|
97
|
+
<g>
|
|
98
|
+
<rect data-type="rect" data-label="" data-x="0.4" data-y="0.274" x="343.6144578313253" y="311.63373493975905" width="13.493975903614455" height="30.361445783132524" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.01482142857142857" />
|
|
99
|
+
</g>
|
|
100
|
+
<g id="crosshair" style="display: none">
|
|
101
|
+
<line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5" />
|
|
102
|
+
<line id="crosshair-v" x1="0" x2="640" stroke="#666" stroke-width="0.5" /><text id="coordinates" font-family="monospace" font-size="12" fill="#666"></text>
|
|
103
|
+
</g>
|
|
104
|
+
<script>
|
|
105
|
+
<![CDATA[
|
|
106
|
+
document.currentScript.parentElement.addEventListener('mousemove', (e) => {
|
|
107
|
+
const svg = e.currentTarget;
|
|
108
|
+
const rect = svg.getBoundingClientRect();
|
|
109
|
+
const x = e.clientX - rect.left;
|
|
110
|
+
const y = e.clientY - rect.top;
|
|
111
|
+
const crosshair = svg.getElementById('crosshair');
|
|
112
|
+
const h = svg.getElementById('crosshair-h');
|
|
113
|
+
const v = svg.getElementById('crosshair-v');
|
|
114
|
+
const coords = svg.getElementById('coordinates');
|
|
115
|
+
|
|
116
|
+
crosshair.style.display = 'block';
|
|
117
|
+
h.setAttribute('x1', '0');
|
|
118
|
+
h.setAttribute('x2', '640');
|
|
119
|
+
h.setAttribute('y1', y);
|
|
120
|
+
h.setAttribute('y2', y);
|
|
121
|
+
v.setAttribute('x1', x);
|
|
122
|
+
v.setAttribute('x2', x);
|
|
123
|
+
v.setAttribute('y1', '0');
|
|
124
|
+
v.setAttribute('y2', '640');
|
|
125
|
+
|
|
126
|
+
// Calculate real coordinates using inverse transformation
|
|
127
|
+
const matrix = {
|
|
128
|
+
"a": 67.46987951807229,
|
|
129
|
+
"c": 0,
|
|
130
|
+
"e": 323.3734939759036,
|
|
131
|
+
"b": 0,
|
|
132
|
+
"d": -67.46987951807229,
|
|
133
|
+
"f": 345.30120481927713
|
|
134
|
+
};
|
|
135
|
+
// Manually invert and apply the affine transform
|
|
136
|
+
// Since we only use translate and scale, we can directly compute:
|
|
137
|
+
// x' = (x - tx) / sx
|
|
138
|
+
// y' = (y - ty) / sy
|
|
139
|
+
const sx = matrix.a;
|
|
140
|
+
const sy = matrix.d;
|
|
141
|
+
const tx = matrix.e;
|
|
142
|
+
const ty = matrix.f;
|
|
143
|
+
const realPoint = {
|
|
144
|
+
x: (x - tx) / sx,
|
|
145
|
+
y: (y - ty) / sy // Flip y back since we used negative scale
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
|
|
149
|
+
coords.setAttribute('x', (x + 5).toString());
|
|
150
|
+
coords.setAttribute('y', (y - 5).toString());
|
|
151
|
+
});
|
|
152
|
+
document.currentScript.parentElement.addEventListener('mouseleave', () => {
|
|
153
|
+
document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
|
|
154
|
+
});
|
|
155
|
+
]]>
|
|
156
|
+
</script>
|
|
157
|
+
</svg>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { expect } from "bun:test"
|
|
2
|
+
import { test } from "bun:test"
|
|
3
|
+
import { SchematicTracePipelineSolver, type InputProblem } from "lib/index"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
const inputProblem = {
|
|
7
|
+
chips: [
|
|
8
|
+
{
|
|
9
|
+
chipId: "schematic_component_0",
|
|
10
|
+
center: {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0,
|
|
13
|
+
},
|
|
14
|
+
width: 2.4000000000000004,
|
|
15
|
+
height: 1,
|
|
16
|
+
pins: [
|
|
17
|
+
{
|
|
18
|
+
pinId: "U1.1",
|
|
19
|
+
x: 1.2000000000000002,
|
|
20
|
+
y: -0.30000000000000004,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pinId: "U1.2",
|
|
24
|
+
x: -1.2000000000000002,
|
|
25
|
+
y: -0.30000000000000004,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pinId: "U1.3",
|
|
29
|
+
x: 1.2000000000000002,
|
|
30
|
+
y: 0.09999999999999998,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pinId: "U1.4",
|
|
34
|
+
x: -1.2000000000000002,
|
|
35
|
+
y: 0.30000000000000004,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pinId: "U1.5",
|
|
39
|
+
x: -1.2000000000000002,
|
|
40
|
+
y: 0.10000000000000003,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
pinId: "U1.6",
|
|
44
|
+
x: -1.2000000000000002,
|
|
45
|
+
y: -0.09999999999999998,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
pinId: "U1.7",
|
|
49
|
+
x: 1.2000000000000002,
|
|
50
|
+
y: -0.10000000000000003,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pinId: "U1.8",
|
|
54
|
+
x: 1.2000000000000002,
|
|
55
|
+
y: 0.30000000000000004,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
chipId: "schematic_component_1",
|
|
61
|
+
center: {
|
|
62
|
+
x: 2.7,
|
|
63
|
+
y: 1.9049999999999998,
|
|
64
|
+
},
|
|
65
|
+
width: 2.2,
|
|
66
|
+
height: 0.8,
|
|
67
|
+
pins: [
|
|
68
|
+
{
|
|
69
|
+
pinId: "J1.1",
|
|
70
|
+
x: 1.6,
|
|
71
|
+
y: 2.105,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pinId: "J1.2",
|
|
75
|
+
x: 1.6,
|
|
76
|
+
y: 1.9049999999999998,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
pinId: "J1.3",
|
|
80
|
+
x: 1.6,
|
|
81
|
+
y: 1.7049999999999998,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
directConnections: [],
|
|
87
|
+
netConnections: [
|
|
88
|
+
{
|
|
89
|
+
netId: "GND",
|
|
90
|
+
pinIds: ["U1.1", "J1.3"],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
netId: "VCC",
|
|
94
|
+
pinIds: ["U1.8", "J1.1"],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
availableNetLabelOrientations: {
|
|
98
|
+
VCC: ["y+"],
|
|
99
|
+
OUT: ["x-", "x+"],
|
|
100
|
+
GND: ["y-"],
|
|
101
|
+
},
|
|
102
|
+
maxMspPairDistance: 2.4,
|
|
103
|
+
} as InputProblem
|
|
104
|
+
|
|
105
|
+
test("example22", () => {
|
|
106
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
107
|
+
solver.solve()
|
|
108
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
109
|
+
})
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { expect } from "bun:test"
|
|
2
|
+
import { test } from "bun:test"
|
|
3
|
+
import { SchematicTracePipelineSolver, type InputProblem } from "lib/index"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
const inputProblem = {
|
|
7
|
+
chips: [
|
|
8
|
+
{
|
|
9
|
+
chipId: "schematic_component_0",
|
|
10
|
+
center: {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0,
|
|
13
|
+
},
|
|
14
|
+
width: 2.4000000000000004,
|
|
15
|
+
height: 1,
|
|
16
|
+
pins: [
|
|
17
|
+
{
|
|
18
|
+
pinId: "U1.1",
|
|
19
|
+
x: 1.2000000000000002,
|
|
20
|
+
y: -0.30000000000000004,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pinId: "U1.2",
|
|
24
|
+
x: -1.2000000000000002,
|
|
25
|
+
y: -0.30000000000000004,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pinId: "U1.3",
|
|
29
|
+
x: 1.2000000000000002,
|
|
30
|
+
y: 0.09999999999999998,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pinId: "U1.4",
|
|
34
|
+
x: -1.2000000000000002,
|
|
35
|
+
y: 0.30000000000000004,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pinId: "U1.5",
|
|
39
|
+
x: -1.2000000000000002,
|
|
40
|
+
y: 0.10000000000000003,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
pinId: "U1.6",
|
|
44
|
+
x: -1.2000000000000002,
|
|
45
|
+
y: -0.09999999999999998,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
pinId: "U1.7",
|
|
49
|
+
x: 1.2000000000000002,
|
|
50
|
+
y: -0.10000000000000003,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pinId: "U1.8",
|
|
54
|
+
x: 1.2000000000000002,
|
|
55
|
+
y: 0.30000000000000004,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
chipId: "schematic_component_1",
|
|
61
|
+
center: {
|
|
62
|
+
x: 2.7,
|
|
63
|
+
y: -2.0950000000000002, // Moved below component 0
|
|
64
|
+
},
|
|
65
|
+
width: 2.2,
|
|
66
|
+
height: 0.8,
|
|
67
|
+
pins: [
|
|
68
|
+
{
|
|
69
|
+
pinId: "J1.1",
|
|
70
|
+
x: 1.6,
|
|
71
|
+
y: -1.895, // Adjusted y position
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pinId: "J1.2",
|
|
75
|
+
x: 1.6,
|
|
76
|
+
y: -2.0950000000000002, // Adjusted y position
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
pinId: "J1.3",
|
|
80
|
+
x: 1.6,
|
|
81
|
+
y: -2.295, // Adjusted y position
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
directConnections: [],
|
|
87
|
+
netConnections: [
|
|
88
|
+
{
|
|
89
|
+
netId: "GND",
|
|
90
|
+
pinIds: ["U1.1", "J1.3"], // U1.1 connects to J1.3
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
netId: "VCC",
|
|
94
|
+
pinIds: ["U1.8", "J1.1"], // U1.8 connects to J1.1
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
availableNetLabelOrientations: {
|
|
98
|
+
VCC: ["y-"], // Changed to y- since trace now goes downward
|
|
99
|
+
OUT: ["x-", "x+"],
|
|
100
|
+
GND: ["y-"], // Changed to y- since trace now goes downward
|
|
101
|
+
},
|
|
102
|
+
maxMspPairDistance: 2.4,
|
|
103
|
+
} as InputProblem
|
|
104
|
+
|
|
105
|
+
test("example23", () => {
|
|
106
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
107
|
+
solver.solve()
|
|
108
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
109
|
+
})
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { expect } from "bun:test"
|
|
2
|
+
import { test } from "bun:test"
|
|
3
|
+
import { SchematicTracePipelineSolver, type InputProblem } from "lib/index"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
const inputProblem = {
|
|
7
|
+
chips: [
|
|
8
|
+
{
|
|
9
|
+
chipId: "schematic_component_0",
|
|
10
|
+
center: {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0,
|
|
13
|
+
},
|
|
14
|
+
width: 2.4000000000000004,
|
|
15
|
+
height: 1,
|
|
16
|
+
pins: [
|
|
17
|
+
{
|
|
18
|
+
pinId: "U1.1",
|
|
19
|
+
x: 1.2000000000000002,
|
|
20
|
+
y: -0.30000000000000004,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pinId: "U1.2",
|
|
24
|
+
x: -1.2000000000000002,
|
|
25
|
+
y: -0.30000000000000004,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pinId: "U1.3",
|
|
29
|
+
x: 1.2000000000000002,
|
|
30
|
+
y: 0.09999999999999998,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pinId: "U1.4",
|
|
34
|
+
x: -1.2000000000000002,
|
|
35
|
+
y: 0.30000000000000004,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pinId: "U1.5",
|
|
39
|
+
x: -1.2000000000000002,
|
|
40
|
+
y: 0.10000000000000003,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
pinId: "U1.6",
|
|
44
|
+
x: -1.2000000000000002,
|
|
45
|
+
y: -0.09999999999999998,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
pinId: "U1.7",
|
|
49
|
+
x: 1.2000000000000002,
|
|
50
|
+
y: -0.10000000000000003,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pinId: "U1.8",
|
|
54
|
+
x: 1.2000000000000002,
|
|
55
|
+
y: 0.30000000000000004,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
chipId: "schematic_component_1",
|
|
61
|
+
center: {
|
|
62
|
+
x: 2.7,
|
|
63
|
+
y: -2.0950000000000002, // Moved below component 0
|
|
64
|
+
},
|
|
65
|
+
width: 2.2,
|
|
66
|
+
height: 0.8,
|
|
67
|
+
pins: [
|
|
68
|
+
{
|
|
69
|
+
pinId: "J1.1",
|
|
70
|
+
x: 1.6,
|
|
71
|
+
y: -1.895, // Adjusted y position
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pinId: "J1.2",
|
|
75
|
+
x: 1.6,
|
|
76
|
+
y: -2.0950000000000002, // Adjusted y position
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
pinId: "J1.3",
|
|
80
|
+
x: 1.6,
|
|
81
|
+
y: -2.295, // Adjusted y position
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
directConnections: [],
|
|
87
|
+
netConnections: [
|
|
88
|
+
{
|
|
89
|
+
netId: "GND",
|
|
90
|
+
pinIds: ["U1.1", "J1.3"], // U1.1 connects to J1.3
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
netId: "VCC",
|
|
94
|
+
pinIds: ["U1.8", "J1.1"], // U1.8 connects to J1.1
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
netId: "MMM",
|
|
98
|
+
pinIds: ["J1.2"], // U1.8 connects to J1.1
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
availableNetLabelOrientations: {
|
|
102
|
+
VCC: ["y-"], // Changed to y- since trace now goes downward
|
|
103
|
+
OUT: ["x-", "x+"],
|
|
104
|
+
GND: ["y-"], // Changed to y- since trace now goes downward
|
|
105
|
+
MMM: ["x+", "x-"],
|
|
106
|
+
},
|
|
107
|
+
maxMspPairDistance: 2.4,
|
|
108
|
+
} as InputProblem
|
|
109
|
+
|
|
110
|
+
test("example24", () => {
|
|
111
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
112
|
+
solver.solve()
|
|
113
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
114
|
+
})
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { expect } from "bun:test"
|
|
2
|
+
import { test } from "bun:test"
|
|
3
|
+
import { SchematicTracePipelineSolver, type InputProblem } from "lib/index"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
const inputProblem = {
|
|
7
|
+
chips: [
|
|
8
|
+
{
|
|
9
|
+
chipId: "schematic_component_0",
|
|
10
|
+
center: {
|
|
11
|
+
x: -3,
|
|
12
|
+
y: 0,
|
|
13
|
+
},
|
|
14
|
+
width: 2.4000000000000004,
|
|
15
|
+
height: 1,
|
|
16
|
+
pins: [
|
|
17
|
+
{
|
|
18
|
+
pinId: "U1.1",
|
|
19
|
+
x: -1.8,
|
|
20
|
+
y: -0.30000000000000004,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pinId: "U1.2",
|
|
24
|
+
x: -4.2,
|
|
25
|
+
y: -0.30000000000000004,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pinId: "U1.3",
|
|
29
|
+
x: -1.8,
|
|
30
|
+
y: 0.09999999999999998,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pinId: "U1.4",
|
|
34
|
+
x: -4.2,
|
|
35
|
+
y: 0.30000000000000004,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pinId: "U1.5",
|
|
39
|
+
x: -4.2,
|
|
40
|
+
y: 0.10000000000000003,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
pinId: "U1.6",
|
|
44
|
+
x: -4.2,
|
|
45
|
+
y: -0.09999999999999998,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
pinId: "U1.7",
|
|
49
|
+
x: -1.8,
|
|
50
|
+
y: -0.10000000000000003,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pinId: "U1.8",
|
|
54
|
+
x: -1.8,
|
|
55
|
+
y: 0.30000000000000004,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
chipId: "schematic_component_1",
|
|
61
|
+
center: {
|
|
62
|
+
x: 3,
|
|
63
|
+
y: 0,
|
|
64
|
+
},
|
|
65
|
+
width: 2.2,
|
|
66
|
+
height: 0.8,
|
|
67
|
+
pins: [
|
|
68
|
+
{
|
|
69
|
+
pinId: "J1.1",
|
|
70
|
+
x: 1.9,
|
|
71
|
+
y: 0.2,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pinId: "J1.2",
|
|
75
|
+
x: 1.9,
|
|
76
|
+
y: 0,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
pinId: "J1.3",
|
|
80
|
+
x: 1.9,
|
|
81
|
+
y: -0.2,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
chipId: "schematic_component_2",
|
|
87
|
+
center: {
|
|
88
|
+
x: 0,
|
|
89
|
+
y: -2, // Moved down so component body doesn't block horizontal traces
|
|
90
|
+
},
|
|
91
|
+
width: 1.2,
|
|
92
|
+
height: 3,
|
|
93
|
+
pins: [
|
|
94
|
+
{
|
|
95
|
+
pinId: "U2.1",
|
|
96
|
+
x: -0.4,
|
|
97
|
+
y: -0.5, // Top pin
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
pinId: "U2.2",
|
|
101
|
+
x: 0.4,
|
|
102
|
+
y: -0.6,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
pinId: "U2.3",
|
|
106
|
+
x: -0.4,
|
|
107
|
+
y: -2.8, // Bottom pin
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
pinId: "U2.4",
|
|
111
|
+
x: 0.4,
|
|
112
|
+
y: -2.8,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
directConnections: [
|
|
118
|
+
{
|
|
119
|
+
pinIds: ["U1.1", "J1.3"],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
pinIds: ["U1.8", "J1.1"],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
netConnections: [
|
|
126
|
+
{
|
|
127
|
+
netId: "SIGNAL1",
|
|
128
|
+
pinIds: ["U2.2"],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
netId: "SIGNAL2",
|
|
132
|
+
pinIds: ["U2.1"],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
availableNetLabelOrientations: {},
|
|
136
|
+
maxMspPairDistance: 6.5,
|
|
137
|
+
} as InputProblem
|
|
138
|
+
|
|
139
|
+
test("example25", () => {
|
|
140
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
141
|
+
solver.solve()
|
|
142
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
143
|
+
})
|