calculate-packing 0.0.38 → 0.0.40
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 +11 -0
- package/dist/index.js +57 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,12 @@ type PackPlacementStrategy = "shortest_connection_along_outline" | "minimum_sum_
|
|
|
56
56
|
interface PackInput {
|
|
57
57
|
components: InputComponent[];
|
|
58
58
|
obstacles?: InputObstacle[];
|
|
59
|
+
bounds?: {
|
|
60
|
+
minX: number;
|
|
61
|
+
minY: number;
|
|
62
|
+
maxX: number;
|
|
63
|
+
maxY: number;
|
|
64
|
+
};
|
|
59
65
|
minGap: number;
|
|
60
66
|
packOrderStrategy: "largest_to_smallest";
|
|
61
67
|
packPlacementStrategy: PackPlacementStrategy;
|
|
@@ -352,6 +358,7 @@ declare class OutlineSegmentCandidatePointSolver extends BaseSolver {
|
|
|
352
358
|
packedComponents: PackedComponent[];
|
|
353
359
|
componentToPack: InputComponent;
|
|
354
360
|
viableBounds?: Bounds;
|
|
361
|
+
globalBounds?: Bounds;
|
|
355
362
|
optimalPosition?: Point$2;
|
|
356
363
|
irlsSolver?: MultiOffsetIrlsSolver;
|
|
357
364
|
twoPhaseIrlsSolver?: TwoPhaseIrlsSolver;
|
|
@@ -364,6 +371,7 @@ declare class OutlineSegmentCandidatePointSolver extends BaseSolver {
|
|
|
364
371
|
packedComponents: PackedComponent[];
|
|
365
372
|
componentToPack: InputComponent;
|
|
366
373
|
obstacles?: InputObstacle[];
|
|
374
|
+
globalBounds?: Bounds;
|
|
367
375
|
});
|
|
368
376
|
getConstructorParams(): ConstructorParameters<typeof OutlineSegmentCandidatePointSolver>[0];
|
|
369
377
|
_getOutlineBoundsWithMargin(params?: {
|
|
@@ -440,12 +448,14 @@ declare class SingleComponentPackSolver extends BaseSolver {
|
|
|
440
448
|
}>;
|
|
441
449
|
bestCandidate?: CandidateResult;
|
|
442
450
|
outputPackedComponent?: PackedComponent;
|
|
451
|
+
bounds?: Bounds;
|
|
443
452
|
constructor(params: {
|
|
444
453
|
componentToPack: InputComponent;
|
|
445
454
|
packedComponents: PackedComponent[];
|
|
446
455
|
packPlacementStrategy: PackPlacementStrategy;
|
|
447
456
|
minGap?: number;
|
|
448
457
|
obstacles?: InputObstacle[];
|
|
458
|
+
bounds?: Bounds;
|
|
449
459
|
});
|
|
450
460
|
_setup(): void;
|
|
451
461
|
_step(): void;
|
|
@@ -465,6 +475,7 @@ declare class SingleComponentPackSolver extends BaseSolver {
|
|
|
465
475
|
packPlacementStrategy: PackPlacementStrategy;
|
|
466
476
|
minGap: number;
|
|
467
477
|
obstacles: InputObstacle[];
|
|
478
|
+
bounds: Bounds | undefined;
|
|
468
479
|
};
|
|
469
480
|
}
|
|
470
481
|
|
package/dist/index.js
CHANGED
|
@@ -1416,6 +1416,7 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver {
|
|
|
1416
1416
|
packedComponents;
|
|
1417
1417
|
componentToPack;
|
|
1418
1418
|
viableBounds;
|
|
1419
|
+
globalBounds;
|
|
1419
1420
|
optimalPosition;
|
|
1420
1421
|
irlsSolver;
|
|
1421
1422
|
twoPhaseIrlsSolver;
|
|
@@ -1429,6 +1430,7 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver {
|
|
|
1429
1430
|
this.packedComponents = params.packedComponents;
|
|
1430
1431
|
this.componentToPack = params.componentToPack;
|
|
1431
1432
|
this.obstacles = params.obstacles ?? [];
|
|
1433
|
+
this.globalBounds = params.globalBounds;
|
|
1432
1434
|
}
|
|
1433
1435
|
getConstructorParams() {
|
|
1434
1436
|
return {
|
|
@@ -1439,7 +1441,8 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver {
|
|
|
1439
1441
|
minGap: this.minGap,
|
|
1440
1442
|
packedComponents: this.packedComponents,
|
|
1441
1443
|
componentToPack: this.componentToPack,
|
|
1442
|
-
obstacles: this.obstacles
|
|
1444
|
+
obstacles: this.obstacles,
|
|
1445
|
+
globalBounds: this.globalBounds
|
|
1443
1446
|
};
|
|
1444
1447
|
}
|
|
1445
1448
|
_getOutlineBoundsWithMargin(params = {}) {
|
|
@@ -1731,6 +1734,19 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver {
|
|
|
1731
1734
|
});
|
|
1732
1735
|
}
|
|
1733
1736
|
}
|
|
1737
|
+
if (this.globalBounds) {
|
|
1738
|
+
graphics.lines.push({
|
|
1739
|
+
points: [
|
|
1740
|
+
{ x: this.globalBounds.minX, y: this.globalBounds.minY },
|
|
1741
|
+
{ x: this.globalBounds.minX, y: this.globalBounds.maxY },
|
|
1742
|
+
{ x: this.globalBounds.maxX, y: this.globalBounds.maxY },
|
|
1743
|
+
{ x: this.globalBounds.maxX, y: this.globalBounds.minY },
|
|
1744
|
+
{ x: this.globalBounds.minX, y: this.globalBounds.minY }
|
|
1745
|
+
],
|
|
1746
|
+
strokeColor: "rgba(255,0,255,0.5)",
|
|
1747
|
+
strokeDash: "2 2"
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1734
1750
|
if (this.viableBounds) {
|
|
1735
1751
|
graphics.rects.push({
|
|
1736
1752
|
center: {
|
|
@@ -1962,6 +1978,7 @@ var SingleComponentPackSolver = class extends BaseSolver {
|
|
|
1962
1978
|
rejectedCandidates = [];
|
|
1963
1979
|
bestCandidate;
|
|
1964
1980
|
outputPackedComponent;
|
|
1981
|
+
bounds;
|
|
1965
1982
|
constructor(params) {
|
|
1966
1983
|
super();
|
|
1967
1984
|
this.componentToPack = params.componentToPack;
|
|
@@ -1969,6 +1986,7 @@ var SingleComponentPackSolver = class extends BaseSolver {
|
|
|
1969
1986
|
this.packPlacementStrategy = params.packPlacementStrategy;
|
|
1970
1987
|
this.minGap = params.minGap ?? 0;
|
|
1971
1988
|
this.obstacles = params.obstacles ?? [];
|
|
1989
|
+
this.bounds = params.bounds;
|
|
1972
1990
|
}
|
|
1973
1991
|
_setup() {
|
|
1974
1992
|
super._setup();
|
|
@@ -2138,7 +2156,8 @@ var SingleComponentPackSolver = class extends BaseSolver {
|
|
|
2138
2156
|
minGap: this.minGap,
|
|
2139
2157
|
packedComponents: this.packedComponents,
|
|
2140
2158
|
componentToPack: this.componentToPack,
|
|
2141
|
-
obstacles: this.obstacles
|
|
2159
|
+
obstacles: this.obstacles,
|
|
2160
|
+
globalBounds: this.bounds
|
|
2142
2161
|
});
|
|
2143
2162
|
this.activeSubSolver.setup();
|
|
2144
2163
|
break;
|
|
@@ -2224,6 +2243,19 @@ var SingleComponentPackSolver = class extends BaseSolver {
|
|
|
2224
2243
|
});
|
|
2225
2244
|
}
|
|
2226
2245
|
}
|
|
2246
|
+
if (this.bounds) {
|
|
2247
|
+
graphics.lines.push({
|
|
2248
|
+
points: [
|
|
2249
|
+
{ x: this.bounds.minX, y: this.bounds.minY },
|
|
2250
|
+
{ x: this.bounds.minX, y: this.bounds.maxY },
|
|
2251
|
+
{ x: this.bounds.maxX, y: this.bounds.maxY },
|
|
2252
|
+
{ x: this.bounds.maxX, y: this.bounds.minY },
|
|
2253
|
+
{ x: this.bounds.minX, y: this.bounds.minY }
|
|
2254
|
+
],
|
|
2255
|
+
strokeColor: "rgba(0,0,0,0.5)",
|
|
2256
|
+
strokeDash: "2 2"
|
|
2257
|
+
});
|
|
2258
|
+
}
|
|
2227
2259
|
switch (this.currentPhase) {
|
|
2228
2260
|
case "outline":
|
|
2229
2261
|
this.visualizeOutlinePhase(graphics);
|
|
@@ -2330,7 +2362,8 @@ gap_distance=${candidate.gapDistance}`,
|
|
|
2330
2362
|
packedComponents: this.packedComponents,
|
|
2331
2363
|
packPlacementStrategy: this.packPlacementStrategy,
|
|
2332
2364
|
minGap: this.minGap,
|
|
2333
|
-
obstacles: this.obstacles
|
|
2365
|
+
obstacles: this.obstacles,
|
|
2366
|
+
bounds: this.bounds
|
|
2334
2367
|
};
|
|
2335
2368
|
}
|
|
2336
2369
|
};
|
|
@@ -2396,7 +2429,8 @@ var PackSolver2 = class extends BaseSolver {
|
|
|
2396
2429
|
componentToPack: firstComponentToPack,
|
|
2397
2430
|
packPlacementStrategy: this.packInput.packPlacementStrategy,
|
|
2398
2431
|
minGap: this.packInput.minGap,
|
|
2399
|
-
obstacles
|
|
2432
|
+
obstacles,
|
|
2433
|
+
bounds: this.packInput.bounds
|
|
2400
2434
|
});
|
|
2401
2435
|
fallbackSolver.solve();
|
|
2402
2436
|
const result = fallbackSolver.getResult();
|
|
@@ -2431,7 +2465,8 @@ var PackSolver2 = class extends BaseSolver {
|
|
|
2431
2465
|
componentToPack: this.componentToPack,
|
|
2432
2466
|
packPlacementStrategy: this.packInput.packPlacementStrategy,
|
|
2433
2467
|
minGap: this.packInput.minGap,
|
|
2434
|
-
obstacles: this.packInput.obstacles ?? []
|
|
2468
|
+
obstacles: this.packInput.obstacles ?? [],
|
|
2469
|
+
bounds: this.packInput.bounds
|
|
2435
2470
|
});
|
|
2436
2471
|
this.activeSubSolver.setup();
|
|
2437
2472
|
}
|
|
@@ -2486,6 +2521,19 @@ var PackSolver2 = class extends BaseSolver {
|
|
|
2486
2521
|
});
|
|
2487
2522
|
}
|
|
2488
2523
|
}
|
|
2524
|
+
if (this.packInput.bounds) {
|
|
2525
|
+
graphics.lines.push({
|
|
2526
|
+
points: [
|
|
2527
|
+
{ x: this.packInput.bounds.minX, y: this.packInput.bounds.minY },
|
|
2528
|
+
{ x: this.packInput.bounds.minX, y: this.packInput.bounds.maxY },
|
|
2529
|
+
{ x: this.packInput.bounds.maxX, y: this.packInput.bounds.maxY },
|
|
2530
|
+
{ x: this.packInput.bounds.maxX, y: this.packInput.bounds.minY },
|
|
2531
|
+
{ x: this.packInput.bounds.minX, y: this.packInput.bounds.minY }
|
|
2532
|
+
],
|
|
2533
|
+
strokeColor: "rgba(0,0,0,0.5)",
|
|
2534
|
+
strokeDash: "2 2"
|
|
2535
|
+
});
|
|
2536
|
+
}
|
|
2489
2537
|
if (this.packedComponents.length === 0) {
|
|
2490
2538
|
for (const component of this.unpackedComponentQueue) {
|
|
2491
2539
|
for (const pad of component.pads) {
|
|
@@ -2620,8 +2668,11 @@ var extractPadInfos = (pcbComponent, db, getNetworkId) => {
|
|
|
2620
2668
|
});
|
|
2621
2669
|
break;
|
|
2622
2670
|
}
|
|
2671
|
+
default: {
|
|
2672
|
+
console.warn(`Unsupported plated hole shape ${ph.shape}`);
|
|
2673
|
+
break;
|
|
2674
|
+
}
|
|
2623
2675
|
}
|
|
2624
|
-
console.warn(`Unsupported plated hole shape ${ph.shape}`);
|
|
2625
2676
|
}
|
|
2626
2677
|
for (const sp of db.pcb_smtpad.list({
|
|
2627
2678
|
pcb_component_id: pcbComponent.pcb_component_id
|
package/package.json
CHANGED