circuit-json-to-lbrn 0.0.13 → 0.0.15
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 +145 -79
- package/lib/ConvertContext.ts +3 -0
- package/lib/element-handlers/addPcbBoard/index.ts +1 -1
- package/lib/element-handlers/addPlatedHole/addCirclePlatedHole.ts +3 -2
- package/lib/element-handlers/addPlatedHole/addCircularHoleWithRectPad.ts +13 -2
- package/lib/element-handlers/addPlatedHole/addHoleWithPolygonPad.ts +3 -0
- package/lib/element-handlers/addPlatedHole/addOvalPlatedHole.ts +4 -7
- package/lib/element-handlers/addPlatedHole/addPillHoleWithRectPad.ts +13 -2
- package/lib/element-handlers/addPlatedHole/addPillPlatedHole.ts +4 -7
- package/lib/element-handlers/addPlatedHole/addRotatedPillHoleWithRectPad.ts +15 -2
- package/lib/element-handlers/addSmtPad/addCircleSmtPad.ts +3 -1
- package/lib/element-handlers/addSmtPad/addPillSmtPad.ts +7 -2
- package/lib/element-handlers/addSmtPad/addPolygonSmtPad.ts +6 -0
- package/lib/element-handlers/addSmtPad/addRectSmtPad.ts +9 -5
- package/lib/element-handlers/addSmtPad/addRotatedPillSmtPad.ts +13 -2
- package/lib/element-handlers/addSmtPad/addRotatedRectSmtPad.ts +15 -2
- package/lib/index.ts +5 -0
- package/package.json +2 -2
- package/tests/examples/__snapshots__/board-outline-soldermask-preset.snap.svg +1 -1
- package/tests/examples/soldermask/__snapshots__/copper-and-soldermask.snap.svg +1 -1
- package/tests/examples/soldermask/__snapshots__/soldermask-only.snap.svg +1 -1
- package/tests/examples/soldermask-margin/__snapshots__/negative-soldermask-margin.snap.svg +8 -0
- package/tests/examples/soldermask-margin/__snapshots__/positive-soldermask-margin.snap.svg +8 -0
- package/tests/examples/soldermask-margin/negative-soldermask-margin.test.ts +85 -0
- package/tests/examples/soldermask-margin/positive-soldermask-margin.test.ts +85 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -52,7 +52,8 @@ var addCirclePlatedHole = (platedHole, ctx) => {
|
|
|
52
52
|
origin,
|
|
53
53
|
includeCopper,
|
|
54
54
|
includeSoldermask,
|
|
55
|
-
connMap
|
|
55
|
+
connMap,
|
|
56
|
+
soldermaskMargin
|
|
56
57
|
} = ctx;
|
|
57
58
|
const centerX = platedHole.x + origin.x;
|
|
58
59
|
const centerY = platedHole.y + origin.y;
|
|
@@ -76,8 +77,8 @@ var addCirclePlatedHole = (platedHole, ctx) => {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
if (platedHole.outer_diameter > 0 && includeSoldermask) {
|
|
79
|
-
const
|
|
80
|
-
const outer = createCirclePath(centerX, centerY,
|
|
80
|
+
const smRadius = platedHole.outer_diameter / 2 + soldermaskMargin;
|
|
81
|
+
const outer = createCirclePath(centerX, centerY, smRadius);
|
|
81
82
|
project.children.push(
|
|
82
83
|
new ShapePath({
|
|
83
84
|
cutIndex: soldermaskCutSetting.index,
|
|
@@ -140,7 +141,8 @@ var addOvalPlatedHole = (platedHole, ctx) => {
|
|
|
140
141
|
throughBoardCutSetting,
|
|
141
142
|
origin,
|
|
142
143
|
includeCopper,
|
|
143
|
-
includeSoldermask
|
|
144
|
+
includeSoldermask,
|
|
145
|
+
soldermaskMargin
|
|
144
146
|
} = ctx;
|
|
145
147
|
if (platedHole.outer_width <= 0 || platedHole.outer_height <= 0) {
|
|
146
148
|
return;
|
|
@@ -166,13 +168,9 @@ var addOvalPlatedHole = (platedHole, ctx) => {
|
|
|
166
168
|
);
|
|
167
169
|
}
|
|
168
170
|
if (platedHole.outer_width > 0 && platedHole.outer_height > 0 && includeSoldermask) {
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
platedHole.outer_width,
|
|
173
|
-
platedHole.outer_height,
|
|
174
|
-
rotation
|
|
175
|
-
);
|
|
171
|
+
const smWidth = platedHole.outer_width + 2 * soldermaskMargin;
|
|
172
|
+
const smHeight = platedHole.outer_height + 2 * soldermaskMargin;
|
|
173
|
+
const outer = createOvalPath(centerX, centerY, smWidth, smHeight, rotation);
|
|
176
174
|
project.children.push(
|
|
177
175
|
new ShapePath2({
|
|
178
176
|
cutIndex: soldermaskCutSetting.index,
|
|
@@ -294,7 +292,8 @@ var addCircularHoleWithRectPad = (platedHole, ctx) => {
|
|
|
294
292
|
throughBoardCutSetting,
|
|
295
293
|
origin,
|
|
296
294
|
includeCopper,
|
|
297
|
-
includeSoldermask
|
|
295
|
+
includeSoldermask,
|
|
296
|
+
soldermaskMargin
|
|
298
297
|
} = ctx;
|
|
299
298
|
const centerX = platedHole.x + origin.x;
|
|
300
299
|
const centerY = platedHole.y + origin.y;
|
|
@@ -320,11 +319,20 @@ var addCircularHoleWithRectPad = (platedHole, ctx) => {
|
|
|
320
319
|
);
|
|
321
320
|
}
|
|
322
321
|
if (includeSoldermask) {
|
|
322
|
+
const smPadWidth = padWidth + 2 * soldermaskMargin;
|
|
323
|
+
const smPadHeight = padHeight + 2 * soldermaskMargin;
|
|
324
|
+
const smPadPath = createRoundedRectPath(
|
|
325
|
+
centerX,
|
|
326
|
+
centerY,
|
|
327
|
+
smPadWidth,
|
|
328
|
+
smPadHeight,
|
|
329
|
+
borderRadius
|
|
330
|
+
);
|
|
323
331
|
project.children.push(
|
|
324
332
|
new ShapePath3({
|
|
325
333
|
cutIndex: soldermaskCutSetting.index,
|
|
326
|
-
verts:
|
|
327
|
-
prims:
|
|
334
|
+
verts: smPadPath.verts,
|
|
335
|
+
prims: smPadPath.prims,
|
|
328
336
|
isClosed: true
|
|
329
337
|
})
|
|
330
338
|
);
|
|
@@ -435,7 +443,8 @@ var addPillHoleWithRectPad = (platedHole, ctx) => {
|
|
|
435
443
|
throughBoardCutSetting,
|
|
436
444
|
origin,
|
|
437
445
|
includeCopper,
|
|
438
|
-
includeSoldermask
|
|
446
|
+
includeSoldermask,
|
|
447
|
+
soldermaskMargin
|
|
439
448
|
} = ctx;
|
|
440
449
|
const centerX = platedHole.x + origin.x;
|
|
441
450
|
const centerY = platedHole.y + origin.y;
|
|
@@ -461,11 +470,20 @@ var addPillHoleWithRectPad = (platedHole, ctx) => {
|
|
|
461
470
|
);
|
|
462
471
|
}
|
|
463
472
|
if (includeSoldermask) {
|
|
473
|
+
const smPadWidth = padWidth + 2 * soldermaskMargin;
|
|
474
|
+
const smPadHeight = padHeight + 2 * soldermaskMargin;
|
|
475
|
+
const smPadPath = createRoundedRectPath(
|
|
476
|
+
centerX,
|
|
477
|
+
centerY,
|
|
478
|
+
smPadWidth,
|
|
479
|
+
smPadHeight,
|
|
480
|
+
borderRadius
|
|
481
|
+
);
|
|
464
482
|
project.children.push(
|
|
465
483
|
new ShapePath4({
|
|
466
484
|
cutIndex: soldermaskCutSetting.index,
|
|
467
|
-
verts:
|
|
468
|
-
prims:
|
|
485
|
+
verts: smPadPath.verts,
|
|
486
|
+
prims: smPadPath.prims,
|
|
469
487
|
isClosed: true
|
|
470
488
|
})
|
|
471
489
|
);
|
|
@@ -503,7 +521,8 @@ var addRotatedPillHoleWithRectPad = (platedHole, ctx) => {
|
|
|
503
521
|
throughBoardCutSetting,
|
|
504
522
|
origin,
|
|
505
523
|
includeCopper,
|
|
506
|
-
includeSoldermask
|
|
524
|
+
includeSoldermask,
|
|
525
|
+
soldermaskMargin
|
|
507
526
|
} = ctx;
|
|
508
527
|
const centerX = platedHole.x + origin.x;
|
|
509
528
|
const centerY = platedHole.y + origin.y;
|
|
@@ -532,11 +551,22 @@ var addRotatedPillHoleWithRectPad = (platedHole, ctx) => {
|
|
|
532
551
|
);
|
|
533
552
|
}
|
|
534
553
|
if (includeSoldermask) {
|
|
554
|
+
const smPadWidth = padWidth + 2 * soldermaskMargin;
|
|
555
|
+
const smPadHeight = padHeight + 2 * soldermaskMargin;
|
|
556
|
+
const smPadPath = createRoundedRectPath(
|
|
557
|
+
centerX,
|
|
558
|
+
centerY,
|
|
559
|
+
smPadWidth,
|
|
560
|
+
smPadHeight,
|
|
561
|
+
borderRadius,
|
|
562
|
+
4,
|
|
563
|
+
padRotation
|
|
564
|
+
);
|
|
535
565
|
project.children.push(
|
|
536
566
|
new ShapePath5({
|
|
537
567
|
cutIndex: soldermaskCutSetting.index,
|
|
538
|
-
verts:
|
|
539
|
-
prims:
|
|
568
|
+
verts: smPadPath.verts,
|
|
569
|
+
prims: smPadPath.prims,
|
|
540
570
|
isClosed: true
|
|
541
571
|
})
|
|
542
572
|
);
|
|
@@ -595,7 +625,8 @@ var addHoleWithPolygonPad = (platedHole, ctx) => {
|
|
|
595
625
|
throughBoardCutSetting,
|
|
596
626
|
origin,
|
|
597
627
|
includeCopper,
|
|
598
|
-
includeSoldermask
|
|
628
|
+
includeSoldermask,
|
|
629
|
+
soldermaskMargin
|
|
599
630
|
} = ctx;
|
|
600
631
|
if (platedHole.pad_outline.length >= 3) {
|
|
601
632
|
const pad = createPolygonPathFromOutline(
|
|
@@ -664,7 +695,8 @@ var addPcbPlatedHolePill = (platedHole, ctx) => {
|
|
|
664
695
|
throughBoardCutSetting,
|
|
665
696
|
origin,
|
|
666
697
|
includeCopper,
|
|
667
|
-
includeSoldermask
|
|
698
|
+
includeSoldermask,
|
|
699
|
+
soldermaskMargin
|
|
668
700
|
} = ctx;
|
|
669
701
|
const centerX = platedHole.x + origin.x;
|
|
670
702
|
const centerY = platedHole.y + origin.y;
|
|
@@ -687,13 +719,9 @@ var addPcbPlatedHolePill = (platedHole, ctx) => {
|
|
|
687
719
|
);
|
|
688
720
|
}
|
|
689
721
|
if (platedHole.outer_width > 0 && platedHole.outer_height > 0 && includeSoldermask) {
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
platedHole.outer_width,
|
|
694
|
-
platedHole.outer_height,
|
|
695
|
-
rotation
|
|
696
|
-
);
|
|
722
|
+
const smWidth = platedHole.outer_width + 2 * soldermaskMargin;
|
|
723
|
+
const smHeight = platedHole.outer_height + 2 * soldermaskMargin;
|
|
724
|
+
const outer = createPillPath(centerX, centerY, smWidth, smHeight, rotation);
|
|
697
725
|
project.children.push(
|
|
698
726
|
new ShapePath7({
|
|
699
727
|
cutIndex: soldermaskCutSetting.index,
|
|
@@ -757,7 +785,8 @@ var addRectSmtPad = (smtPad, ctx) => {
|
|
|
757
785
|
netGeoms,
|
|
758
786
|
origin,
|
|
759
787
|
includeCopper,
|
|
760
|
-
includeSoldermask
|
|
788
|
+
includeSoldermask,
|
|
789
|
+
soldermaskMargin
|
|
761
790
|
} = ctx;
|
|
762
791
|
const centerX = smtPad.x + origin.x;
|
|
763
792
|
const centerY = smtPad.y + origin.y;
|
|
@@ -801,12 +830,14 @@ var addRectSmtPad = (smtPad, ctx) => {
|
|
|
801
830
|
}
|
|
802
831
|
}
|
|
803
832
|
if (includeSoldermask) {
|
|
833
|
+
const smHalfWidth = halfWidth + soldermaskMargin;
|
|
834
|
+
const smHalfHeight = halfHeight + soldermaskMargin;
|
|
804
835
|
const verts = [
|
|
805
|
-
{ x: centerX -
|
|
806
|
-
{ x: centerX +
|
|
807
|
-
{ x: centerX +
|
|
808
|
-
{ x: centerX -
|
|
809
|
-
{ x: centerX -
|
|
836
|
+
{ x: centerX - smHalfWidth, y: centerY - smHalfHeight },
|
|
837
|
+
{ x: centerX + smHalfWidth, y: centerY - smHalfHeight },
|
|
838
|
+
{ x: centerX + smHalfWidth, y: centerY + smHalfHeight },
|
|
839
|
+
{ x: centerX - smHalfWidth, y: centerY + smHalfHeight },
|
|
840
|
+
{ x: centerX - smHalfWidth, y: centerY - smHalfHeight }
|
|
810
841
|
// Close the path
|
|
811
842
|
];
|
|
812
843
|
const prims = [
|
|
@@ -838,7 +869,8 @@ var addCircleSmtPad = (smtPad, ctx) => {
|
|
|
838
869
|
origin,
|
|
839
870
|
includeCopper,
|
|
840
871
|
includeSoldermask,
|
|
841
|
-
connMap
|
|
872
|
+
connMap,
|
|
873
|
+
soldermaskMargin
|
|
842
874
|
} = ctx;
|
|
843
875
|
const centerX = smtPad.x + origin.x;
|
|
844
876
|
const centerY = smtPad.y + origin.y;
|
|
@@ -863,7 +895,8 @@ var addCircleSmtPad = (smtPad, ctx) => {
|
|
|
863
895
|
}
|
|
864
896
|
}
|
|
865
897
|
if (includeSoldermask) {
|
|
866
|
-
const
|
|
898
|
+
const smRadius = outerRadius + soldermaskMargin;
|
|
899
|
+
const outer = createCirclePath(centerX, centerY, smRadius);
|
|
867
900
|
project.children.push(
|
|
868
901
|
new ShapePath9({
|
|
869
902
|
cutIndex: soldermaskCutSetting.index,
|
|
@@ -895,7 +928,8 @@ var addPillSmtPad = (smtPad, ctx) => {
|
|
|
895
928
|
origin,
|
|
896
929
|
includeCopper,
|
|
897
930
|
includeSoldermask,
|
|
898
|
-
connMap
|
|
931
|
+
connMap,
|
|
932
|
+
soldermaskMargin
|
|
899
933
|
} = ctx;
|
|
900
934
|
const centerX = smtPad.x + origin.x;
|
|
901
935
|
const centerY = smtPad.y + origin.y;
|
|
@@ -918,11 +952,14 @@ var addPillSmtPad = (smtPad, ctx) => {
|
|
|
918
952
|
}
|
|
919
953
|
}
|
|
920
954
|
if (includeSoldermask) {
|
|
955
|
+
const smWidth = smtPad.width + 2 * soldermaskMargin;
|
|
956
|
+
const smHeight = smtPad.height + 2 * soldermaskMargin;
|
|
957
|
+
const smOuter = createPillPath(centerX, centerY, smWidth, smHeight);
|
|
921
958
|
project.children.push(
|
|
922
959
|
new ShapePath10({
|
|
923
960
|
cutIndex: soldermaskCutSetting.index,
|
|
924
|
-
verts:
|
|
925
|
-
prims:
|
|
961
|
+
verts: smOuter.verts,
|
|
962
|
+
prims: smOuter.prims,
|
|
926
963
|
isClosed: true
|
|
927
964
|
})
|
|
928
965
|
);
|
|
@@ -940,7 +977,8 @@ var addRotatedPillSmtPad = (smtPad, ctx) => {
|
|
|
940
977
|
origin,
|
|
941
978
|
includeCopper,
|
|
942
979
|
includeSoldermask,
|
|
943
|
-
connMap
|
|
980
|
+
connMap,
|
|
981
|
+
soldermaskMargin
|
|
944
982
|
} = ctx;
|
|
945
983
|
const centerX = smtPad.x + origin.x;
|
|
946
984
|
const centerY = smtPad.y + origin.y;
|
|
@@ -969,11 +1007,20 @@ var addRotatedPillSmtPad = (smtPad, ctx) => {
|
|
|
969
1007
|
}
|
|
970
1008
|
}
|
|
971
1009
|
if (includeSoldermask) {
|
|
1010
|
+
const smWidth = smtPad.width + 2 * soldermaskMargin;
|
|
1011
|
+
const smHeight = smtPad.height + 2 * soldermaskMargin;
|
|
1012
|
+
const smOuter = createPillPath(
|
|
1013
|
+
centerX,
|
|
1014
|
+
centerY,
|
|
1015
|
+
smWidth,
|
|
1016
|
+
smHeight,
|
|
1017
|
+
(smtPad.ccw_rotation ?? 0) * (Math.PI / 180)
|
|
1018
|
+
);
|
|
972
1019
|
project.children.push(
|
|
973
1020
|
new ShapePath11({
|
|
974
1021
|
cutIndex: soldermaskCutSetting.index,
|
|
975
|
-
verts:
|
|
976
|
-
prims:
|
|
1022
|
+
verts: smOuter.verts,
|
|
1023
|
+
prims: smOuter.prims,
|
|
977
1024
|
isClosed: true
|
|
978
1025
|
})
|
|
979
1026
|
);
|
|
@@ -983,6 +1030,35 @@ var addRotatedPillSmtPad = (smtPad, ctx) => {
|
|
|
983
1030
|
|
|
984
1031
|
// lib/element-handlers/addSmtPad/addPolygonSmtPad.ts
|
|
985
1032
|
import { ShapePath as ShapePath12 } from "lbrnts";
|
|
1033
|
+
|
|
1034
|
+
// lib/polygon-to-shape-path.ts
|
|
1035
|
+
function polygonToShapePathData(polygon) {
|
|
1036
|
+
const verts = [];
|
|
1037
|
+
const prims = [];
|
|
1038
|
+
const svgString = polygon.svg();
|
|
1039
|
+
const dAttributeMatch = svgString.match(/\bd="([^"]+)"/);
|
|
1040
|
+
if (!dAttributeMatch || !dAttributeMatch[1]) {
|
|
1041
|
+
return { verts, prims };
|
|
1042
|
+
}
|
|
1043
|
+
const pathData = dAttributeMatch[1].trim();
|
|
1044
|
+
const commands = pathData.match(/[MLz][^MLz]*/g) || [];
|
|
1045
|
+
for (const command of commands) {
|
|
1046
|
+
const type = command[0];
|
|
1047
|
+
const coords = command.slice(1).trim();
|
|
1048
|
+
if (type === "M" || type === "L") {
|
|
1049
|
+
const parts = coords.split(",");
|
|
1050
|
+
const x = Number(parts[0]);
|
|
1051
|
+
const y = Number(parts[1]);
|
|
1052
|
+
if (!Number.isNaN(x) && !Number.isNaN(y)) {
|
|
1053
|
+
verts.push({ x, y });
|
|
1054
|
+
prims.push({ type: 0 });
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
return { verts, prims };
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
// lib/element-handlers/addSmtPad/addPolygonSmtPad.ts
|
|
986
1062
|
var addPolygonSmtPad = (smtPad, ctx) => {
|
|
987
1063
|
const {
|
|
988
1064
|
project,
|
|
@@ -991,7 +1067,8 @@ var addPolygonSmtPad = (smtPad, ctx) => {
|
|
|
991
1067
|
origin,
|
|
992
1068
|
includeCopper,
|
|
993
1069
|
includeSoldermask,
|
|
994
|
-
connMap
|
|
1070
|
+
connMap,
|
|
1071
|
+
soldermaskMargin
|
|
995
1072
|
} = ctx;
|
|
996
1073
|
if (smtPad.points.length >= 3) {
|
|
997
1074
|
const pad = createPolygonPathFromOutline(smtPad.points, origin.x, origin.y);
|
|
@@ -1034,7 +1111,8 @@ var addRotatedRectSmtPad = (smtPad, ctx) => {
|
|
|
1034
1111
|
origin,
|
|
1035
1112
|
includeCopper,
|
|
1036
1113
|
includeSoldermask,
|
|
1037
|
-
connMap
|
|
1114
|
+
connMap,
|
|
1115
|
+
soldermaskMargin
|
|
1038
1116
|
} = ctx;
|
|
1039
1117
|
const centerX = smtPad.x + origin.x;
|
|
1040
1118
|
const centerY = smtPad.y + origin.y;
|
|
@@ -1067,11 +1145,22 @@ var addRotatedRectSmtPad = (smtPad, ctx) => {
|
|
|
1067
1145
|
}
|
|
1068
1146
|
}
|
|
1069
1147
|
if (includeSoldermask) {
|
|
1148
|
+
const smWidth = smtPad.width + 2 * soldermaskMargin;
|
|
1149
|
+
const smHeight = smtPad.height + 2 * soldermaskMargin;
|
|
1150
|
+
const smOuter = createRoundedRectPath(
|
|
1151
|
+
centerX,
|
|
1152
|
+
centerY,
|
|
1153
|
+
smWidth,
|
|
1154
|
+
smHeight,
|
|
1155
|
+
borderRadius,
|
|
1156
|
+
4,
|
|
1157
|
+
rotation
|
|
1158
|
+
);
|
|
1070
1159
|
project.children.push(
|
|
1071
1160
|
new ShapePath13({
|
|
1072
1161
|
cutIndex: soldermaskCutSetting.index,
|
|
1073
|
-
verts:
|
|
1074
|
-
prims:
|
|
1162
|
+
verts: smOuter.verts,
|
|
1163
|
+
prims: smOuter.prims,
|
|
1075
1164
|
isClosed: true
|
|
1076
1165
|
})
|
|
1077
1166
|
);
|
|
@@ -1169,35 +1258,6 @@ var addPcbTrace = (trace, ctx) => {
|
|
|
1169
1258
|
// lib/element-handlers/addPcbBoard/index.ts
|
|
1170
1259
|
import { Polygon as Polygon3, point as point4 } from "@flatten-js/core";
|
|
1171
1260
|
import { ShapePath as ShapePath14 } from "lbrnts";
|
|
1172
|
-
|
|
1173
|
-
// lib/polygon-to-shape-path.ts
|
|
1174
|
-
function polygonToShapePathData(polygon) {
|
|
1175
|
-
const verts = [];
|
|
1176
|
-
const prims = [];
|
|
1177
|
-
const svgString = polygon.svg();
|
|
1178
|
-
const dAttributeMatch = svgString.match(/\bd="([^"]+)"/);
|
|
1179
|
-
if (!dAttributeMatch || !dAttributeMatch[1]) {
|
|
1180
|
-
return { verts, prims };
|
|
1181
|
-
}
|
|
1182
|
-
const pathData = dAttributeMatch[1].trim();
|
|
1183
|
-
const commands = pathData.match(/[MLz][^MLz]*/g) || [];
|
|
1184
|
-
for (const command of commands) {
|
|
1185
|
-
const type = command[0];
|
|
1186
|
-
const coords = command.slice(1).trim();
|
|
1187
|
-
if (type === "M" || type === "L") {
|
|
1188
|
-
const parts = coords.split(",");
|
|
1189
|
-
const x = Number(parts[0]);
|
|
1190
|
-
const y = Number(parts[1]);
|
|
1191
|
-
if (!Number.isNaN(x) && !Number.isNaN(y)) {
|
|
1192
|
-
verts.push({ x, y });
|
|
1193
|
-
prims.push({ type: 0 });
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
return { verts, prims };
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
// lib/element-handlers/addPcbBoard/index.ts
|
|
1201
1261
|
var addPcbBoard = (board, ctx) => {
|
|
1202
1262
|
const {
|
|
1203
1263
|
origin,
|
|
@@ -1246,7 +1306,7 @@ var addPcbBoard = (board, ctx) => {
|
|
|
1246
1306
|
cutIndex: soldermaskCutSetting.index,
|
|
1247
1307
|
verts,
|
|
1248
1308
|
prims,
|
|
1249
|
-
isClosed:
|
|
1309
|
+
isClosed: false
|
|
1250
1310
|
})
|
|
1251
1311
|
);
|
|
1252
1312
|
}
|
|
@@ -1340,8 +1400,13 @@ var convertCircuitJsonToLbrn = (circuitJson, options = {}) => {
|
|
|
1340
1400
|
name: "Cut Soldermask",
|
|
1341
1401
|
numPasses: 1,
|
|
1342
1402
|
speed: 150,
|
|
1343
|
-
scanOpt: "individual"
|
|
1403
|
+
scanOpt: "individual",
|
|
1344
1404
|
// Scan each shape individually
|
|
1405
|
+
interval: 0.18,
|
|
1406
|
+
// Distance between cross-hatch lines
|
|
1407
|
+
angle: 45,
|
|
1408
|
+
// Angle of the cross-hatch lines
|
|
1409
|
+
crossHatch: true
|
|
1345
1410
|
});
|
|
1346
1411
|
project.children.push(soldermaskCutSetting);
|
|
1347
1412
|
const connMap = getFullConnectivityMapFromCircuitJson(circuitJson);
|
|
@@ -1360,7 +1425,8 @@ var convertCircuitJsonToLbrn = (circuitJson, options = {}) => {
|
|
|
1360
1425
|
netGeoms: /* @__PURE__ */ new Map(),
|
|
1361
1426
|
origin,
|
|
1362
1427
|
includeCopper: options.includeCopper ?? true,
|
|
1363
|
-
includeSoldermask: options.includeSoldermask ?? false
|
|
1428
|
+
includeSoldermask: options.includeSoldermask ?? false,
|
|
1429
|
+
soldermaskMargin: options.soldermaskMargin ?? 0
|
|
1364
1430
|
};
|
|
1365
1431
|
for (const net of Object.keys(connMap.netMap)) {
|
|
1366
1432
|
ctx.netGeoms.set(net, []);
|
package/lib/ConvertContext.ts
CHANGED
|
@@ -18,6 +18,7 @@ export const addCirclePlatedHole = (
|
|
|
18
18
|
includeCopper,
|
|
19
19
|
includeSoldermask,
|
|
20
20
|
connMap,
|
|
21
|
+
soldermaskMargin,
|
|
21
22
|
} = ctx
|
|
22
23
|
const centerX = platedHole.x + origin.x
|
|
23
24
|
const centerY = platedHole.y + origin.y
|
|
@@ -48,8 +49,8 @@ export const addCirclePlatedHole = (
|
|
|
48
49
|
|
|
49
50
|
// Add soldermask opening if drawing soldermask
|
|
50
51
|
if (platedHole.outer_diameter > 0 && includeSoldermask) {
|
|
51
|
-
const
|
|
52
|
-
const outer = createCirclePath(centerX, centerY,
|
|
52
|
+
const smRadius = platedHole.outer_diameter / 2 + soldermaskMargin
|
|
53
|
+
const outer = createCirclePath(centerX, centerY, smRadius)
|
|
53
54
|
project.children.push(
|
|
54
55
|
new ShapePath({
|
|
55
56
|
cutIndex: soldermaskCutSetting.index,
|
|
@@ -16,6 +16,7 @@ export const addCircularHoleWithRectPad = (
|
|
|
16
16
|
origin,
|
|
17
17
|
includeCopper,
|
|
18
18
|
includeSoldermask,
|
|
19
|
+
soldermaskMargin,
|
|
19
20
|
} = ctx
|
|
20
21
|
const centerX = platedHole.x + origin.x
|
|
21
22
|
const centerY = platedHole.y + origin.y
|
|
@@ -47,11 +48,21 @@ export const addCircularHoleWithRectPad = (
|
|
|
47
48
|
|
|
48
49
|
// Add soldermask opening if drawing soldermask
|
|
49
50
|
if (includeSoldermask) {
|
|
51
|
+
const smPadWidth = padWidth + 2 * soldermaskMargin
|
|
52
|
+
const smPadHeight = padHeight + 2 * soldermaskMargin
|
|
53
|
+
const smPadPath = createRoundedRectPath(
|
|
54
|
+
centerX,
|
|
55
|
+
centerY,
|
|
56
|
+
smPadWidth,
|
|
57
|
+
smPadHeight,
|
|
58
|
+
borderRadius,
|
|
59
|
+
)
|
|
60
|
+
|
|
50
61
|
project.children.push(
|
|
51
62
|
new ShapePath({
|
|
52
63
|
cutIndex: soldermaskCutSetting.index,
|
|
53
|
-
verts:
|
|
54
|
-
prims:
|
|
64
|
+
verts: smPadPath.verts,
|
|
65
|
+
prims: smPadPath.prims,
|
|
55
66
|
isClosed: true,
|
|
56
67
|
}),
|
|
57
68
|
)
|
|
@@ -16,6 +16,7 @@ export const addHoleWithPolygonPad = (
|
|
|
16
16
|
origin,
|
|
17
17
|
includeCopper,
|
|
18
18
|
includeSoldermask,
|
|
19
|
+
soldermaskMargin,
|
|
19
20
|
} = ctx
|
|
20
21
|
|
|
21
22
|
// Create the polygon pad
|
|
@@ -40,6 +41,8 @@ export const addHoleWithPolygonPad = (
|
|
|
40
41
|
|
|
41
42
|
// Add soldermask opening if drawing soldermask
|
|
42
43
|
if (includeSoldermask) {
|
|
44
|
+
// TODO: For polygon pads with soldermask margin, we need to implement proper
|
|
45
|
+
// polygon offsetting. For now, we use the pad vertices directly.
|
|
43
46
|
project.children.push(
|
|
44
47
|
new ShapePath({
|
|
45
48
|
cutIndex: soldermaskCutSetting.index,
|
|
@@ -15,6 +15,7 @@ export const addOvalPlatedHole = (
|
|
|
15
15
|
origin,
|
|
16
16
|
includeCopper,
|
|
17
17
|
includeSoldermask,
|
|
18
|
+
soldermaskMargin,
|
|
18
19
|
} = ctx
|
|
19
20
|
|
|
20
21
|
if (platedHole.outer_width <= 0 || platedHole.outer_height <= 0) {
|
|
@@ -54,13 +55,9 @@ export const addOvalPlatedHole = (
|
|
|
54
55
|
platedHole.outer_height > 0 &&
|
|
55
56
|
includeSoldermask
|
|
56
57
|
) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
platedHole.outer_width,
|
|
61
|
-
platedHole.outer_height,
|
|
62
|
-
rotation,
|
|
63
|
-
)
|
|
58
|
+
const smWidth = platedHole.outer_width + 2 * soldermaskMargin
|
|
59
|
+
const smHeight = platedHole.outer_height + 2 * soldermaskMargin
|
|
60
|
+
const outer = createOvalPath(centerX, centerY, smWidth, smHeight, rotation)
|
|
64
61
|
project.children.push(
|
|
65
62
|
new ShapePath({
|
|
66
63
|
cutIndex: soldermaskCutSetting.index,
|
|
@@ -16,6 +16,7 @@ export const addPillHoleWithRectPad = (
|
|
|
16
16
|
origin,
|
|
17
17
|
includeCopper,
|
|
18
18
|
includeSoldermask,
|
|
19
|
+
soldermaskMargin,
|
|
19
20
|
} = ctx
|
|
20
21
|
const centerX = platedHole.x + origin.x
|
|
21
22
|
const centerY = platedHole.y + origin.y
|
|
@@ -47,11 +48,21 @@ export const addPillHoleWithRectPad = (
|
|
|
47
48
|
|
|
48
49
|
// Add soldermask opening if drawing soldermask
|
|
49
50
|
if (includeSoldermask) {
|
|
51
|
+
const smPadWidth = padWidth + 2 * soldermaskMargin
|
|
52
|
+
const smPadHeight = padHeight + 2 * soldermaskMargin
|
|
53
|
+
const smPadPath = createRoundedRectPath(
|
|
54
|
+
centerX,
|
|
55
|
+
centerY,
|
|
56
|
+
smPadWidth,
|
|
57
|
+
smPadHeight,
|
|
58
|
+
borderRadius,
|
|
59
|
+
)
|
|
60
|
+
|
|
50
61
|
project.children.push(
|
|
51
62
|
new ShapePath({
|
|
52
63
|
cutIndex: soldermaskCutSetting.index,
|
|
53
|
-
verts:
|
|
54
|
-
prims:
|
|
64
|
+
verts: smPadPath.verts,
|
|
65
|
+
prims: smPadPath.prims,
|
|
55
66
|
isClosed: true,
|
|
56
67
|
}),
|
|
57
68
|
)
|
|
@@ -15,6 +15,7 @@ export const addPcbPlatedHolePill = (
|
|
|
15
15
|
origin,
|
|
16
16
|
includeCopper,
|
|
17
17
|
includeSoldermask,
|
|
18
|
+
soldermaskMargin,
|
|
18
19
|
} = ctx
|
|
19
20
|
const centerX = platedHole.x + origin.x
|
|
20
21
|
const centerY = platedHole.y + origin.y
|
|
@@ -49,13 +50,9 @@ export const addPcbPlatedHolePill = (
|
|
|
49
50
|
platedHole.outer_height > 0 &&
|
|
50
51
|
includeSoldermask
|
|
51
52
|
) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
platedHole.outer_width,
|
|
56
|
-
platedHole.outer_height,
|
|
57
|
-
rotation,
|
|
58
|
-
)
|
|
53
|
+
const smWidth = platedHole.outer_width + 2 * soldermaskMargin
|
|
54
|
+
const smHeight = platedHole.outer_height + 2 * soldermaskMargin
|
|
55
|
+
const outer = createPillPath(centerX, centerY, smWidth, smHeight, rotation)
|
|
59
56
|
project.children.push(
|
|
60
57
|
new ShapePath({
|
|
61
58
|
cutIndex: soldermaskCutSetting.index,
|
|
@@ -16,6 +16,7 @@ export const addRotatedPillHoleWithRectPad = (
|
|
|
16
16
|
origin,
|
|
17
17
|
includeCopper,
|
|
18
18
|
includeSoldermask,
|
|
19
|
+
soldermaskMargin,
|
|
19
20
|
} = ctx
|
|
20
21
|
const centerX = platedHole.x + origin.x
|
|
21
22
|
const centerY = platedHole.y + origin.y
|
|
@@ -50,11 +51,23 @@ export const addRotatedPillHoleWithRectPad = (
|
|
|
50
51
|
|
|
51
52
|
// Add soldermask opening if drawing soldermask
|
|
52
53
|
if (includeSoldermask) {
|
|
54
|
+
const smPadWidth = padWidth + 2 * soldermaskMargin
|
|
55
|
+
const smPadHeight = padHeight + 2 * soldermaskMargin
|
|
56
|
+
const smPadPath = createRoundedRectPath(
|
|
57
|
+
centerX,
|
|
58
|
+
centerY,
|
|
59
|
+
smPadWidth,
|
|
60
|
+
smPadHeight,
|
|
61
|
+
borderRadius,
|
|
62
|
+
4,
|
|
63
|
+
padRotation,
|
|
64
|
+
)
|
|
65
|
+
|
|
53
66
|
project.children.push(
|
|
54
67
|
new ShapePath({
|
|
55
68
|
cutIndex: soldermaskCutSetting.index,
|
|
56
|
-
verts:
|
|
57
|
-
prims:
|
|
69
|
+
verts: smPadPath.verts,
|
|
70
|
+
prims: smPadPath.prims,
|
|
58
71
|
isClosed: true,
|
|
59
72
|
}),
|
|
60
73
|
)
|
|
@@ -17,6 +17,7 @@ export const addCircleSmtPad = (
|
|
|
17
17
|
includeCopper,
|
|
18
18
|
includeSoldermask,
|
|
19
19
|
connMap,
|
|
20
|
+
soldermaskMargin,
|
|
20
21
|
} = ctx
|
|
21
22
|
const centerX = smtPad.x + origin.x
|
|
22
23
|
const centerY = smtPad.y + origin.y
|
|
@@ -49,7 +50,8 @@ export const addCircleSmtPad = (
|
|
|
49
50
|
|
|
50
51
|
// Add soldermask opening if drawing soldermask
|
|
51
52
|
if (includeSoldermask) {
|
|
52
|
-
const
|
|
53
|
+
const smRadius = outerRadius + soldermaskMargin
|
|
54
|
+
const outer = createCirclePath(centerX, centerY, smRadius)
|
|
53
55
|
project.children.push(
|
|
54
56
|
new ShapePath({
|
|
55
57
|
cutIndex: soldermaskCutSetting.index,
|