calculate-packing 0.0.52 → 0.0.54
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.js +33 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2843,6 +2843,18 @@ var pack = (input) => {
|
|
|
2843
2843
|
import { cju, getCircuitJsonTree } from "@tscircuit/circuit-json-util";
|
|
2844
2844
|
|
|
2845
2845
|
// lib/plumbing/extractPadInfos.ts
|
|
2846
|
+
var getPolygonBoundingBox = (points) => {
|
|
2847
|
+
if (!points || points.length === 0)
|
|
2848
|
+
return { minX: 0, maxX: 0, minY: 0, maxY: 0 };
|
|
2849
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
2850
|
+
for (const point of points) {
|
|
2851
|
+
minX = Math.min(minX, point.x);
|
|
2852
|
+
maxX = Math.max(maxX, point.x);
|
|
2853
|
+
minY = Math.min(minY, point.y);
|
|
2854
|
+
maxY = Math.max(maxY, point.y);
|
|
2855
|
+
}
|
|
2856
|
+
return { minX, maxX, minY, maxY };
|
|
2857
|
+
};
|
|
2846
2858
|
var extractPadInfos = (pcbComponent, db, getNetworkId) => {
|
|
2847
2859
|
const out = [];
|
|
2848
2860
|
const pushPad = ({
|
|
@@ -2942,28 +2954,32 @@ var extractPadInfos = (pcbComponent, db, getNetworkId) => {
|
|
|
2942
2954
|
pushPad({
|
|
2943
2955
|
padId: sp.pcb_smtpad_id,
|
|
2944
2956
|
pcbPortId: sp.pcb_port_id,
|
|
2945
|
-
sx: sp.radius
|
|
2946
|
-
|
|
2957
|
+
sx: sp.radius * 2,
|
|
2958
|
+
// Convert radius to diameter for width/height
|
|
2959
|
+
sy: sp.radius * 2,
|
|
2947
2960
|
x: sp.x,
|
|
2948
2961
|
y: sp.y
|
|
2949
2962
|
});
|
|
2950
2963
|
break;
|
|
2951
2964
|
}
|
|
2952
|
-
case "
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2965
|
+
case "polygon": {
|
|
2966
|
+
if (sp.points && sp.points.length > 0) {
|
|
2967
|
+
const { minX, maxX, minY, maxY } = getPolygonBoundingBox(sp.points);
|
|
2968
|
+
const width = maxX - minX;
|
|
2969
|
+
const height = maxY - minY;
|
|
2970
|
+
const centerX = (minX + maxX) / 2;
|
|
2971
|
+
const centerY = (minY + maxY) / 2;
|
|
2972
|
+
pushPad({
|
|
2973
|
+
padId: sp.pcb_smtpad_id,
|
|
2974
|
+
pcbPortId: sp.pcb_port_id,
|
|
2975
|
+
sx: width,
|
|
2976
|
+
sy: height,
|
|
2977
|
+
x: centerX,
|
|
2978
|
+
y: centerY
|
|
2979
|
+
});
|
|
2980
|
+
} else {
|
|
2981
|
+
console.warn(`Polygon pad ${sp.pcb_smtpad_id} has no points`);
|
|
2982
|
+
}
|
|
2967
2983
|
break;
|
|
2968
2984
|
}
|
|
2969
2985
|
}
|
package/package.json
CHANGED