calculate-packing 0.0.33 → 0.0.35
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 +17 -1
- package/dist/index.js +27 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -43,9 +43,19 @@ interface PackedComponent extends InputComponent {
|
|
|
43
43
|
ccwRotationDegrees?: number;
|
|
44
44
|
pads: OutputPad[];
|
|
45
45
|
}
|
|
46
|
+
interface InputObstacle {
|
|
47
|
+
obstacleId: string;
|
|
48
|
+
absoluteCenter: {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
};
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
}
|
|
46
55
|
type PackPlacementStrategy = "shortest_connection_along_outline" | "minimum_sum_distance_to_network" | "minimum_sum_squared_distance_to_network" | "minimum_closest_sum_squared_distance";
|
|
47
56
|
interface PackInput {
|
|
48
57
|
components: InputComponent[];
|
|
58
|
+
obstacles?: InputObstacle[];
|
|
49
59
|
minGap: number;
|
|
50
60
|
packOrderStrategy: "largest_to_smallest";
|
|
51
61
|
packPlacementStrategy: PackPlacementStrategy;
|
|
@@ -172,6 +182,12 @@ declare class PhasedPackSolver extends BaseSolver {
|
|
|
172
182
|
declare const convertCircuitJsonToPackOutput: (circuitJson: CircuitJson, opts?: {
|
|
173
183
|
source_group_id?: string;
|
|
174
184
|
shouldAddInnerObstacles?: boolean;
|
|
185
|
+
chipMarginsMap?: Record<string, {
|
|
186
|
+
left: number;
|
|
187
|
+
right: number;
|
|
188
|
+
top: number;
|
|
189
|
+
bottom: number;
|
|
190
|
+
}>;
|
|
175
191
|
}) => PackOutput;
|
|
176
192
|
|
|
177
193
|
declare const getGraphicsFromPackOutput: (packOutput: PackOutput) => GraphicsObject;
|
|
@@ -521,4 +537,4 @@ declare class PackSolver2 extends BaseSolver {
|
|
|
521
537
|
visualize(): GraphicsObject;
|
|
522
538
|
}
|
|
523
539
|
|
|
524
|
-
export { type ComponentId, type GlobalBounds, type InputComponent, type InputPad, LargestRectOutsideOutlineFromPointSolver, type NetworkId, type OutputPad, type PackInput, type PackOutput, type PackPlacementStrategy, PackSolver2, type PackedComponent, type PadId, PhasedPackSolver, type Point$1 as Point, type Rect, convertCircuitJsonToPackOutput, convertPackOutputToPackInput, getGraphicsFromPackOutput, pack };
|
|
540
|
+
export { type ComponentId, type GlobalBounds, type InputComponent, type InputObstacle, type InputPad, LargestRectOutsideOutlineFromPointSolver, type NetworkId, type OutputPad, type PackInput, type PackOutput, type PackPlacementStrategy, PackSolver2, type PackedComponent, type PadId, PhasedPackSolver, type Point$1 as Point, type Rect, convertCircuitJsonToPackOutput, convertPackOutputToPackInput, getGraphicsFromPackOutput, pack };
|
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