calculate-packing 0.0.33 → 0.0.34
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 +6 -0
- package/dist/index.js +27 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -172,6 +172,12 @@ declare class PhasedPackSolver extends BaseSolver {
|
|
|
172
172
|
declare const convertCircuitJsonToPackOutput: (circuitJson: CircuitJson, opts?: {
|
|
173
173
|
source_group_id?: string;
|
|
174
174
|
shouldAddInnerObstacles?: boolean;
|
|
175
|
+
chipMarginsMap?: Record<string, {
|
|
176
|
+
left: number;
|
|
177
|
+
right: number;
|
|
178
|
+
top: number;
|
|
179
|
+
bottom: number;
|
|
180
|
+
}>;
|
|
175
181
|
}) => PackOutput;
|
|
176
182
|
|
|
177
183
|
declare const getGraphicsFromPackOutput: (packOutput: PackOutput) => GraphicsObject;
|
package/dist/index.js
CHANGED
|
@@ -1605,10 +1605,23 @@ var extractPadInfos = (pcbComponent, db, getNetworkId) => {
|
|
|
1605
1605
|
};
|
|
1606
1606
|
|
|
1607
1607
|
// lib/plumbing/convertCircuitJsonToPackOutput.ts
|
|
1608
|
-
var buildPackedComponent = (pcbComponents, componentId, db, getNetworkId, shouldAddInnerObstacles) => {
|
|
1609
|
-
const padInfos = pcbComponents.flatMap(
|
|
1610
|
-
|
|
1611
|
-
|
|
1608
|
+
var buildPackedComponent = (pcbComponents, componentId, db, getNetworkId, shouldAddInnerObstacles, chipMarginsMap = {}) => {
|
|
1609
|
+
const padInfos = pcbComponents.flatMap((pc) => {
|
|
1610
|
+
const pads2 = extractPadInfos(pc, db, getNetworkId);
|
|
1611
|
+
const margins = chipMarginsMap[pc.pcb_component_id];
|
|
1612
|
+
if (!margins) return pads2;
|
|
1613
|
+
return pads2.map((p) => ({
|
|
1614
|
+
...p,
|
|
1615
|
+
size: {
|
|
1616
|
+
x: p.size.x + margins.left + margins.right,
|
|
1617
|
+
y: p.size.y + margins.top + margins.bottom
|
|
1618
|
+
},
|
|
1619
|
+
absoluteCenter: {
|
|
1620
|
+
x: p.absoluteCenter.x + (margins.right - margins.left) / 2,
|
|
1621
|
+
y: p.absoluteCenter.y + (margins.top - margins.bottom) / 2
|
|
1622
|
+
}
|
|
1623
|
+
}));
|
|
1624
|
+
});
|
|
1612
1625
|
let minX = Infinity;
|
|
1613
1626
|
let minY = Infinity;
|
|
1614
1627
|
let maxX = -Infinity;
|
|
@@ -1693,7 +1706,8 @@ var convertCircuitJsonToPackOutput = (circuitJson, opts = {}) => {
|
|
|
1693
1706
|
pcbComponent.pcb_component_id,
|
|
1694
1707
|
db,
|
|
1695
1708
|
getNetworkId,
|
|
1696
|
-
opts.shouldAddInnerObstacles
|
|
1709
|
+
opts.shouldAddInnerObstacles,
|
|
1710
|
+
opts.chipMarginsMap
|
|
1697
1711
|
)
|
|
1698
1712
|
);
|
|
1699
1713
|
} else if (node.nodeType === "group") {
|
|
@@ -1701,7 +1715,14 @@ var convertCircuitJsonToPackOutput = (circuitJson, opts = {}) => {
|
|
|
1701
1715
|
if (!pcbComps.length) continue;
|
|
1702
1716
|
const compId = node.sourceGroup?.source_group_id ?? node.sourceGroup?.name ?? `group_${packOutput.components.length}`;
|
|
1703
1717
|
packOutput.components.push(
|
|
1704
|
-
buildPackedComponent(
|
|
1718
|
+
buildPackedComponent(
|
|
1719
|
+
pcbComps,
|
|
1720
|
+
compId,
|
|
1721
|
+
db,
|
|
1722
|
+
getNetworkId,
|
|
1723
|
+
void 0,
|
|
1724
|
+
opts.chipMarginsMap
|
|
1725
|
+
)
|
|
1705
1726
|
);
|
|
1706
1727
|
}
|
|
1707
1728
|
}
|
package/package.json
CHANGED