circuit-json-to-lbrn 0.0.20 → 0.0.22
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 +1 -0
- package/dist/index.js +784 -345
- package/lib/ConvertContext.ts +6 -2
- package/lib/element-handlers/addPcbCutout/addCirclePcbCutout.ts +10 -2
- package/lib/element-handlers/addPcbCutout/addPolygonPcbCutout.ts +10 -6
- package/lib/element-handlers/addPcbCutout/addRectPcbCutout.ts +12 -12
- package/lib/element-handlers/addPcbHole/addCirclePcbHole.ts +10 -2
- package/lib/element-handlers/addPcbHole/addOvalPcbHole.ts +8 -8
- package/lib/element-handlers/addPcbHole/addPillPcbHole.ts +8 -8
- package/lib/element-handlers/addPcbHole/addRectPcbHole.ts +10 -10
- package/lib/element-handlers/addPcbHole/addRotatedPillPcbHole.ts +8 -8
- package/lib/element-handlers/addPcbTrace/index.ts +145 -61
- package/lib/element-handlers/addPcbVia/index.ts +49 -15
- package/lib/element-handlers/addPlatedHole/addCirclePlatedHole.ts +49 -15
- package/lib/element-handlers/addPlatedHole/addCircularHoleWithRectPad.ts +38 -18
- package/lib/element-handlers/addPlatedHole/addHoleWithPolygonPad.ts +41 -16
- package/lib/element-handlers/addPlatedHole/addOvalPlatedHole.ts +39 -18
- package/lib/element-handlers/addPlatedHole/addPillHoleWithRectPad.ts +38 -23
- package/lib/element-handlers/addPlatedHole/addPillPlatedHole.ts +39 -18
- package/lib/element-handlers/addPlatedHole/addRotatedPillHoleWithRectPad.ts +43 -28
- package/lib/element-handlers/addSmtPad/addCircleSmtPad.ts +31 -4
- package/lib/element-handlers/addSmtPad/addPillSmtPad.ts +33 -4
- package/lib/element-handlers/addSmtPad/addPolygonSmtPad.ts +25 -3
- package/lib/element-handlers/addSmtPad/addRectSmtPad.ts +20 -3
- package/lib/element-handlers/addSmtPad/addRotatedPillSmtPad.ts +31 -12
- package/lib/element-handlers/addSmtPad/addRotatedRectSmtPad.ts +31 -12
- package/lib/helpers/circleShape.ts +13 -6
- package/lib/helpers/ovalShape.ts +17 -8
- package/lib/helpers/pathPointUtils.ts +11 -5
- package/lib/helpers/pillShape.ts +24 -11
- package/lib/helpers/polygonShape.ts +11 -5
- package/lib/helpers/roundedRectShape.ts +19 -9
- package/lib/index.ts +92 -41
- package/package.json +1 -1
- package/tests/assets/keyboard-default60.json +92565 -0
- package/tests/examples/__snapshots__/board-outline-soldermask-preset.snap.svg +1 -1
- package/tests/examples/__snapshots__/board-outline.snap.svg +1 -1
- package/tests/examples/__snapshots__/lga-interconnect.snap.svg +1 -1
- package/tests/examples/__snapshots__/single-trace.snap.svg +1 -1
- package/tests/examples/addPcbCutout/__snapshots__/pcb-cutout-circle.snap.svg +1 -1
- package/tests/examples/addPcbCutout/__snapshots__/pcb-cutout-path.snap.svg +1 -1
- package/tests/examples/addPcbCutout/__snapshots__/pcb-cutout-polygon.snap.svg +1 -1
- package/tests/examples/addPcbCutout/__snapshots__/pcb-cutout-rect.snap.svg +1 -1
- package/tests/examples/addPcbHole/__snapshots__/pcb-hole-circle.snap.svg +1 -1
- package/tests/examples/addPcbHole/__snapshots__/pcb-hole-oval.snap.svg +1 -1
- package/tests/examples/addPcbHole/__snapshots__/pcb-hole-pill.snap.svg +1 -1
- package/tests/examples/addPcbHole/__snapshots__/pcb-hole-rect.snap.svg +1 -1
- package/tests/examples/addPcbHole/__snapshots__/pcb-hole-rotated-pill.snap.svg +2 -2
- package/tests/examples/addPcbHole/__snapshots__/pcb-hole-with-soldermask.snap.svg +1 -1
- package/tests/examples/addPcbVia/__snapshots__/pcb-via-basic.snap.svg +1 -1
- package/tests/examples/addPcbVia/__snapshots__/pcb-via-with-net.snap.svg +1 -1
- package/tests/examples/addPcbVia/__snapshots__/pcb-via-with-soldermask.snap.svg +1 -1
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-circle.snap.svg +1 -1
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-circular-hole-with-rect-pad.snap.svg +1 -1
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-oval.snap.svg +1 -1
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-pill-with-rect-pad.snap.svg +1 -1
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-pill.snap.svg +1 -1
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-polygon.snap.svg +1 -1
- package/tests/examples/addPlatedHole/__snapshots__/pcb-plated-hole-rotated-pill-with-rect-pad.snap.svg +1 -1
- package/tests/examples/addSmtPad/__snapshots__/circleSmtPad.snap.svg +1 -1
- package/tests/examples/addSmtPad/__snapshots__/pillSmtPad.snap.svg +1 -1
- package/tests/examples/addSmtPad/__snapshots__/polygonSmtPad.snap.svg +1 -1
- package/tests/examples/addSmtPad/__snapshots__/rotatedPillSmtPad.snap.svg +1 -1
- package/tests/examples/addSmtPad/__snapshots__/rotatedRectSmtPad.snap.svg +1 -1
- package/tests/examples/keyboard-defaul60/__snapshots__/keyboard-both-layer-includeSoldermask.snap.svg +8 -0
- package/tests/examples/keyboard-defaul60/__snapshots__/keyboard-both-layers.snap.svg +8 -0
- package/tests/examples/keyboard-defaul60/__snapshots__/keyboard-bottom-layer.snap.svg +8 -0
- package/tests/examples/keyboard-defaul60/__snapshots__/keyboard-top-layer.snap.svg +8 -0
- package/tests/examples/keyboard-defaul60/keyboard-both-layer-includeSoldermask.test.ts +27 -0
- package/tests/examples/keyboard-defaul60/keyboard-both-layers.test.ts +26 -0
- package/tests/examples/keyboard-defaul60/keyboard-bottom-layer.test.ts +26 -0
- package/tests/examples/keyboard-defaul60/keyboard-top-layer.test.ts +26 -0
- package/tests/examples/lga-interconnect.test.ts +3 -2
- package/tests/examples/soldermask/__snapshots__/copper-and-soldermask.snap.svg +1 -1
- package/tests/examples/soldermask/__snapshots__/copper-only.snap.svg +1 -1
- package/tests/examples/soldermask/__snapshots__/soldermask-only.snap.svg +1 -1
- package/tests/examples/soldermask/copper-and-soldermask.test.ts +18 -10
- package/tests/examples/soldermask/soldermask-only.test.ts +3 -3
- package/tests/examples/soldermask-margin/__snapshots__/negative-soldermask-margin.snap.svg +1 -1
- package/tests/examples/soldermask-margin/__snapshots__/positive-soldermask-margin.snap.svg +1 -1
- package/tsconfig.json +2 -1
|
@@ -12,15 +12,25 @@ export interface RoundedRectPath {
|
|
|
12
12
|
prims: Prim[]
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
centerX: number
|
|
17
|
-
centerY: number
|
|
18
|
-
width: number
|
|
19
|
-
height: number
|
|
20
|
-
borderRadius
|
|
21
|
-
segments
|
|
22
|
-
rotation
|
|
23
|
-
|
|
15
|
+
export interface CreateRoundedRectPathParams {
|
|
16
|
+
centerX: number
|
|
17
|
+
centerY: number
|
|
18
|
+
width: number
|
|
19
|
+
height: number
|
|
20
|
+
borderRadius?: number
|
|
21
|
+
segments?: number
|
|
22
|
+
rotation?: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const createRoundedRectPath = ({
|
|
26
|
+
centerX,
|
|
27
|
+
centerY,
|
|
28
|
+
width,
|
|
29
|
+
height,
|
|
30
|
+
borderRadius = 0,
|
|
31
|
+
segments = 4,
|
|
32
|
+
rotation = 0,
|
|
33
|
+
}: CreateRoundedRectPathParams): RoundedRectPath => {
|
|
24
34
|
const verts: Point[] = []
|
|
25
35
|
const prims: Prim[] = []
|
|
26
36
|
const halfWidth = width / 2
|
package/lib/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export const convertCircuitJsonToLbrn = (
|
|
|
27
27
|
includeCopper?: boolean
|
|
28
28
|
includeSoldermask?: boolean
|
|
29
29
|
soldermaskMargin?: number
|
|
30
|
+
includeLayers?: Array<"top" | "bottom">
|
|
30
31
|
} = {},
|
|
31
32
|
): LightBurnProject => {
|
|
32
33
|
const db = cju(circuitJson)
|
|
@@ -35,16 +36,27 @@ export const convertCircuitJsonToLbrn = (
|
|
|
35
36
|
formatVersion: "1",
|
|
36
37
|
})
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
// Default to all layers if not specified
|
|
40
|
+
const includeLayers = options.includeLayers ?? ["top", "bottom"]
|
|
41
|
+
|
|
42
|
+
const topCopperCutSetting = new CutSetting({
|
|
39
43
|
index: 0,
|
|
40
|
-
name: "Cut Copper",
|
|
44
|
+
name: "Cut Top Copper",
|
|
41
45
|
numPasses: 12,
|
|
42
46
|
speed: 100,
|
|
43
47
|
})
|
|
44
|
-
project.children.push(
|
|
48
|
+
project.children.push(topCopperCutSetting)
|
|
45
49
|
|
|
46
|
-
const
|
|
50
|
+
const bottomCopperCutSetting = new CutSetting({
|
|
47
51
|
index: 1,
|
|
52
|
+
name: "Cut Bottom Copper",
|
|
53
|
+
numPasses: 12,
|
|
54
|
+
speed: 100,
|
|
55
|
+
})
|
|
56
|
+
project.children.push(bottomCopperCutSetting)
|
|
57
|
+
|
|
58
|
+
const throughBoardCutSetting = new CutSetting({
|
|
59
|
+
index: 2,
|
|
48
60
|
name: "Cut Through Board",
|
|
49
61
|
numPasses: 3,
|
|
50
62
|
speed: 50,
|
|
@@ -52,14 +64,14 @@ export const convertCircuitJsonToLbrn = (
|
|
|
52
64
|
project.children.push(throughBoardCutSetting)
|
|
53
65
|
|
|
54
66
|
const soldermaskCutSetting = new CutSetting({
|
|
55
|
-
type: "Scan", // Use Scan mode to fill
|
|
56
|
-
index:
|
|
67
|
+
type: "Scan", // Use Scan mode to fill pad shapes for Kapton tape cutting
|
|
68
|
+
index: 3,
|
|
57
69
|
name: "Cut Soldermask",
|
|
58
70
|
numPasses: 1,
|
|
59
71
|
speed: 150,
|
|
60
72
|
scanOpt: "individual", // Scan each shape individually
|
|
61
73
|
interval: 0.18, // Distance between cross-hatch lines
|
|
62
|
-
angle: 45, // Angle of
|
|
74
|
+
angle: 45, // Angle of cross-hatch lines
|
|
63
75
|
crossHatch: true,
|
|
64
76
|
})
|
|
65
77
|
project.children.push(soldermaskCutSetting)
|
|
@@ -76,19 +88,23 @@ export const convertCircuitJsonToLbrn = (
|
|
|
76
88
|
const ctx: ConvertContext = {
|
|
77
89
|
db,
|
|
78
90
|
project,
|
|
79
|
-
|
|
91
|
+
topCopperCutSetting,
|
|
92
|
+
bottomCopperCutSetting,
|
|
80
93
|
throughBoardCutSetting,
|
|
81
94
|
soldermaskCutSetting,
|
|
82
95
|
connMap,
|
|
83
|
-
|
|
96
|
+
topNetGeoms: new Map(),
|
|
97
|
+
bottomNetGeoms: new Map(),
|
|
84
98
|
origin,
|
|
85
99
|
includeCopper: options.includeCopper ?? true,
|
|
86
100
|
includeSoldermask: options.includeSoldermask ?? false,
|
|
87
101
|
soldermaskMargin: options.soldermaskMargin ?? 0,
|
|
102
|
+
includeLayers,
|
|
88
103
|
}
|
|
89
104
|
|
|
90
105
|
for (const net of Object.keys(connMap.netMap)) {
|
|
91
|
-
ctx.
|
|
106
|
+
ctx.topNetGeoms.set(net, [])
|
|
107
|
+
ctx.bottomNetGeoms.set(net, [])
|
|
92
108
|
}
|
|
93
109
|
|
|
94
110
|
for (const smtpad of db.pcb_smtpad.list()) {
|
|
@@ -149,42 +165,77 @@ export const convertCircuitJsonToLbrn = (
|
|
|
149
165
|
// Create a union of all the net geoms, and add to project
|
|
150
166
|
// Only do this when including copper
|
|
151
167
|
if (ctx.includeCopper) {
|
|
152
|
-
|
|
153
|
-
|
|
168
|
+
// Process top layer
|
|
169
|
+
if (includeLayers.includes("top")) {
|
|
170
|
+
for (const net of Object.keys(connMap.netMap)) {
|
|
171
|
+
const netGeoms = ctx.topNetGeoms.get(net)!
|
|
154
172
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
173
|
+
if (netGeoms.length === 0) {
|
|
174
|
+
continue
|
|
175
|
+
}
|
|
158
176
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
let union = netGeoms[0]!
|
|
178
|
+
if (union instanceof Box) {
|
|
179
|
+
union = new Polygon(union)
|
|
180
|
+
}
|
|
181
|
+
for (const geom of netGeoms.slice(1)) {
|
|
182
|
+
if (geom instanceof Polygon) {
|
|
183
|
+
union = BooleanOperations.unify(union, geom)
|
|
184
|
+
} else if (geom instanceof Box) {
|
|
185
|
+
union = BooleanOperations.unify(union, new Polygon(geom))
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
for (const island of union.splitToIslands()) {
|
|
190
|
+
// Convert the polygon to verts and prims
|
|
191
|
+
const { verts, prims } = polygonToShapePathData(island)
|
|
192
|
+
|
|
193
|
+
project.children.push(
|
|
194
|
+
new ShapePath({
|
|
195
|
+
cutIndex: topCopperCutSetting.index,
|
|
196
|
+
verts,
|
|
197
|
+
prims,
|
|
198
|
+
isClosed: false,
|
|
199
|
+
}),
|
|
200
|
+
)
|
|
168
201
|
}
|
|
169
202
|
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Process bottom layer
|
|
206
|
+
if (includeLayers.includes("bottom")) {
|
|
207
|
+
for (const net of Object.keys(connMap.netMap)) {
|
|
208
|
+
const netGeoms = ctx.bottomNetGeoms.get(net)!
|
|
170
209
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
)
|
|
210
|
+
if (netGeoms.length === 0) {
|
|
211
|
+
continue
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
let union = netGeoms[0]!
|
|
215
|
+
if (union instanceof Box) {
|
|
216
|
+
union = new Polygon(union)
|
|
217
|
+
}
|
|
218
|
+
for (const geom of netGeoms.slice(1)) {
|
|
219
|
+
if (geom instanceof Polygon) {
|
|
220
|
+
union = BooleanOperations.unify(union, geom)
|
|
221
|
+
} else if (geom instanceof Box) {
|
|
222
|
+
union = BooleanOperations.unify(union, new Polygon(geom))
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (const island of union.splitToIslands()) {
|
|
227
|
+
// Convert the polygon to verts and prims
|
|
228
|
+
const { verts, prims } = polygonToShapePathData(island)
|
|
229
|
+
|
|
230
|
+
project.children.push(
|
|
231
|
+
new ShapePath({
|
|
232
|
+
cutIndex: bottomCopperCutSetting.index,
|
|
233
|
+
verts,
|
|
234
|
+
prims,
|
|
235
|
+
isClosed: false,
|
|
236
|
+
}),
|
|
237
|
+
)
|
|
238
|
+
}
|
|
188
239
|
}
|
|
189
240
|
}
|
|
190
241
|
}
|