@tscircuit/schematic-trace-solver 0.0.73 → 0.0.74
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 +0 -30
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +0 -5
- package/package.json +1 -1
- package/site/examples/example43.page.tsx +4 -0
- package/tests/assets/example43.json +45 -0
- package/tests/examples/__snapshots__/example43.snap.svg +169 -0
- package/tests/examples/example43.test.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -5863,33 +5863,6 @@ var tracePathIntersectsBounds = (tracePath, bounds) => {
|
|
|
5863
5863
|
}
|
|
5864
5864
|
return false;
|
|
5865
5865
|
};
|
|
5866
|
-
var tracePathCrossesAnyTrace = (tracePath, traceMap) => {
|
|
5867
|
-
for (const trace of Object.values(traceMap)) {
|
|
5868
|
-
const points = trace.tracePath;
|
|
5869
|
-
for (let i = 0; i < tracePath.length - 1; i++) {
|
|
5870
|
-
for (let j = 0; j < points.length - 1; j++) {
|
|
5871
|
-
if (segmentsStrictlyCross(
|
|
5872
|
-
tracePath[i],
|
|
5873
|
-
tracePath[i + 1],
|
|
5874
|
-
points[j],
|
|
5875
|
-
points[j + 1]
|
|
5876
|
-
)) {
|
|
5877
|
-
return true;
|
|
5878
|
-
}
|
|
5879
|
-
}
|
|
5880
|
-
}
|
|
5881
|
-
}
|
|
5882
|
-
return false;
|
|
5883
|
-
};
|
|
5884
|
-
var segmentsStrictlyCross = (a1, a2, b1, b2) => {
|
|
5885
|
-
if (sameX2(a1, a2) && sameY2(b1, b2)) {
|
|
5886
|
-
return a1.x > Math.min(b1.x, b2.x) + EPS8 && a1.x < Math.max(b1.x, b2.x) - EPS8 && b1.y > Math.min(a1.y, a2.y) + EPS8 && b1.y < Math.max(a1.y, a2.y) - EPS8;
|
|
5887
|
-
}
|
|
5888
|
-
if (sameY2(a1, a2) && sameX2(b1, b2)) {
|
|
5889
|
-
return b1.x > Math.min(a1.x, a2.x) + EPS8 && b1.x < Math.max(a1.x, a2.x) - EPS8 && a1.y > Math.min(b1.y, b2.y) + EPS8 && a1.y < Math.max(b1.y, b2.y) - EPS8;
|
|
5890
|
-
}
|
|
5891
|
-
return false;
|
|
5892
|
-
};
|
|
5893
5866
|
var getSideDistances = (point, bounds) => [
|
|
5894
5867
|
["left", Math.abs(point.x - bounds.minX)],
|
|
5895
5868
|
["right", Math.abs(point.x - bounds.maxX)],
|
|
@@ -6472,9 +6445,6 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
6472
6445
|
orientation: candidate.orientation,
|
|
6473
6446
|
phase
|
|
6474
6447
|
});
|
|
6475
|
-
if (tracePathCrossesAnyTrace(connectorTrace, this.traceMap)) {
|
|
6476
|
-
return "trace-collision";
|
|
6477
|
-
}
|
|
6478
6448
|
for (const chip of this.chipObstacleSpatialIndex.chips) {
|
|
6479
6449
|
if (tracePathCrossesAnyBounds(connectorTrace, chip.bounds)) {
|
|
6480
6450
|
return "chip-collision";
|
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
traceCrossesBoundsInterior,
|
|
25
25
|
tracePathIntersectsBounds,
|
|
26
26
|
tracePathCrossesAnyBounds,
|
|
27
|
-
tracePathCrossesAnyTrace,
|
|
28
27
|
} from "./geometry"
|
|
29
28
|
import { getPinMap, getTracePins, toNetLabelPlacementPatch } from "./traces"
|
|
30
29
|
import type {
|
|
@@ -618,10 +617,6 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
618
617
|
phase,
|
|
619
618
|
})
|
|
620
619
|
|
|
621
|
-
if (tracePathCrossesAnyTrace(connectorTrace, this.traceMap)) {
|
|
622
|
-
return "trace-collision"
|
|
623
|
-
}
|
|
624
|
-
|
|
625
620
|
for (const chip of this.chipObstacleSpatialIndex.chips) {
|
|
626
621
|
if (tracePathCrossesAnyBounds(connectorTrace, chip.bounds)) {
|
|
627
622
|
return "chip-collision"
|
package/package.json
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chips": [
|
|
3
|
+
{
|
|
4
|
+
"chipId": "schematic_component_0",
|
|
5
|
+
"center": { "x": 0, "y": 0 },
|
|
6
|
+
"width": 1.3,
|
|
7
|
+
"height": 1,
|
|
8
|
+
"pins": [
|
|
9
|
+
{ "pinId": "PWR1.7", "x": 1.05, "y": 0.2 },
|
|
10
|
+
{ "pinId": "PWR1.6", "x": 1.05, "y": 0 },
|
|
11
|
+
{ "pinId": "PWR1.5", "x": 1.05, "y": -0.2 },
|
|
12
|
+
{ "pinId": "PWR1.4", "x": -1.05, "y": -0.30000000000000004 },
|
|
13
|
+
{ "pinId": "PWR1.3", "x": -1.05, "y": -0.09999999999999998 },
|
|
14
|
+
{ "pinId": "PWR1.2", "x": -1.05, "y": 0.10000000000000003 },
|
|
15
|
+
{ "pinId": "PWR1.1", "x": -1.05, "y": 0.30000000000000004 }
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"chipId": "schematic_component_1",
|
|
20
|
+
"center": { "x": 3, "y": -1.5 },
|
|
21
|
+
"width": 1.0999999999999996,
|
|
22
|
+
"height": 1.2400000000000002,
|
|
23
|
+
"pins": [
|
|
24
|
+
{ "pinId": "C6.1", "x": 2.45, "y": -1.5 },
|
|
25
|
+
{ "pinId": "C6.2", "x": 3.55, "y": -1.5 }
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"directConnections": [],
|
|
30
|
+
"netConnections": [
|
|
31
|
+
{
|
|
32
|
+
"netId": "v5",
|
|
33
|
+
"pinIds": ["PWR1.6", "PWR1.4", "C6.1"],
|
|
34
|
+
"netLabelWidth": 0.36
|
|
35
|
+
},
|
|
36
|
+
{ "netId": "gnd", "pinIds": ["PWR1.3", "C6.2"], "netLabelWidth": 0.48 },
|
|
37
|
+
{ "netId": "v3_3", "pinIds": ["PWR1.1"], "netLabelWidth": 0.6 }
|
|
38
|
+
],
|
|
39
|
+
"availableNetLabelOrientations": {
|
|
40
|
+
"v5": ["y+"],
|
|
41
|
+
"v3_3": ["y+"],
|
|
42
|
+
"gnd": ["y-"]
|
|
43
|
+
},
|
|
44
|
+
"maxMspPairDistance": 2.4
|
|
45
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
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="PWR1.7
|
|
5
|
+
x+" data-x="1.05" data-y="0.2" cx="325.0890585241731" cy="221.78117048346053" r="3" fill="hsl(159, 100%, 50%, 0.8)" />
|
|
6
|
+
</g>
|
|
7
|
+
<g>
|
|
8
|
+
<circle data-type="point" data-label="PWR1.6
|
|
9
|
+
x+" data-x="1.05" data-y="0" cx="325.0890585241731" cy="242.13740458015263" r="3" fill="hsl(158, 100%, 50%, 0.8)" />
|
|
10
|
+
</g>
|
|
11
|
+
<g>
|
|
12
|
+
<circle data-type="point" data-label="PWR1.5
|
|
13
|
+
x+" data-x="1.05" data-y="-0.2" cx="325.0890585241731" cy="262.49363867684474" r="3" fill="hsl(157, 100%, 50%, 0.8)" />
|
|
14
|
+
</g>
|
|
15
|
+
<g>
|
|
16
|
+
<circle data-type="point" data-label="PWR1.4
|
|
17
|
+
x-" data-x="-1.05" data-y="-0.30000000000000004" cx="111.34860050890588" cy="272.6717557251908" r="3" fill="hsl(156, 100%, 50%, 0.8)" />
|
|
18
|
+
</g>
|
|
19
|
+
<g>
|
|
20
|
+
<circle data-type="point" data-label="PWR1.3
|
|
21
|
+
x-" data-x="-1.05" data-y="-0.09999999999999998" cx="111.34860050890588" cy="252.3155216284987" r="3" fill="hsl(155, 100%, 50%, 0.8)" />
|
|
22
|
+
</g>
|
|
23
|
+
<g>
|
|
24
|
+
<circle data-type="point" data-label="PWR1.2
|
|
25
|
+
x-" data-x="-1.05" data-y="0.10000000000000003" cx="111.34860050890588" cy="231.95928753180658" r="3" fill="hsl(154, 100%, 50%, 0.8)" />
|
|
26
|
+
</g>
|
|
27
|
+
<g>
|
|
28
|
+
<circle data-type="point" data-label="PWR1.1
|
|
29
|
+
x-" data-x="-1.05" data-y="0.30000000000000004" cx="111.34860050890588" cy="211.60305343511445" r="3" fill="hsl(153, 100%, 50%, 0.8)" />
|
|
30
|
+
</g>
|
|
31
|
+
<g>
|
|
32
|
+
<circle data-type="point" data-label="C6.1
|
|
33
|
+
x-" data-x="2.45" data-y="-1.5" cx="467.5826972010179" cy="394.8091603053435" r="3" fill="hsl(246, 100%, 50%, 0.8)" />
|
|
34
|
+
</g>
|
|
35
|
+
<g>
|
|
36
|
+
<circle data-type="point" data-label="C6.2
|
|
37
|
+
x+" data-x="3.55" data-y="-1.5" cx="579.5419847328244" cy="394.8091603053435" r="3" fill="hsl(247, 100%, 50%, 0.8)" />
|
|
38
|
+
</g>
|
|
39
|
+
<g>
|
|
40
|
+
<circle data-type="point" data-label="anchorPoint
|
|
41
|
+
orientation: y+" data-x="1.4" data-y="0" cx="360.71246819338427" cy="242.13740458015263" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
42
|
+
</g>
|
|
43
|
+
<g>
|
|
44
|
+
<circle data-type="point" data-label="anchorPoint
|
|
45
|
+
orientation: y+" data-x="-1.651" data-y="-0.24900000000000005" cx="50.17811704834608" cy="267.48091603053433" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
46
|
+
</g>
|
|
47
|
+
<g>
|
|
48
|
+
<circle data-type="point" data-label="anchorPoint
|
|
49
|
+
orientation: y-" data-x="-1.151" data-y="-0.5009999999999999" cx="101.06870229007636" cy="293.1297709923664" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
50
|
+
</g>
|
|
51
|
+
<g>
|
|
52
|
+
<circle data-type="point" data-label="anchorPoint
|
|
53
|
+
orientation: y-" data-x="3.651" data-y="-2.151" cx="589.8218829516541" cy="461.0687022900763" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
54
|
+
</g>
|
|
55
|
+
<g>
|
|
56
|
+
<circle data-type="point" data-label="anchorPoint
|
|
57
|
+
orientation: y+" data-x="-1.151" data-y="0.5010000000000001" cx="101.06870229007636" cy="191.14503816793888" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
58
|
+
</g>
|
|
59
|
+
<g>
|
|
60
|
+
<polyline data-points="1.05,0 -1.05,-0.30000000000000004" data-type="line" data-label="" points="325.0890585241731,242.13740458015263 111.34860050890588,272.6717557251908" fill="none" stroke="hsl(111, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
61
|
+
</g>
|
|
62
|
+
<g>
|
|
63
|
+
<polyline data-points="1.05,0 2.45,-1.5" data-type="line" data-label="" points="325.0890585241731,242.13740458015263 467.5826972010179,394.8091603053435" fill="none" stroke="hsl(111, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
64
|
+
</g>
|
|
65
|
+
<g>
|
|
66
|
+
<polyline data-points="-1.05,-0.30000000000000004 2.45,-1.5" data-type="line" data-label="" points="111.34860050890588,272.6717557251908 467.5826972010179,394.8091603053435" fill="none" stroke="hsl(111, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
67
|
+
</g>
|
|
68
|
+
<g>
|
|
69
|
+
<polyline data-points="-1.05,-0.09999999999999998 3.55,-1.5" data-type="line" data-label="" points="111.34860050890588,252.3155216284987 579.5419847328244,394.8091603053435" fill="none" stroke="hsl(253, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
70
|
+
</g>
|
|
71
|
+
<g>
|
|
72
|
+
<polyline data-points="1.05,0 1.75,0 1.75,-1.5 2.45,-1.5" data-type="line" data-label="" points="325.0890585241731,242.13740458015263 396.33587786259545,242.13740458015263 396.33587786259545,394.8091603053435 467.5826972010179,394.8091603053435" fill="none" stroke="purple" stroke-width="1" />
|
|
73
|
+
</g>
|
|
74
|
+
<g>
|
|
75
|
+
<polyline data-points="-1.05,-0.30000000000000004 -1.651,-0.30000000000000004 -1.651,-0.24900000000000005" data-type="line" data-label="" points="111.34860050890588,272.6717557251908 50.17811704834608,272.6717557251908 50.17811704834608,267.48091603053433" fill="none" stroke="purple" stroke-width="1" />
|
|
76
|
+
</g>
|
|
77
|
+
<g>
|
|
78
|
+
<polyline data-points="-1.05,-0.09999999999999998 -1.151,-0.09999999999999998 -1.151,-0.5009999999999999" data-type="line" data-label="" points="111.34860050890588,252.3155216284987 101.06870229007636,252.3155216284987 101.06870229007636,293.1297709923664" fill="none" stroke="purple" stroke-width="1" />
|
|
79
|
+
</g>
|
|
80
|
+
<g>
|
|
81
|
+
<polyline data-points="3.55,-1.5 3.651,-1.5 3.651,-2.151" data-type="line" data-label="" points="579.5419847328244,394.8091603053435 589.8218829516541,394.8091603053435 589.8218829516541,461.0687022900763" fill="none" stroke="purple" stroke-width="1" />
|
|
82
|
+
</g>
|
|
83
|
+
<g>
|
|
84
|
+
<polyline data-points="-1.05,0.30000000000000004 -1.151,0.30000000000000004 -1.151,0.5010000000000001" data-type="line" data-label="" points="111.34860050890588,211.60305343511445 101.06870229007636,211.60305343511445 101.06870229007636,191.14503816793888" fill="none" stroke="purple" stroke-width="1" />
|
|
85
|
+
</g>
|
|
86
|
+
<g>
|
|
87
|
+
<rect data-type="rect" data-label="schematic_component_0" data-x="0" data-y="0" x="111.34860050890588" y="191.24681933842234" width="213.74045801526722" height="101.78117048346056" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.009824999999999999" />
|
|
88
|
+
</g>
|
|
89
|
+
<g>
|
|
90
|
+
<rect data-type="rect" data-label="schematic_component_1" data-x="3" data-y="-1.5" x="467.5826972010179" y="331.7048346055979" width="111.95928753180652" height="126.20865139949115" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.009824999999999999" />
|
|
91
|
+
</g>
|
|
92
|
+
<g>
|
|
93
|
+
<rect data-type="rect" data-label="netId: v5
|
|
94
|
+
globalConnNetId: connectivity_net0" data-x="1.4" data-y="0.18" x="350.53435114503816" y="205.49618320610682" width="20.356234096692162" height="36.64122137404581" fill="#ef444466" stroke="#ef4444" stroke-width="0.009824999999999999" />
|
|
95
|
+
</g>
|
|
96
|
+
<g>
|
|
97
|
+
<rect data-type="rect" data-label="netId: v5
|
|
98
|
+
globalConnNetId: connectivity_net0" data-x="-1.651" data-y="-0.06900000000000006" x="40" y="230.83969465648852" width="20.356234096692134" height="36.64122137404581" fill="#ef444466" stroke="#ef4444" stroke-width="0.009824999999999999" />
|
|
99
|
+
</g>
|
|
100
|
+
<g>
|
|
101
|
+
<rect data-type="rect" data-label="netId: gnd
|
|
102
|
+
globalConnNetId: connectivity_net1" data-x="-1.151" data-y="-0.7409999999999999" x="90.89058524173029" y="293.1297709923664" width="20.35623409669212" height="48.854961832061065" fill="#00000066" stroke="#000000" stroke-width="0.009824999999999999" />
|
|
103
|
+
</g>
|
|
104
|
+
<g>
|
|
105
|
+
<rect data-type="rect" data-label="netId: gnd
|
|
106
|
+
globalConnNetId: connectivity_net1" data-x="3.651" data-y="-2.391" x="579.6437659033079" y="461.0687022900763" width="20.356234096692106" height="48.85496183206112" fill="#00000066" stroke="#000000" stroke-width="0.009824999999999999" />
|
|
107
|
+
</g>
|
|
108
|
+
<g>
|
|
109
|
+
<rect data-type="rect" data-label="netId: v3_3
|
|
110
|
+
globalConnNetId: connectivity_net2" data-x="-1.151" data-y="0.8010000000000002" x="90.89058524173029" y="130.0763358778625" width="20.35623409669212" height="61.068702290076374" fill="#ef444466" stroke="#ef4444" stroke-width="0.009824999999999999" />
|
|
111
|
+
</g>
|
|
112
|
+
<g id="crosshair" style="display: none">
|
|
113
|
+
<line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5" />
|
|
114
|
+
<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>
|
|
115
|
+
</g>
|
|
116
|
+
<script>
|
|
117
|
+
<![CDATA[
|
|
118
|
+
document.currentScript.parentElement.addEventListener('mousemove', (e) => {
|
|
119
|
+
const svg = e.currentTarget;
|
|
120
|
+
const rect = svg.getBoundingClientRect();
|
|
121
|
+
const x = e.clientX - rect.left;
|
|
122
|
+
const y = e.clientY - rect.top;
|
|
123
|
+
const crosshair = svg.getElementById('crosshair');
|
|
124
|
+
const h = svg.getElementById('crosshair-h');
|
|
125
|
+
const v = svg.getElementById('crosshair-v');
|
|
126
|
+
const coords = svg.getElementById('coordinates');
|
|
127
|
+
|
|
128
|
+
crosshair.style.display = 'block';
|
|
129
|
+
h.setAttribute('x1', '0');
|
|
130
|
+
h.setAttribute('x2', '640');
|
|
131
|
+
h.setAttribute('y1', y);
|
|
132
|
+
h.setAttribute('y2', y);
|
|
133
|
+
v.setAttribute('x1', x);
|
|
134
|
+
v.setAttribute('x2', x);
|
|
135
|
+
v.setAttribute('y1', '0');
|
|
136
|
+
v.setAttribute('y2', '640');
|
|
137
|
+
|
|
138
|
+
// Calculate real coordinates using inverse transformation
|
|
139
|
+
const matrix = {
|
|
140
|
+
"a": 101.78117048346057,
|
|
141
|
+
"c": 0,
|
|
142
|
+
"e": 218.21882951653947,
|
|
143
|
+
"b": 0,
|
|
144
|
+
"d": -101.78117048346057,
|
|
145
|
+
"f": 242.13740458015263
|
|
146
|
+
};
|
|
147
|
+
// Manually invert and apply the affine transform
|
|
148
|
+
// Since we only use translate and scale, we can directly compute:
|
|
149
|
+
// x' = (x - tx) / sx
|
|
150
|
+
// y' = (y - ty) / sy
|
|
151
|
+
const sx = matrix.a;
|
|
152
|
+
const sy = matrix.d;
|
|
153
|
+
const tx = matrix.e;
|
|
154
|
+
const ty = matrix.f;
|
|
155
|
+
const realPoint = {
|
|
156
|
+
x: (x - tx) / sx,
|
|
157
|
+
y: (y - ty) / sy // Flip y back since we used negative scale
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
|
|
161
|
+
coords.setAttribute('x', (x + 5).toString());
|
|
162
|
+
coords.setAttribute('y', (y - 5).toString());
|
|
163
|
+
});
|
|
164
|
+
document.currentScript.parentElement.addEventListener('mouseleave', () => {
|
|
165
|
+
document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
|
|
166
|
+
});
|
|
167
|
+
]]>
|
|
168
|
+
</script>
|
|
169
|
+
</svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { test, expect } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import inputProblem from "../assets/example43.json"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
test("example43", () => {
|
|
7
|
+
const solver = new SchematicTracePipelineSolver(inputProblem as any)
|
|
8
|
+
|
|
9
|
+
solver.solve()
|
|
10
|
+
|
|
11
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
12
|
+
})
|