@tscircuit/rectdiff 0.0.5 → 0.0.6
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.
|
@@ -190,6 +190,7 @@ export class RectDiffSolver extends BaseSolver {
|
|
|
190
190
|
|
|
191
191
|
const rects: NonNullable<GraphicsObject["rects"]> = []
|
|
192
192
|
const points: NonNullable<GraphicsObject["points"]> = []
|
|
193
|
+
const lines: NonNullable<GraphicsObject["lines"]> = [] // Initialize lines array
|
|
193
194
|
|
|
194
195
|
// Board bounds - use srj bounds which is always available
|
|
195
196
|
const boardBounds = {
|
|
@@ -199,18 +200,27 @@ export class RectDiffSolver extends BaseSolver {
|
|
|
199
200
|
maxY: this.srj.bounds.maxY,
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
// board
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
203
|
+
// board or outline
|
|
204
|
+
if (this.srj.outline && this.srj.outline.length > 1) {
|
|
205
|
+
lines.push({
|
|
206
|
+
points: [...this.srj.outline, this.srj.outline[0]!], // Close the loop by adding the first point again
|
|
207
|
+
strokeColor: "#111827",
|
|
208
|
+
strokeWidth: 0.01,
|
|
209
|
+
label: "outline",
|
|
210
|
+
})
|
|
211
|
+
} else {
|
|
212
|
+
rects.push({
|
|
213
|
+
center: {
|
|
214
|
+
x: (boardBounds.minX + boardBounds.maxX) / 2,
|
|
215
|
+
y: (boardBounds.minY + boardBounds.maxY) / 2,
|
|
216
|
+
},
|
|
217
|
+
width: boardBounds.maxX - boardBounds.minX,
|
|
218
|
+
height: boardBounds.maxY - boardBounds.minY,
|
|
219
|
+
fill: "none",
|
|
220
|
+
stroke: "#111827",
|
|
221
|
+
label: "board",
|
|
222
|
+
})
|
|
223
|
+
}
|
|
214
224
|
|
|
215
225
|
// obstacles (rect & oval as bounding boxes)
|
|
216
226
|
for (const ob of this.srj.obstacles ?? []) {
|
|
@@ -263,6 +273,7 @@ export class RectDiffSolver extends BaseSolver {
|
|
|
263
273
|
coordinateSystem: "cartesian",
|
|
264
274
|
rects,
|
|
265
275
|
points,
|
|
276
|
+
lines, // Include lines in the returned GraphicsObject
|
|
266
277
|
}
|
|
267
278
|
}
|
|
268
279
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GenericSolverDebugger } from "@tscircuit/solver-utils/react"
|
|
2
|
+
import simpleRouteJson from "../test-assets/board-with-cutout.json"
|
|
3
|
+
import { RectDiffSolver } from "../lib/solvers/RectDiffSolver"
|
|
4
|
+
import { useMemo } from "react"
|
|
5
|
+
import { SolverDebugger3d } from "../components/SolverDebugger3d"
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
const solver = useMemo(() => new RectDiffSolver({ simpleRouteJson }), [])
|
|
9
|
+
|
|
10
|
+
return <SolverDebugger3d solver={solver} />
|
|
11
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bounds": {
|
|
3
|
+
"minX": -9,
|
|
4
|
+
"maxX": 9,
|
|
5
|
+
"minY": -7,
|
|
6
|
+
"maxY": 7
|
|
7
|
+
},
|
|
8
|
+
"obstacles": [
|
|
9
|
+
{
|
|
10
|
+
"type": "rect",
|
|
11
|
+
"layers": ["top"],
|
|
12
|
+
"center": {
|
|
13
|
+
"x": -5.51,
|
|
14
|
+
"y": -4
|
|
15
|
+
},
|
|
16
|
+
"width": 0.54,
|
|
17
|
+
"height": 0.64,
|
|
18
|
+
"connectedTo": [
|
|
19
|
+
"pcb_smtpad_0",
|
|
20
|
+
"connectivity_net11",
|
|
21
|
+
"source_port_0",
|
|
22
|
+
"pcb_smtpad_0",
|
|
23
|
+
"pcb_port_0"
|
|
24
|
+
],
|
|
25
|
+
"zLayers": [0]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "rect",
|
|
29
|
+
"layers": ["top"],
|
|
30
|
+
"center": {
|
|
31
|
+
"x": -4.49,
|
|
32
|
+
"y": -4
|
|
33
|
+
},
|
|
34
|
+
"width": 0.54,
|
|
35
|
+
"height": 0.64,
|
|
36
|
+
"connectedTo": [
|
|
37
|
+
"pcb_smtpad_1",
|
|
38
|
+
"connectivity_net0",
|
|
39
|
+
"source_trace_0",
|
|
40
|
+
"source_port_1",
|
|
41
|
+
"source_port_3",
|
|
42
|
+
"pcb_smtpad_1",
|
|
43
|
+
"pcb_port_1",
|
|
44
|
+
"pcb_smtpad_3",
|
|
45
|
+
"pcb_port_3"
|
|
46
|
+
],
|
|
47
|
+
"zLayers": [0]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"type": "rect",
|
|
51
|
+
"layers": ["top"],
|
|
52
|
+
"center": {
|
|
53
|
+
"x": 4.49,
|
|
54
|
+
"y": -4
|
|
55
|
+
},
|
|
56
|
+
"width": 0.54,
|
|
57
|
+
"height": 0.64,
|
|
58
|
+
"connectedTo": [
|
|
59
|
+
"pcb_smtpad_2",
|
|
60
|
+
"connectivity_net12",
|
|
61
|
+
"source_port_2",
|
|
62
|
+
"pcb_smtpad_2",
|
|
63
|
+
"pcb_port_2"
|
|
64
|
+
],
|
|
65
|
+
"zLayers": [0]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"type": "rect",
|
|
69
|
+
"layers": ["top"],
|
|
70
|
+
"center": {
|
|
71
|
+
"x": 5.51,
|
|
72
|
+
"y": -4
|
|
73
|
+
},
|
|
74
|
+
"width": 0.54,
|
|
75
|
+
"height": 0.64,
|
|
76
|
+
"connectedTo": [
|
|
77
|
+
"pcb_smtpad_3",
|
|
78
|
+
"connectivity_net0",
|
|
79
|
+
"source_trace_0",
|
|
80
|
+
"source_port_1",
|
|
81
|
+
"source_port_3",
|
|
82
|
+
"pcb_smtpad_1",
|
|
83
|
+
"pcb_port_1",
|
|
84
|
+
"pcb_smtpad_3",
|
|
85
|
+
"pcb_port_3"
|
|
86
|
+
],
|
|
87
|
+
"zLayers": [0]
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"connections": [
|
|
91
|
+
{
|
|
92
|
+
"name": "source_trace_0",
|
|
93
|
+
"source_trace_id": "source_trace_0",
|
|
94
|
+
"pointsToConnect": [
|
|
95
|
+
{
|
|
96
|
+
"x": -4.49,
|
|
97
|
+
"y": -4,
|
|
98
|
+
"layer": "top",
|
|
99
|
+
"pointId": "pcb_port_1",
|
|
100
|
+
"pcb_port_id": "pcb_port_1"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"x": 5.51,
|
|
104
|
+
"y": -4,
|
|
105
|
+
"layer": "top",
|
|
106
|
+
"pointId": "pcb_port_3",
|
|
107
|
+
"pcb_port_id": "pcb_port_3"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"layerCount": 2,
|
|
113
|
+
"minTraceWidth": 0.15,
|
|
114
|
+
"outline": [
|
|
115
|
+
{
|
|
116
|
+
"x": -8,
|
|
117
|
+
"y": -6
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"x": -2,
|
|
121
|
+
"y": -6
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"x": -2,
|
|
125
|
+
"y": 2
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"x": 2,
|
|
129
|
+
"y": 2
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"x": 2,
|
|
133
|
+
"y": -6
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"x": 8,
|
|
137
|
+
"y": -6
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"x": 8,
|
|
141
|
+
"y": 6
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"x": -8,
|
|
145
|
+
"y": 6
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|