@tscircuit/schematic-trace-solver 0.0.40 → 0.0.42

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 (57) hide show
  1. package/dist/index.d.ts +155 -9
  2. package/dist/index.js +998 -479
  3. package/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts +238 -0
  4. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +61 -26
  5. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/TraceLabelOverlapAvoidanceSolver.ts +94 -192
  6. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/rerouteCollidingTrace.ts +13 -24
  7. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/LabelMergingSolver.ts +205 -0
  8. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/OverlapAvoidanceStepSolver/OverlapAvoidanceStepSolver.ts +144 -0
  9. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/SingleOverlapSolver/SingleOverlapSolver.ts +117 -0
  10. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/TraceCleanupSolver/TraceCleanupSolver.ts +132 -0
  11. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/{balanceLShapes.ts → sub-solvers/TraceCleanupSolver/balanceLShapes.ts} +12 -10
  12. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/{hasCollisions.ts → sub-solvers/TraceCleanupSolver/hasCollisions.ts} +1 -1
  13. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/{hasCollisionsWithLabels.ts → sub-solvers/TraceCleanupSolver/hasCollisionsWithLabels.ts} +1 -1
  14. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/{minimizeTurnsWithFilteredLabels.ts → sub-solvers/TraceCleanupSolver/minimizeTurnsWithFilteredLabels.ts} +6 -6
  15. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/{simplifyPath.ts → sub-solvers/TraceCleanupSolver/simplifyPath.ts} +1 -1
  16. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/{turnMinimization.ts → sub-solvers/TraceCleanupSolver/turnMinimization.ts} +0 -2
  17. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/tryFourPointDetour.ts +104 -0
  18. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/trySnipAndReconnect.ts +24 -154
  19. package/lib/utils/does-trace-overlap-with-existing-traces.ts +33 -0
  20. package/package.json +1 -1
  21. package/site/examples/example25.page.tsx +4 -0
  22. package/tests/assets/1.input.json +379 -0
  23. package/tests/assets/2.input.json +330 -0
  24. package/tests/assets/3.input.json +388 -0
  25. package/tests/assets/MergedNetLabelObstacles.test.input.json +154 -0
  26. package/tests/assets/OverlapAvoidanceStepSolver.test.input.json +682 -0
  27. package/tests/assets/SingleOverlapSolver.test.input.json +170 -0
  28. package/tests/assets/TraceCleanupSolver.test.input.json +216 -0
  29. package/tests/assets/TraceLabelOverlapAvoidanceSolver.test.input.json +424 -0
  30. package/tests/assets/example25.json +96 -0
  31. package/tests/examples/__snapshots__/example03.snap.svg +67 -76
  32. package/tests/examples/__snapshots__/example10.snap.svg +24 -30
  33. package/tests/examples/__snapshots__/example13.snap.svg +81 -84
  34. package/tests/examples/__snapshots__/example15.snap.svg +5 -8
  35. package/tests/examples/__snapshots__/example21.snap.svg +68 -74
  36. package/tests/examples/__snapshots__/example25.snap.svg +3 -3
  37. package/tests/examples/__snapshots__/example26.snap.svg +3 -3
  38. package/tests/examples/__snapshots__/example28.snap.svg +273 -0
  39. package/tests/examples/example28.test.ts +13 -0
  40. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/TraceLabelOverlapAvoidanceSolver.test.ts +18 -0
  41. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/__snapshots__/TraceLabelOverlapAvoidanceSolver.snap.svg +243 -0
  42. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView01.snap.svg +223 -0
  43. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView02.snap.svg +205 -0
  44. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView03.snap.svg +184 -0
  45. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/renderComparisonView01.test.ts +29 -0
  46. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/renderComparisonView02.test.ts +27 -0
  47. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/renderComparisonView03.test.ts +39 -0
  48. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/MergedNetLabelObstacles.test.ts +14 -0
  49. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/OverlapAvoidanceStepSolver.test.ts +20 -0
  50. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/SingleOverlapSolver.test.ts +10 -0
  51. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/TraceCleanupSolver.test.ts +19 -0
  52. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/MergedNetLabelObstacles.snap.svg +140 -0
  53. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/OverlapAvoidanceStepSolver.snap.svg +216 -0
  54. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/SingleOverlapSolver.snap.svg +125 -0
  55. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/TraceCleanupSolver.snap.svg +119 -0
  56. /package/lib/solvers/TraceLabelOverlapAvoidanceSolver/{countTurns.ts → sub-solvers/TraceCleanupSolver/countTurns.ts} +0 -0
  57. /package/lib/solvers/TraceLabelOverlapAvoidanceSolver/{tryConnectPoints.ts → sub-solvers/TraceCleanupSolver/tryConnectPoints.ts} +0 -0
@@ -0,0 +1,170 @@
1
+ {
2
+ "trace": {
3
+ "mspPairId": "U1.1-J1.3",
4
+ "dcConnNetId": "connectivity_net0",
5
+ "globalConnNetId": "connectivity_net0",
6
+ "userNetId": "GND",
7
+ "pins": [
8
+ {
9
+ "pinId": "U1.1",
10
+ "x": 1.2000000000000002,
11
+ "y": -0.30000000000000004,
12
+ "chipId": "schematic_component_0",
13
+ "_facingDirection": "x+"
14
+ },
15
+ {
16
+ "pinId": "J1.3",
17
+ "x": 1.6,
18
+ "y": -2.295,
19
+ "chipId": "schematic_component_1",
20
+ "_facingDirection": "x-"
21
+ }
22
+ ],
23
+ "tracePath": [
24
+ {
25
+ "x": 1.2000000000000002,
26
+ "y": -0.30000000000000004
27
+ },
28
+ {
29
+ "x": 1.4000000000000001,
30
+ "y": -0.30000000000000004
31
+ },
32
+ {
33
+ "x": 1.4000000000000001,
34
+ "y": -1.2974999999999999
35
+ },
36
+ {
37
+ "x": 1.4000000000000001,
38
+ "y": -2.295
39
+ },
40
+ {
41
+ "x": 1.6,
42
+ "y": -2.295
43
+ }
44
+ ],
45
+ "mspConnectionPairIds": ["U1.1-J1.3"],
46
+ "pinIds": ["U1.1", "J1.3"]
47
+ },
48
+ "label": {
49
+ "globalConnNetId": "merged-group-J1-x-",
50
+ "netId": "VCC",
51
+ "mspConnectionPairIds": [],
52
+ "pinIds": ["J1.1", "J1.2"],
53
+ "orientation": "x-",
54
+ "anchorPoint": {
55
+ "x": 1.6,
56
+ "y": -1.895
57
+ },
58
+ "width": 0.4500000000000002,
59
+ "height": 0.40000000000000036,
60
+ "center": {
61
+ "x": 1.374,
62
+ "y": -1.995
63
+ }
64
+ },
65
+ "problem": {
66
+ "chips": [
67
+ {
68
+ "chipId": "schematic_component_0",
69
+ "center": {
70
+ "x": 0,
71
+ "y": 0
72
+ },
73
+ "width": 2.4000000000000004,
74
+ "height": 1,
75
+ "pins": [
76
+ {
77
+ "pinId": "U1.1",
78
+ "x": 1.2000000000000002,
79
+ "y": -0.30000000000000004
80
+ },
81
+ {
82
+ "pinId": "U1.2",
83
+ "x": -1.2000000000000002,
84
+ "y": -0.30000000000000004
85
+ },
86
+ {
87
+ "pinId": "U1.3",
88
+ "x": 1.2000000000000002,
89
+ "y": 0.09999999999999998
90
+ },
91
+ {
92
+ "pinId": "U1.4",
93
+ "x": -1.2000000000000002,
94
+ "y": 0.30000000000000004
95
+ },
96
+ {
97
+ "pinId": "U1.5",
98
+ "x": -1.2000000000000002,
99
+ "y": 0.10000000000000003
100
+ },
101
+ {
102
+ "pinId": "U1.6",
103
+ "x": -1.2000000000000002,
104
+ "y": -0.09999999999999998
105
+ },
106
+ {
107
+ "pinId": "U1.7",
108
+ "x": 1.2000000000000002,
109
+ "y": -0.10000000000000003
110
+ },
111
+ {
112
+ "pinId": "U1.8",
113
+ "x": 1.2000000000000002,
114
+ "y": 0.30000000000000004
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ "chipId": "schematic_component_1",
120
+ "center": {
121
+ "x": 2.7,
122
+ "y": -2.095
123
+ },
124
+ "width": 2.2,
125
+ "height": 0.8,
126
+ "pins": [
127
+ {
128
+ "pinId": "J1.1",
129
+ "x": 1.6,
130
+ "y": -1.895
131
+ },
132
+ {
133
+ "pinId": "J1.2",
134
+ "x": 1.6,
135
+ "y": -2.095
136
+ },
137
+ {
138
+ "pinId": "J1.3",
139
+ "x": 1.6,
140
+ "y": -2.295
141
+ }
142
+ ]
143
+ }
144
+ ],
145
+ "directConnections": [],
146
+ "netConnections": [
147
+ {
148
+ "netId": "GND",
149
+ "pinIds": ["U1.1", "J1.3"]
150
+ },
151
+ {
152
+ "netId": "VCC",
153
+ "pinIds": ["U1.8", "J1.1"]
154
+ },
155
+ {
156
+ "netId": "MMM",
157
+ "pinIds": ["J1.2"]
158
+ }
159
+ ],
160
+ "availableNetLabelOrientations": {
161
+ "VCC": ["y-"],
162
+ "OUT": ["x-", "x+"],
163
+ "GND": ["y-"],
164
+ "MMM": ["x+", "x-"]
165
+ },
166
+ "maxMspPairDistance": 2.4
167
+ },
168
+ "paddingBuffer": 0.1,
169
+ "detourCount": 0
170
+ }
@@ -0,0 +1,216 @@
1
+ {
2
+ "inputProblem": {
3
+ "chips": [
4
+ {
5
+ "chipId": "schematic_component_0",
6
+ "center": {
7
+ "x": 0,
8
+ "y": 0
9
+ },
10
+ "width": 2.4000000000000004,
11
+ "height": 1,
12
+ "pins": [
13
+ {
14
+ "pinId": "U1.1",
15
+ "x": 1.2000000000000002,
16
+ "y": -0.30000000000000004
17
+ },
18
+ {
19
+ "pinId": "U1.2",
20
+ "x": -1.2000000000000002,
21
+ "y": -0.30000000000000004
22
+ },
23
+ {
24
+ "pinId": "U1.3",
25
+ "x": 1.2000000000000002,
26
+ "y": 0.09999999999999998
27
+ },
28
+ {
29
+ "pinId": "U1.4",
30
+ "x": -1.2000000000000002,
31
+ "y": 0.30000000000000004
32
+ },
33
+ {
34
+ "pinId": "U1.5",
35
+ "x": -1.2000000000000002,
36
+ "y": 0.10000000000000003
37
+ },
38
+ {
39
+ "pinId": "U1.6",
40
+ "x": -1.2000000000000002,
41
+ "y": -0.09999999999999998
42
+ },
43
+ {
44
+ "pinId": "U1.7",
45
+ "x": 1.2000000000000002,
46
+ "y": -0.10000000000000003
47
+ },
48
+ {
49
+ "pinId": "U1.8",
50
+ "x": 1.2000000000000002,
51
+ "y": 0.30000000000000004
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "chipId": "schematic_component_1",
57
+ "center": {
58
+ "x": 2.7,
59
+ "y": -2.095
60
+ },
61
+ "width": 2.2,
62
+ "height": 0.8,
63
+ "pins": [
64
+ {
65
+ "pinId": "J1.1",
66
+ "x": 1.6,
67
+ "y": -1.895
68
+ },
69
+ {
70
+ "pinId": "J1.2",
71
+ "x": 1.6,
72
+ "y": -2.095
73
+ },
74
+ {
75
+ "pinId": "J1.3",
76
+ "x": 1.6,
77
+ "y": -2.295
78
+ }
79
+ ]
80
+ }
81
+ ],
82
+ "directConnections": [],
83
+ "netConnections": [
84
+ {
85
+ "netId": "GND",
86
+ "pinIds": ["U1.1", "J1.3"]
87
+ },
88
+ {
89
+ "netId": "VCC",
90
+ "pinIds": ["U1.8", "J1.1"]
91
+ },
92
+ {
93
+ "netId": "MMM",
94
+ "pinIds": ["J1.2"]
95
+ }
96
+ ],
97
+ "availableNetLabelOrientations": {
98
+ "VCC": ["y-"],
99
+ "OUT": ["x-", "x+"],
100
+ "GND": ["y-"],
101
+ "MMM": ["x+", "x-"]
102
+ },
103
+ "maxMspPairDistance": 2.4
104
+ },
105
+ "allTraces": [
106
+ {
107
+ "mspPairId": "U1.1-J1.3",
108
+ "dcConnNetId": "connectivity_net0",
109
+ "globalConnNetId": "connectivity_net0",
110
+ "userNetId": "GND",
111
+ "pins": [
112
+ {
113
+ "pinId": "U1.1",
114
+ "x": 1.2000000000000002,
115
+ "y": -0.30000000000000004,
116
+ "chipId": "schematic_component_0",
117
+ "_facingDirection": "x+"
118
+ },
119
+ {
120
+ "pinId": "J1.3",
121
+ "x": 1.6,
122
+ "y": -2.295,
123
+ "chipId": "schematic_component_1",
124
+ "_facingDirection": "x-"
125
+ }
126
+ ],
127
+ "tracePath": [
128
+ {
129
+ "x": 1.2000000000000002,
130
+ "y": -0.30000000000000004
131
+ },
132
+ {
133
+ "x": 1.4000000000000001,
134
+ "y": -0.30000000000000004
135
+ },
136
+ {
137
+ "x": 1.4000000000000001,
138
+ "y": -1.6949999999999998
139
+ },
140
+ {
141
+ "x": 1.049,
142
+ "y": -1.6949999999999998
143
+ },
144
+ {
145
+ "x": 1.049,
146
+ "y": -2.2950000000000004
147
+ },
148
+ {
149
+ "x": 1.6,
150
+ "y": -2.295
151
+ }
152
+ ],
153
+ "mspConnectionPairIds": ["U1.1-J1.3"],
154
+ "pinIds": ["U1.1", "J1.3"]
155
+ }
156
+ ],
157
+ "targetTraceIds": ["U1.1-J1.3"],
158
+ "allLabelPlacements": [
159
+ {
160
+ "globalConnNetId": "connectivity_net0",
161
+ "dcConnNetId": "connectivity_net0",
162
+ "netId": "GND",
163
+ "mspConnectionPairIds": ["U1.1-J1.3"],
164
+ "pinIds": ["U1.1", "J1.3"],
165
+ "orientation": "y-",
166
+ "anchorPoint": {
167
+ "x": 1.4000000000000001,
168
+ "y": -2.295
169
+ },
170
+ "width": 0.2,
171
+ "height": 0.45,
172
+ "center": {
173
+ "x": 1.4000000000000001,
174
+ "y": -2.52
175
+ }
176
+ },
177
+ {
178
+ "globalConnNetId": "connectivity_net1",
179
+ "netId": "VCC",
180
+ "mspConnectionPairIds": [],
181
+ "pinIds": ["U1.8"],
182
+ "orientation": "x+",
183
+ "anchorPoint": {
184
+ "x": 1.2000000000000002,
185
+ "y": 0.30000000000000004
186
+ },
187
+ "width": 0.45,
188
+ "height": 0.2,
189
+ "center": {
190
+ "x": 1.4260000000000002,
191
+ "y": 0.30000000000000004
192
+ }
193
+ },
194
+ {
195
+ "globalConnNetId": "merged-group-J1-x-",
196
+ "netId": "VCC",
197
+ "mspConnectionPairIds": [],
198
+ "pinIds": ["J1.1", "J1.2"],
199
+ "orientation": "x-",
200
+ "anchorPoint": {
201
+ "x": 1.6,
202
+ "y": -1.895
203
+ },
204
+ "width": 0.4500000000000002,
205
+ "height": 0.40000000000000036,
206
+ "center": {
207
+ "x": 1.374,
208
+ "y": -1.995
209
+ }
210
+ }
211
+ ],
212
+ "mergedLabelNetIdMap": {
213
+ "merged-group-J1-x-": ["connectivity_net1", "connectivity_net2"]
214
+ },
215
+ "paddingBuffer": 0.01
216
+ }