@tscircuit/schematic-trace-solver 0.0.41 → 0.0.43

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 (58) hide show
  1. package/dist/index.d.ts +118 -8
  2. package/dist/index.js +1067 -748
  3. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +48 -16
  4. package/lib/solvers/TraceCleanupSolver/TraceCleanupSolver.ts +133 -0
  5. package/lib/solvers/TraceCleanupSolver/balanceZShapes.ts +200 -0
  6. package/lib/solvers/{TraceLabelOverlapAvoidanceSolver → TraceCleanupSolver}/hasCollisions.ts +1 -1
  7. package/lib/solvers/{TraceLabelOverlapAvoidanceSolver → TraceCleanupSolver}/hasCollisionsWithLabels.ts +1 -1
  8. package/lib/solvers/TraceCleanupSolver/minimizeTurnsWithFilteredLabels.ts +76 -0
  9. package/lib/solvers/{TraceLabelOverlapAvoidanceSolver → TraceCleanupSolver}/simplifyPath.ts +1 -1
  10. package/lib/solvers/{TraceLabelOverlapAvoidanceSolver → TraceCleanupSolver}/turnMinimization.ts +0 -2
  11. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/TraceLabelOverlapAvoidanceSolver.ts +74 -192
  12. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/rerouteCollidingTrace.ts +13 -24
  13. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/LabelMergingSolver.ts +205 -0
  14. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/OverlapAvoidanceStepSolver/OverlapAvoidanceStepSolver.ts +144 -0
  15. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/SingleOverlapSolver/SingleOverlapSolver.ts +117 -0
  16. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/tryFourPointDetour.ts +104 -0
  17. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/trySnipAndReconnect.ts +24 -154
  18. package/package.json +1 -1
  19. package/site/examples/example26.page.tsx +4 -0
  20. package/tests/assets/1.input.json +379 -0
  21. package/tests/assets/2.input.json +330 -0
  22. package/tests/assets/3.input.json +388 -0
  23. package/tests/assets/MergedNetLabelObstacles.test.input.json +154 -0
  24. package/tests/assets/OverlapAvoidanceStepSolver.test.input.json +682 -0
  25. package/tests/assets/SingleOverlapSolver.test.input.json +170 -0
  26. package/tests/assets/TraceCleanupSolver.test.input.json +216 -0
  27. package/tests/assets/TraceLabelOverlapAvoidanceSolver.test.input.json +424 -0
  28. package/tests/assets/example26.json +1206 -0
  29. package/tests/examples/__snapshots__/example02.snap.svg +1 -1
  30. package/tests/examples/__snapshots__/example09.snap.svg +34 -34
  31. package/tests/examples/__snapshots__/example11.snap.svg +13 -13
  32. package/tests/examples/__snapshots__/example12.snap.svg +3 -3
  33. package/tests/examples/__snapshots__/example13.snap.svg +12 -12
  34. package/tests/examples/__snapshots__/example16.snap.svg +4 -4
  35. package/tests/examples/__snapshots__/example19.snap.svg +9 -9
  36. package/tests/examples/__snapshots__/example28.snap.svg +3 -3
  37. package/tests/examples/__snapshots__/example29.snap.svg +1208 -0
  38. package/tests/examples/example29.test.ts +13 -0
  39. package/tests/solvers/TraceCleanupSolver/TraceCleanupSolver.test.ts +19 -0
  40. package/tests/solvers/TraceCleanupSolver/__snapshots__/TraceCleanupSolver.snap.svg +119 -0
  41. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/TraceLabelOverlapAvoidanceSolver.test.ts +18 -0
  42. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/__snapshots__/TraceLabelOverlapAvoidanceSolver.snap.svg +243 -0
  43. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView01.snap.svg +223 -0
  44. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView02.snap.svg +205 -0
  45. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView03.snap.svg +184 -0
  46. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/renderComparisonView01.test.ts +29 -0
  47. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/renderComparisonView02.test.ts +27 -0
  48. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/renderComparisonView03.test.ts +39 -0
  49. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/MergedNetLabelObstacles.test.ts +14 -0
  50. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/OverlapAvoidanceStepSolver.test.ts +20 -0
  51. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/SingleOverlapSolver.test.ts +10 -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/lib/solvers/TraceLabelOverlapAvoidanceSolver/balanceLShapes.ts +0 -207
  56. package/lib/solvers/TraceLabelOverlapAvoidanceSolver/minimizeTurnsWithFilteredLabels.ts +0 -66
  57. /package/lib/solvers/{TraceLabelOverlapAvoidanceSolver → TraceCleanupSolver}/countTurns.ts +0 -0
  58. /package/lib/solvers/{TraceLabelOverlapAvoidanceSolver → TraceCleanupSolver}/tryConnectPoints.ts +0 -0
@@ -0,0 +1,388 @@
1
+ {
2
+ "traceCleanupSolver": {
3
+ "inputProblem": {
4
+ "chips": [
5
+ {
6
+ "chipId": "schematic_component_0",
7
+ "center": {
8
+ "x": 0,
9
+ "y": 0
10
+ },
11
+ "width": 2.4000000000000004,
12
+ "height": 1,
13
+ "pins": [
14
+ {
15
+ "pinId": "U1.1",
16
+ "x": 1.2000000000000002,
17
+ "y": -0.30000000000000004
18
+ },
19
+ {
20
+ "pinId": "U1.2",
21
+ "x": -1.2000000000000002,
22
+ "y": -0.30000000000000004
23
+ },
24
+ {
25
+ "pinId": "U1.3",
26
+ "x": 1.2000000000000002,
27
+ "y": 0.09999999999999998
28
+ },
29
+ {
30
+ "pinId": "U1.4",
31
+ "x": -1.2000000000000002,
32
+ "y": 0.30000000000000004
33
+ },
34
+ {
35
+ "pinId": "U1.5",
36
+ "x": -1.2000000000000002,
37
+ "y": 0.10000000000000003
38
+ },
39
+ {
40
+ "pinId": "U1.6",
41
+ "x": -1.2000000000000002,
42
+ "y": -0.09999999999999998
43
+ },
44
+ {
45
+ "pinId": "U1.7",
46
+ "x": 1.2000000000000002,
47
+ "y": -0.10000000000000003
48
+ },
49
+ {
50
+ "pinId": "U1.8",
51
+ "x": 1.2000000000000002,
52
+ "y": 0.30000000000000004
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ "chipId": "schematic_component_1",
58
+ "center": {
59
+ "x": 2.7,
60
+ "y": -2.095
61
+ },
62
+ "width": 2.2,
63
+ "height": 0.8,
64
+ "pins": [
65
+ {
66
+ "pinId": "J1.1",
67
+ "x": 1.6,
68
+ "y": -1.895
69
+ },
70
+ {
71
+ "pinId": "J1.2",
72
+ "x": 1.6,
73
+ "y": -2.095
74
+ },
75
+ {
76
+ "pinId": "J1.3",
77
+ "x": 1.6,
78
+ "y": -2.295
79
+ }
80
+ ]
81
+ }
82
+ ],
83
+ "directConnections": [],
84
+ "netConnections": [
85
+ {
86
+ "netId": "GND",
87
+ "pinIds": ["U1.1", "J1.3"]
88
+ },
89
+ {
90
+ "netId": "VCC",
91
+ "pinIds": ["U1.8", "J1.1"]
92
+ },
93
+ {
94
+ "netId": "MMM",
95
+ "pinIds": ["J1.2"]
96
+ }
97
+ ],
98
+ "availableNetLabelOrientations": {
99
+ "VCC": ["y-"],
100
+ "OUT": ["x-", "x+"],
101
+ "GND": ["y-"],
102
+ "MMM": ["x+", "x-"]
103
+ },
104
+ "maxMspPairDistance": 2.4
105
+ },
106
+ "allTraces": [
107
+ {
108
+ "mspPairId": "U1.1-J1.3",
109
+ "dcConnNetId": "connectivity_net0",
110
+ "globalConnNetId": "connectivity_net0",
111
+ "userNetId": "GND",
112
+ "pins": [
113
+ {
114
+ "pinId": "U1.1",
115
+ "x": 1.2000000000000002,
116
+ "y": -0.30000000000000004,
117
+ "chipId": "schematic_component_0",
118
+ "_facingDirection": "x+"
119
+ },
120
+ {
121
+ "pinId": "J1.3",
122
+ "x": 1.6,
123
+ "y": -2.295,
124
+ "chipId": "schematic_component_1",
125
+ "_facingDirection": "x-"
126
+ }
127
+ ],
128
+ "tracePath": [
129
+ {
130
+ "x": 1.2000000000000002,
131
+ "y": -0.30000000000000004
132
+ },
133
+ {
134
+ "x": 1.4000000000000001,
135
+ "y": -0.30000000000000004
136
+ },
137
+ {
138
+ "x": 1.4000000000000001,
139
+ "y": -1.6949999999999998
140
+ },
141
+ {
142
+ "x": 1.049,
143
+ "y": -1.6949999999999998
144
+ },
145
+ {
146
+ "x": 1.049,
147
+ "y": -2.2950000000000004
148
+ },
149
+ {
150
+ "x": 1.6,
151
+ "y": -2.295
152
+ }
153
+ ],
154
+ "mspConnectionPairIds": ["U1.1-J1.3"],
155
+ "pinIds": ["U1.1", "J1.3"]
156
+ }
157
+ ],
158
+ "targetTraceIds": ["U1.1-J1.3"],
159
+ "allLabelPlacements": [
160
+ {
161
+ "globalConnNetId": "connectivity_net0",
162
+ "dcConnNetId": "connectivity_net0",
163
+ "netId": "GND",
164
+ "mspConnectionPairIds": ["U1.1-J1.3"],
165
+ "pinIds": ["U1.1", "J1.3"],
166
+ "orientation": "y-",
167
+ "anchorPoint": {
168
+ "x": 1.4000000000000001,
169
+ "y": -2.295
170
+ },
171
+ "width": 0.2,
172
+ "height": 0.45,
173
+ "center": {
174
+ "x": 1.4000000000000001,
175
+ "y": -2.52
176
+ }
177
+ },
178
+ {
179
+ "globalConnNetId": "connectivity_net1",
180
+ "netId": "VCC",
181
+ "mspConnectionPairIds": [],
182
+ "pinIds": ["U1.8"],
183
+ "orientation": "x+",
184
+ "anchorPoint": {
185
+ "x": 1.2000000000000002,
186
+ "y": 0.30000000000000004
187
+ },
188
+ "width": 0.45,
189
+ "height": 0.2,
190
+ "center": {
191
+ "x": 1.4260000000000002,
192
+ "y": 0.30000000000000004
193
+ }
194
+ },
195
+ {
196
+ "globalConnNetId": "merged-group-J1-x-",
197
+ "netId": "VCC",
198
+ "mspConnectionPairIds": [],
199
+ "pinIds": ["J1.1", "J1.2"],
200
+ "orientation": "x-",
201
+ "anchorPoint": {
202
+ "x": 1.6,
203
+ "y": -1.895
204
+ },
205
+ "width": 0.4500000000000002,
206
+ "height": 0.40000000000000036,
207
+ "center": {
208
+ "x": 1.374,
209
+ "y": -1.995
210
+ }
211
+ }
212
+ ],
213
+ "mergedLabelNetIdMap": {
214
+ "merged-group-J1-x-": ["connectivity_net1", "connectivity_net2"]
215
+ },
216
+ "paddingBuffer": 0.01
217
+ },
218
+ "singleOverlapSolver": {
219
+ "trace": {
220
+ "mspPairId": "U1.1-J1.3",
221
+ "dcConnNetId": "connectivity_net0",
222
+ "globalConnNetId": "connectivity_net0",
223
+ "userNetId": "GND",
224
+ "pins": [
225
+ {
226
+ "pinId": "U1.1",
227
+ "x": 1.2000000000000002,
228
+ "y": -0.30000000000000004,
229
+ "chipId": "schematic_component_0",
230
+ "_facingDirection": "x+"
231
+ },
232
+ {
233
+ "pinId": "J1.3",
234
+ "x": 1.6,
235
+ "y": -2.295,
236
+ "chipId": "schematic_component_1",
237
+ "_facingDirection": "x-"
238
+ }
239
+ ],
240
+ "tracePath": [
241
+ {
242
+ "x": 1.2000000000000002,
243
+ "y": -0.30000000000000004
244
+ },
245
+ {
246
+ "x": 1.4000000000000001,
247
+ "y": -0.30000000000000004
248
+ },
249
+ {
250
+ "x": 1.4000000000000001,
251
+ "y": -1.2974999999999999
252
+ },
253
+ {
254
+ "x": 1.4000000000000001,
255
+ "y": -2.295
256
+ },
257
+ {
258
+ "x": 1.6,
259
+ "y": -2.295
260
+ }
261
+ ],
262
+ "mspConnectionPairIds": ["U1.1-J1.3"],
263
+ "pinIds": ["U1.1", "J1.3"]
264
+ },
265
+ "label": {
266
+ "globalConnNetId": "merged-group-J1-x-",
267
+ "netId": "VCC",
268
+ "mspConnectionPairIds": [],
269
+ "pinIds": ["J1.1", "J1.2"],
270
+ "orientation": "x-",
271
+ "anchorPoint": {
272
+ "x": 1.6,
273
+ "y": -1.895
274
+ },
275
+ "width": 0.4500000000000002,
276
+ "height": 0.40000000000000036,
277
+ "center": {
278
+ "x": 1.374,
279
+ "y": -1.995
280
+ }
281
+ },
282
+ "problem": {
283
+ "chips": [
284
+ {
285
+ "chipId": "schematic_component_0",
286
+ "center": {
287
+ "x": 0,
288
+ "y": 0
289
+ },
290
+ "width": 2.4000000000000004,
291
+ "height": 1,
292
+ "pins": [
293
+ {
294
+ "pinId": "U1.1",
295
+ "x": 1.2000000000000002,
296
+ "y": -0.30000000000000004
297
+ },
298
+ {
299
+ "pinId": "U1.2",
300
+ "x": -1.2000000000000002,
301
+ "y": -0.30000000000000004
302
+ },
303
+ {
304
+ "pinId": "U1.3",
305
+ "x": 1.2000000000000002,
306
+ "y": 0.09999999999999998
307
+ },
308
+ {
309
+ "pinId": "U1.4",
310
+ "x": -1.2000000000000002,
311
+ "y": 0.30000000000000004
312
+ },
313
+ {
314
+ "pinId": "U1.5",
315
+ "x": -1.2000000000000002,
316
+ "y": 0.10000000000000003
317
+ },
318
+ {
319
+ "pinId": "U1.6",
320
+ "x": -1.2000000000000002,
321
+ "y": -0.09999999999999998
322
+ },
323
+ {
324
+ "pinId": "U1.7",
325
+ "x": 1.2000000000000002,
326
+ "y": -0.10000000000000003
327
+ },
328
+ {
329
+ "pinId": "U1.8",
330
+ "x": 1.2000000000000002,
331
+ "y": 0.30000000000000004
332
+ }
333
+ ]
334
+ },
335
+ {
336
+ "chipId": "schematic_component_1",
337
+ "center": {
338
+ "x": 2.7,
339
+ "y": -2.095
340
+ },
341
+ "width": 2.2,
342
+ "height": 0.8,
343
+ "pins": [
344
+ {
345
+ "pinId": "J1.1",
346
+ "x": 1.6,
347
+ "y": -1.895
348
+ },
349
+ {
350
+ "pinId": "J1.2",
351
+ "x": 1.6,
352
+ "y": -2.095
353
+ },
354
+ {
355
+ "pinId": "J1.3",
356
+ "x": 1.6,
357
+ "y": -2.295
358
+ }
359
+ ]
360
+ }
361
+ ],
362
+ "directConnections": [],
363
+ "netConnections": [
364
+ {
365
+ "netId": "GND",
366
+ "pinIds": ["U1.1", "J1.3"]
367
+ },
368
+ {
369
+ "netId": "VCC",
370
+ "pinIds": ["U1.8", "J1.1"]
371
+ },
372
+ {
373
+ "netId": "MMM",
374
+ "pinIds": ["J1.2"]
375
+ }
376
+ ],
377
+ "availableNetLabelOrientations": {
378
+ "VCC": ["y-"],
379
+ "OUT": ["x-", "x+"],
380
+ "GND": ["y-"],
381
+ "MMM": ["x+", "x-"]
382
+ },
383
+ "maxMspPairDistance": 2.4
384
+ },
385
+ "paddingBuffer": 0.1,
386
+ "detourCount": 0
387
+ }
388
+ }
@@ -0,0 +1,154 @@
1
+ {
2
+ "netLabelPlacements": [
3
+ {
4
+ "globalConnNetId": "connectivity_net0",
5
+ "dcConnNetId": "connectivity_net0",
6
+ "netId": "GND",
7
+ "mspConnectionPairIds": ["U1.1-J1.3"],
8
+ "pinIds": ["U1.1", "J1.3"],
9
+ "orientation": "y-",
10
+ "anchorPoint": { "x": 1.4000000000000001, "y": -2.295 },
11
+ "width": 0.2,
12
+ "height": 0.45,
13
+ "center": { "x": 1.4000000000000001, "y": -2.52 }
14
+ },
15
+ {
16
+ "globalConnNetId": "connectivity_net1",
17
+ "netId": "VCC",
18
+ "mspConnectionPairIds": [],
19
+ "pinIds": ["U1.8"],
20
+ "orientation": "x+",
21
+ "anchorPoint": { "x": 1.2000000000000002, "y": 0.30000000000000004 },
22
+ "width": 0.45,
23
+ "height": 0.2,
24
+ "center": { "x": 1.4260000000000002, "y": 0.30000000000000004 }
25
+ },
26
+ {
27
+ "globalConnNetId": "connectivity_net1",
28
+ "netId": "VCC",
29
+ "mspConnectionPairIds": [],
30
+ "pinIds": ["J1.1"],
31
+ "orientation": "x-",
32
+ "anchorPoint": { "x": 1.6, "y": -1.895 },
33
+ "width": 0.45,
34
+ "height": 0.2,
35
+ "center": { "x": 1.374, "y": -1.895 }
36
+ },
37
+ {
38
+ "globalConnNetId": "connectivity_net2",
39
+ "netId": "MMM",
40
+ "mspConnectionPairIds": [],
41
+ "pinIds": ["J1.2"],
42
+ "orientation": "x-",
43
+ "anchorPoint": { "x": 1.6, "y": -2.095 },
44
+ "width": 0.45,
45
+ "height": 0.2,
46
+ "center": { "x": 1.374, "y": -2.095 }
47
+ }
48
+ ],
49
+ "inputProblem": {
50
+ "chips": [
51
+ {
52
+ "chipId": "schematic_component_0",
53
+ "center": { "x": 0, "y": 0 },
54
+ "width": 2.4000000000000004,
55
+ "height": 1,
56
+ "pins": [
57
+ {
58
+ "pinId": "U1.1",
59
+ "x": 1.2000000000000002,
60
+ "y": -0.30000000000000004
61
+ },
62
+ {
63
+ "pinId": "U1.2",
64
+ "x": -1.2000000000000002,
65
+ "y": -0.30000000000000004
66
+ },
67
+ {
68
+ "pinId": "U1.3",
69
+ "x": 1.2000000000000002,
70
+ "y": 0.09999999999999998
71
+ },
72
+ {
73
+ "pinId": "U1.4",
74
+ "x": -1.2000000000000002,
75
+ "y": 0.30000000000000004
76
+ },
77
+ {
78
+ "pinId": "U1.5",
79
+ "x": -1.2000000000000002,
80
+ "y": 0.10000000000000003
81
+ },
82
+ {
83
+ "pinId": "U1.6",
84
+ "x": -1.2000000000000002,
85
+ "y": -0.09999999999999998
86
+ },
87
+ {
88
+ "pinId": "U1.7",
89
+ "x": 1.2000000000000002,
90
+ "y": -0.10000000000000003
91
+ },
92
+ { "pinId": "U1.8", "x": 1.2000000000000002, "y": 0.30000000000000004 }
93
+ ]
94
+ },
95
+ {
96
+ "chipId": "schematic_component_1",
97
+ "center": { "x": 2.7, "y": -2.095 },
98
+ "width": 2.2,
99
+ "height": 0.8,
100
+ "pins": [
101
+ { "pinId": "J1.1", "x": 1.6, "y": -1.895 },
102
+ { "pinId": "J1.2", "x": 1.6, "y": -2.095 },
103
+ { "pinId": "J1.3", "x": 1.6, "y": -2.295 }
104
+ ]
105
+ }
106
+ ],
107
+ "directConnections": [],
108
+ "netConnections": [
109
+ { "netId": "GND", "pinIds": ["U1.1", "J1.3"] },
110
+ { "netId": "VCC", "pinIds": ["U1.8", "J1.1"] },
111
+ { "netId": "MMM", "pinIds": ["J1.2"] }
112
+ ],
113
+ "availableNetLabelOrientations": {
114
+ "VCC": ["y-"],
115
+ "OUT": ["x-", "x+"],
116
+ "GND": ["y-"],
117
+ "MMM": ["x+", "x-"]
118
+ },
119
+ "maxMspPairDistance": 2.4
120
+ },
121
+ "traces": [
122
+ {
123
+ "mspPairId": "U1.1-J1.3",
124
+ "dcConnNetId": "connectivity_net0",
125
+ "globalConnNetId": "connectivity_net0",
126
+ "userNetId": "GND",
127
+ "pins": [
128
+ {
129
+ "pinId": "U1.1",
130
+ "x": 1.2000000000000002,
131
+ "y": -0.30000000000000004,
132
+ "chipId": "schematic_component_0",
133
+ "_facingDirection": "x+"
134
+ },
135
+ {
136
+ "pinId": "J1.3",
137
+ "x": 1.6,
138
+ "y": -2.295,
139
+ "chipId": "schematic_component_1",
140
+ "_facingDirection": "x-"
141
+ }
142
+ ],
143
+ "tracePath": [
144
+ { "x": 1.2000000000000002, "y": -0.30000000000000004 },
145
+ { "x": 1.4000000000000001, "y": -0.30000000000000004 },
146
+ { "x": 1.4000000000000001, "y": -1.2974999999999999 },
147
+ { "x": 1.4000000000000001, "y": -2.295 },
148
+ { "x": 1.6, "y": -2.295 }
149
+ ],
150
+ "mspConnectionPairIds": ["U1.1-J1.3"],
151
+ "pinIds": ["U1.1", "J1.3"]
152
+ }
153
+ ]
154
+ }