@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,134 @@
|
|
|
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: 1, // Moved down so component body doesn't block horizontal traces
|
|
90
|
+
},
|
|
91
|
+
width: 1,
|
|
92
|
+
height: 1,
|
|
93
|
+
pins: [
|
|
94
|
+
{
|
|
95
|
+
pinId: "U2.3",
|
|
96
|
+
x: -0.4,
|
|
97
|
+
y: 0.5, // Bottom pin
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
pinId: "U2.4",
|
|
101
|
+
x: 0.4,
|
|
102
|
+
y: 0.5,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
directConnections: [],
|
|
108
|
+
netConnections: [
|
|
109
|
+
{
|
|
110
|
+
netId: "SIGNAL1",
|
|
111
|
+
pinIds: ["U2.3"],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
netId: "SIGNAL2",
|
|
115
|
+
pinIds: ["U2.4"],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
netId: "SSH",
|
|
119
|
+
pinIds: ["U1.1", "J1.3"],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
netId: "BHH",
|
|
123
|
+
pinIds: ["J1.1", "U1.3"],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
availableNetLabelOrientations: {},
|
|
127
|
+
maxMspPairDistance: 6.5,
|
|
128
|
+
} as InputProblem
|
|
129
|
+
|
|
130
|
+
test("example26", () => {
|
|
131
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
132
|
+
solver.solve()
|
|
133
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
134
|
+
})
|