@tscircuit/matchpack 0.0.7 → 0.0.9
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 +3 -3
- package/dist/index.js +35 -41
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphicsObject } from 'graphics-debug';
|
|
2
2
|
import { Point, Bounds } from '@tscircuit/math-utils';
|
|
3
|
-
import {
|
|
3
|
+
import { PackSolver2 } from 'calculate-packing';
|
|
4
4
|
|
|
5
5
|
declare class BaseSolver {
|
|
6
6
|
MAX_ITERATIONS: number;
|
|
@@ -120,7 +120,7 @@ type OutputLayout = {
|
|
|
120
120
|
declare class SingleInnerPartitionPackingSolver extends BaseSolver {
|
|
121
121
|
inputProblem: InputProblem;
|
|
122
122
|
layout: OutputLayout | null;
|
|
123
|
-
|
|
123
|
+
activeSubSolver: PackSolver2 | null;
|
|
124
124
|
constructor(inputProblem: InputProblem);
|
|
125
125
|
_step(): void;
|
|
126
126
|
private createPackInput;
|
|
@@ -164,7 +164,7 @@ declare class PartitionPackingSolver extends BaseSolver {
|
|
|
164
164
|
packedPartitions: PackedPartition[];
|
|
165
165
|
inputProblem: InputProblem;
|
|
166
166
|
finalLayout: OutputLayout | null;
|
|
167
|
-
|
|
167
|
+
packSolver2: PackSolver2 | null;
|
|
168
168
|
constructor(input: PartitionPackingSolverInput);
|
|
169
169
|
_step(): void;
|
|
170
170
|
private organizePackedPartitions;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// lib/solvers/BaseSolver.ts
|
|
2
2
|
var BaseSolver = class {
|
|
3
|
-
MAX_ITERATIONS =
|
|
3
|
+
MAX_ITERATIONS = 1e5;
|
|
4
4
|
solved = false;
|
|
5
5
|
failed = false;
|
|
6
6
|
iterations = 0;
|
|
@@ -90,7 +90,7 @@ function rotatePoint(point, angleDegrees) {
|
|
|
90
90
|
}
|
|
91
91
|
function getRotatedDimensions(width, height, rotation) {
|
|
92
92
|
const normalizedRotation = (rotation % 360 + 360) % 360;
|
|
93
|
-
if (normalizedRotation
|
|
93
|
+
if (Math.round((normalizedRotation + 90) % 180) === 0) {
|
|
94
94
|
return { width: height, height: width };
|
|
95
95
|
}
|
|
96
96
|
return { width, height };
|
|
@@ -453,7 +453,7 @@ var ChipPartitionsSolver = class extends BaseSolver {
|
|
|
453
453
|
};
|
|
454
454
|
|
|
455
455
|
// lib/solvers/PackInnerPartitionsSolver/SingleInnerPartitionPackingSolver.ts
|
|
456
|
-
import {
|
|
456
|
+
import { PackSolver2 } from "calculate-packing";
|
|
457
457
|
|
|
458
458
|
// lib/utils/networkFiltering.ts
|
|
459
459
|
function createFilteredNetworkMapping(inputProblem) {
|
|
@@ -554,34 +554,28 @@ function createFilteredNetworkMapping(inputProblem) {
|
|
|
554
554
|
var SingleInnerPartitionPackingSolver = class extends BaseSolver {
|
|
555
555
|
inputProblem;
|
|
556
556
|
layout = null;
|
|
557
|
-
phasedPackSolver = null;
|
|
558
557
|
constructor(inputProblem) {
|
|
559
558
|
super();
|
|
560
559
|
this.inputProblem = inputProblem;
|
|
561
560
|
}
|
|
562
561
|
_step() {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
if (this.phasedPackSolver.failed) {
|
|
571
|
-
this.failed = true;
|
|
572
|
-
this.error = `PhasedPackSolver failed: ${this.phasedPackSolver.error}`;
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
if (this.phasedPackSolver.solved) {
|
|
576
|
-
this.layout = this.createLayoutFromPackingResult(
|
|
577
|
-
this.phasedPackSolver.getResult()
|
|
578
|
-
);
|
|
579
|
-
this.solved = true;
|
|
580
|
-
this.activeSubSolver = null;
|
|
581
|
-
}
|
|
582
|
-
} catch (error) {
|
|
562
|
+
if (!this.activeSubSolver) {
|
|
563
|
+
const packInput = this.createPackInput();
|
|
564
|
+
this.activeSubSolver = new PackSolver2(packInput);
|
|
565
|
+
this.activeSubSolver = this.activeSubSolver;
|
|
566
|
+
}
|
|
567
|
+
this.activeSubSolver.step();
|
|
568
|
+
if (this.activeSubSolver.failed) {
|
|
583
569
|
this.failed = true;
|
|
584
|
-
this.error = `
|
|
570
|
+
this.error = `PackSolver2 failed: ${this.activeSubSolver.error}`;
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (this.activeSubSolver.solved) {
|
|
574
|
+
this.layout = this.createLayoutFromPackingResult(
|
|
575
|
+
this.activeSubSolver.packedComponents
|
|
576
|
+
);
|
|
577
|
+
this.solved = true;
|
|
578
|
+
this.activeSubSolver = null;
|
|
585
579
|
}
|
|
586
580
|
}
|
|
587
581
|
createPackInput() {
|
|
@@ -635,7 +629,7 @@ var SingleInnerPartitionPackingSolver = class extends BaseSolver {
|
|
|
635
629
|
chipPlacements[chipId] = {
|
|
636
630
|
x: packedComponent.center.x,
|
|
637
631
|
y: packedComponent.center.y,
|
|
638
|
-
ccwRotationDegrees: packedComponent.ccwRotationDegrees || 0
|
|
632
|
+
ccwRotationDegrees: packedComponent.ccwRotationOffset || packedComponent.ccwRotationDegrees || 0
|
|
639
633
|
};
|
|
640
634
|
}
|
|
641
635
|
return {
|
|
@@ -644,8 +638,8 @@ var SingleInnerPartitionPackingSolver = class extends BaseSolver {
|
|
|
644
638
|
};
|
|
645
639
|
}
|
|
646
640
|
visualize() {
|
|
647
|
-
if (this.
|
|
648
|
-
return this.
|
|
641
|
+
if (this.activeSubSolver && !this.solved) {
|
|
642
|
+
return this.activeSubSolver.visualize();
|
|
649
643
|
}
|
|
650
644
|
if (!this.layout) {
|
|
651
645
|
return super.visualize();
|
|
@@ -725,12 +719,12 @@ var PackInnerPartitionsSolver = class extends BaseSolver {
|
|
|
725
719
|
};
|
|
726
720
|
|
|
727
721
|
// lib/solvers/PartitionPackingSolver/PartitionPackingSolver.ts
|
|
728
|
-
import {
|
|
722
|
+
import { PackSolver2 as PackSolver22 } from "calculate-packing";
|
|
729
723
|
var PartitionPackingSolver = class extends BaseSolver {
|
|
730
724
|
packedPartitions;
|
|
731
725
|
inputProblem;
|
|
732
726
|
finalLayout = null;
|
|
733
|
-
|
|
727
|
+
packSolver2 = null;
|
|
734
728
|
constructor(input) {
|
|
735
729
|
super();
|
|
736
730
|
this.packedPartitions = input.packedPartitions;
|
|
@@ -752,20 +746,20 @@ var PartitionPackingSolver = class extends BaseSolver {
|
|
|
752
746
|
return;
|
|
753
747
|
}
|
|
754
748
|
const partitionGroups = this.organizePackedPartitions();
|
|
755
|
-
if (!this.
|
|
749
|
+
if (!this.packSolver2) {
|
|
756
750
|
const packInput = this.createPackInput(partitionGroups);
|
|
757
|
-
this.
|
|
758
|
-
this.activeSubSolver = this.
|
|
751
|
+
this.packSolver2 = new PackSolver22(packInput);
|
|
752
|
+
this.activeSubSolver = this.packSolver2;
|
|
759
753
|
}
|
|
760
|
-
this.
|
|
761
|
-
if (this.
|
|
754
|
+
this.packSolver2.step();
|
|
755
|
+
if (this.packSolver2.failed) {
|
|
762
756
|
this.failed = true;
|
|
763
|
-
this.error = `
|
|
757
|
+
this.error = `PackSolver2 failed: ${this.packSolver2.error}`;
|
|
764
758
|
return;
|
|
765
759
|
}
|
|
766
|
-
if (this.
|
|
760
|
+
if (this.packSolver2.solved) {
|
|
767
761
|
const packedLayout = this.applyPackingResult(
|
|
768
|
-
this.
|
|
762
|
+
this.packSolver2.packedComponents,
|
|
769
763
|
partitionGroups
|
|
770
764
|
);
|
|
771
765
|
this.finalLayout = packedLayout;
|
|
@@ -948,8 +942,8 @@ var PartitionPackingSolver = class extends BaseSolver {
|
|
|
948
942
|
};
|
|
949
943
|
}
|
|
950
944
|
visualize() {
|
|
951
|
-
if (this.
|
|
952
|
-
return this.
|
|
945
|
+
if (this.packSolver2 && !this.solved) {
|
|
946
|
+
return this.packSolver2.visualize();
|
|
953
947
|
}
|
|
954
948
|
if (!this.finalLayout) {
|
|
955
949
|
return super.visualize();
|
|
@@ -1051,7 +1045,7 @@ var LayoutPipelineSolver = class extends BaseSolver {
|
|
|
1051
1045
|
constructor(inputProblem) {
|
|
1052
1046
|
super();
|
|
1053
1047
|
this.inputProblem = inputProblem;
|
|
1054
|
-
this.MAX_ITERATIONS =
|
|
1048
|
+
this.MAX_ITERATIONS = 1e6;
|
|
1055
1049
|
this.startTimeOfPhase = {};
|
|
1056
1050
|
this.endTimeOfPhase = {};
|
|
1057
1051
|
this.timeSpentOnPhase = {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tscircuit/matchpack",
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.9",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
8
8
|
],
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@tscircuit/schematic-viewer": "^2.0.26",
|
|
22
22
|
"@types/bun": "latest",
|
|
23
23
|
"bpc-graph": "^0.0.66",
|
|
24
|
-
"calculate-packing": "^0.0.
|
|
24
|
+
"calculate-packing": "^0.0.28",
|
|
25
25
|
"circuit-json": "^0.0.226",
|
|
26
26
|
"graphics-debug": "^0.0.62",
|
|
27
27
|
"react-cosmos": "^7.0.0",
|