calculate-packing 0.0.69 → 0.0.71
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 +7 -0
- package/dist/index.js +55 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -167,6 +167,7 @@ declare class LargestRectOutsideOutlineFromPointSolver extends BaseSolver$1 {
|
|
|
167
167
|
* - "inside": Find rect inside the polygon (for CW free space pockets)
|
|
168
168
|
*/
|
|
169
169
|
mode: "outside" | "inside";
|
|
170
|
+
getSolverName(): string;
|
|
170
171
|
constructor(params: {
|
|
171
172
|
ccwFullOutline: Point$1[];
|
|
172
173
|
origin: Point$1;
|
|
@@ -213,6 +214,7 @@ declare class BaseSolver {
|
|
|
213
214
|
timeToSolve?: number;
|
|
214
215
|
stats: Record<string, any>;
|
|
215
216
|
_setupDone: boolean;
|
|
217
|
+
getSolverName(): string;
|
|
216
218
|
setup(): void;
|
|
217
219
|
/** DO NOT OVERRIDE! Override _step() instead */
|
|
218
220
|
step(): void;
|
|
@@ -287,6 +289,7 @@ declare class MultiOffsetIrlsSolver extends BaseSolver {
|
|
|
287
289
|
useSquaredDistance: boolean;
|
|
288
290
|
optimalPosition?: Point;
|
|
289
291
|
private readonly initialPosition;
|
|
292
|
+
getSolverName(): string;
|
|
290
293
|
constructor(params: MultiOffsetIrlsSolverParams);
|
|
291
294
|
getConstructorParams(): MultiOffsetIrlsSolverParams;
|
|
292
295
|
_setup(): void;
|
|
@@ -345,6 +348,7 @@ declare class TwoPhaseIrlsSolver extends BaseSolver {
|
|
|
345
348
|
private readonly phase1Epsilon;
|
|
346
349
|
private readonly phase2Epsilon;
|
|
347
350
|
private readonly maxIterations;
|
|
351
|
+
getSolverName(): string;
|
|
348
352
|
private phase1Solver?;
|
|
349
353
|
private phase2Solver?;
|
|
350
354
|
private currentPhase;
|
|
@@ -416,6 +420,7 @@ declare class OutlineSegmentCandidatePointSolver extends BaseSolver$1 {
|
|
|
416
420
|
optimalPosition?: Point$2;
|
|
417
421
|
irlsSolver?: MultiOffsetIrlsSolver;
|
|
418
422
|
twoPhaseIrlsSolver?: TwoPhaseIrlsSolver;
|
|
423
|
+
getSolverName(): string;
|
|
419
424
|
largestRectBounds?: Bounds;
|
|
420
425
|
largestRectMidPoint?: Point$2;
|
|
421
426
|
largestRectOrigin?: Point$2;
|
|
@@ -505,6 +510,7 @@ declare class SingleComponentPackSolver extends BaseSolver$1 {
|
|
|
505
510
|
y: number;
|
|
506
511
|
}>;
|
|
507
512
|
weightedConnections?: PackInput["weightedConnections"];
|
|
513
|
+
getSolverName(): string;
|
|
508
514
|
currentPhase: Phase;
|
|
509
515
|
outlines: Segment[][];
|
|
510
516
|
queuedOutlineSegments: QueuedOutlineSegment[];
|
|
@@ -566,6 +572,7 @@ declare class SingleComponentPackSolver extends BaseSolver$1 {
|
|
|
566
572
|
declare class PackSolver2 extends BaseSolver$1 {
|
|
567
573
|
activeSubSolver: SingleComponentPackSolver | null | undefined;
|
|
568
574
|
packInput: PackInput;
|
|
575
|
+
getSolverName(): string;
|
|
569
576
|
unpackedComponentQueue: InputComponent[];
|
|
570
577
|
packedComponents: PackedComponent[];
|
|
571
578
|
componentToPack?: InputComponent | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -427,6 +427,9 @@ var BaseSolver = class {
|
|
|
427
427
|
timeToSolve;
|
|
428
428
|
stats = {};
|
|
429
429
|
_setupDone = false;
|
|
430
|
+
getSolverName() {
|
|
431
|
+
return this.constructor.name;
|
|
432
|
+
}
|
|
430
433
|
setup() {
|
|
431
434
|
if (this._setupDone) return;
|
|
432
435
|
this._setup();
|
|
@@ -443,7 +446,7 @@ var BaseSolver = class {
|
|
|
443
446
|
try {
|
|
444
447
|
this._step();
|
|
445
448
|
} catch (e) {
|
|
446
|
-
this.error = `${this.
|
|
449
|
+
this.error = `${this.getSolverName()} error: ${e}`;
|
|
447
450
|
console.error(this.error);
|
|
448
451
|
this.failed = true;
|
|
449
452
|
throw e;
|
|
@@ -452,7 +455,7 @@ var BaseSolver = class {
|
|
|
452
455
|
this.tryFinalAcceptance();
|
|
453
456
|
}
|
|
454
457
|
if (!this.solved && this.iterations > this.MAX_ITERATIONS) {
|
|
455
|
-
this.error = `${this.
|
|
458
|
+
this.error = `${this.getSolverName()} ran out of iterations`;
|
|
456
459
|
console.error(this.error);
|
|
457
460
|
this.failed = true;
|
|
458
461
|
}
|
|
@@ -531,6 +534,9 @@ var MultiOffsetIrlsSolver = class extends BaseSolver {
|
|
|
531
534
|
useSquaredDistance;
|
|
532
535
|
optimalPosition;
|
|
533
536
|
initialPosition;
|
|
537
|
+
getSolverName() {
|
|
538
|
+
return "MultiOffsetIrlsSolver";
|
|
539
|
+
}
|
|
534
540
|
constructor(params) {
|
|
535
541
|
super();
|
|
536
542
|
this.offsetPadPoints = [...params.offsetPadPoints];
|
|
@@ -763,6 +769,9 @@ var TwoPhaseIrlsSolver = class extends BaseSolver {
|
|
|
763
769
|
phase1Epsilon;
|
|
764
770
|
phase2Epsilon;
|
|
765
771
|
maxIterations;
|
|
772
|
+
getSolverName() {
|
|
773
|
+
return "TwoPhaseIrlsSolver";
|
|
774
|
+
}
|
|
766
775
|
phase1Solver;
|
|
767
776
|
phase2Solver;
|
|
768
777
|
currentPhase = 1;
|
|
@@ -1082,6 +1091,9 @@ var LargestRectOutsideOutlineFromPointSolver = class extends BaseSolver2 {
|
|
|
1082
1091
|
* - "inside": Find rect inside the polygon (for CW free space pockets)
|
|
1083
1092
|
*/
|
|
1084
1093
|
mode;
|
|
1094
|
+
getSolverName() {
|
|
1095
|
+
return "LargestRectOutsideOutlineFromPointSolver";
|
|
1096
|
+
}
|
|
1085
1097
|
constructor(params) {
|
|
1086
1098
|
super();
|
|
1087
1099
|
this.ccwFullOutline = params.ccwFullOutline;
|
|
@@ -1445,6 +1457,9 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver3 {
|
|
|
1445
1457
|
optimalPosition;
|
|
1446
1458
|
irlsSolver;
|
|
1447
1459
|
twoPhaseIrlsSolver;
|
|
1460
|
+
getSolverName() {
|
|
1461
|
+
return "OutlineSegmentCandidatePointSolver";
|
|
1462
|
+
}
|
|
1448
1463
|
largestRectBounds;
|
|
1449
1464
|
largestRectMidPoint;
|
|
1450
1465
|
largestRectOrigin;
|
|
@@ -2145,6 +2160,9 @@ var SingleComponentPackSolver = class extends BaseSolver4 {
|
|
|
2145
2160
|
obstacles;
|
|
2146
2161
|
boundaryOutline;
|
|
2147
2162
|
weightedConnections;
|
|
2163
|
+
getSolverName() {
|
|
2164
|
+
return "SingleComponentPackSolver";
|
|
2165
|
+
}
|
|
2148
2166
|
// Phase management
|
|
2149
2167
|
currentPhase = "outline";
|
|
2150
2168
|
outlines = [];
|
|
@@ -2714,6 +2732,9 @@ function getPolygonCentroid(points) {
|
|
|
2714
2732
|
// lib/PackSolver2/PackSolver2.ts
|
|
2715
2733
|
var PackSolver2 = class extends BaseSolver5 {
|
|
2716
2734
|
packInput;
|
|
2735
|
+
getSolverName() {
|
|
2736
|
+
return "PackSolver2";
|
|
2737
|
+
}
|
|
2717
2738
|
unpackedComponentQueue = [];
|
|
2718
2739
|
packedComponents = [];
|
|
2719
2740
|
componentToPack;
|
|
@@ -3181,9 +3202,37 @@ var getElementOutsideTree = (db, tree) => {
|
|
|
3181
3202
|
outside.push(ph);
|
|
3182
3203
|
}
|
|
3183
3204
|
}
|
|
3205
|
+
for (const hole of db.pcb_hole.list({})) {
|
|
3206
|
+
outside.push(hole);
|
|
3207
|
+
}
|
|
3184
3208
|
return outside;
|
|
3185
3209
|
};
|
|
3186
3210
|
|
|
3211
|
+
// lib/plumbing/getObstacleFromElement.ts
|
|
3212
|
+
var getObstacleFromElement = (element) => {
|
|
3213
|
+
if (element.type === "pcb_plated_hole" && element.shape === "circular_hole_with_rect_pad") {
|
|
3214
|
+
const { rect_pad_height, rect_pad_width, x, y } = element;
|
|
3215
|
+
return {
|
|
3216
|
+
obstacleId: element.pcb_plated_hole_id,
|
|
3217
|
+
absoluteCenter: { x, y },
|
|
3218
|
+
width: rect_pad_width,
|
|
3219
|
+
height: rect_pad_height
|
|
3220
|
+
};
|
|
3221
|
+
}
|
|
3222
|
+
if (element.type === "pcb_hole") {
|
|
3223
|
+
const { x, y, pcb_hole_id } = element;
|
|
3224
|
+
const width = "hole_diameter" in element ? element.hole_diameter : element.hole_width;
|
|
3225
|
+
const height = "hole_diameter" in element ? element.hole_diameter : element.hole_height;
|
|
3226
|
+
return {
|
|
3227
|
+
obstacleId: pcb_hole_id,
|
|
3228
|
+
absoluteCenter: { x, y },
|
|
3229
|
+
width,
|
|
3230
|
+
height
|
|
3231
|
+
};
|
|
3232
|
+
}
|
|
3233
|
+
return void 0;
|
|
3234
|
+
};
|
|
3235
|
+
|
|
3187
3236
|
// lib/plumbing/convertCircuitJsonToPackOutput.ts
|
|
3188
3237
|
var buildPackedComponent = (pcbComponents, componentId, db, getNetworkId, shouldAddInnerObstacles, sourcePortToPadIds = /* @__PURE__ */ new Map(), chipMarginsMap = {}, isStatic = false) => {
|
|
3189
3238
|
const padInfos = pcbComponents.flatMap((pc) => {
|
|
@@ -3276,7 +3325,7 @@ var convertCircuitJsonToPackOutput = (circuitJson, opts = {}) => {
|
|
|
3276
3325
|
const pcbBoard = circuitJson.find(
|
|
3277
3326
|
(item) => item.type === "pcb_board"
|
|
3278
3327
|
);
|
|
3279
|
-
if (pcbBoard
|
|
3328
|
+
if (pcbBoard?.outline) {
|
|
3280
3329
|
packOutput.boundaryOutline = pcbBoard.outline;
|
|
3281
3330
|
}
|
|
3282
3331
|
const getNetworkId = (pcbPortId) => {
|
|
@@ -3380,14 +3429,9 @@ var convertCircuitJsonToPackOutput = (circuitJson, opts = {}) => {
|
|
|
3380
3429
|
});
|
|
3381
3430
|
}
|
|
3382
3431
|
for (const element of elementsOutsideTree) {
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
packOutput.obstacles.push(
|
|
3386
|
-
obstacleId: element.pcb_plated_hole_id,
|
|
3387
|
-
absoluteCenter: { x, y },
|
|
3388
|
-
width: rect_pad_width,
|
|
3389
|
-
height: rect_pad_height
|
|
3390
|
-
});
|
|
3432
|
+
const obstacle = getObstacleFromElement(element);
|
|
3433
|
+
if (obstacle) {
|
|
3434
|
+
packOutput.obstacles.push(obstacle);
|
|
3391
3435
|
}
|
|
3392
3436
|
}
|
|
3393
3437
|
const weightedConnections = [];
|
package/package.json
CHANGED