calculate-packing 0.0.12 → 0.0.13
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 +49 -28
- package/dist/index.js +1090 -736
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphicsObject, Point } from 'graphics-debug';
|
|
1
|
+
import { GraphicsObject, Point as Point$1 } from 'graphics-debug';
|
|
2
2
|
import { CircuitJson } from 'circuit-json';
|
|
3
3
|
|
|
4
4
|
type ComponentId = string;
|
|
@@ -36,6 +36,7 @@ interface PackedComponent extends InputComponent {
|
|
|
36
36
|
x: number;
|
|
37
37
|
y: number;
|
|
38
38
|
};
|
|
39
|
+
/** Rotation in degrees (counterclockwise) */
|
|
39
40
|
ccwRotationOffset: number;
|
|
40
41
|
pads: OutputPad[];
|
|
41
42
|
}
|
|
@@ -43,7 +44,7 @@ interface PackInput {
|
|
|
43
44
|
components: InputComponent[];
|
|
44
45
|
minGap: number;
|
|
45
46
|
packOrderStrategy: "largest_to_smallest";
|
|
46
|
-
packPlacementStrategy: "shortest_connection_along_outline" | "minimum_sum_distance_to_network";
|
|
47
|
+
packPlacementStrategy: "shortest_connection_along_outline" | "minimum_sum_distance_to_network" | "minimum_sum_squared_distance_to_network";
|
|
47
48
|
disconnectedPackDirection?: "left" | "right" | "up" | "down" | "nearest_to_center";
|
|
48
49
|
packFirst?: ComponentId[];
|
|
49
50
|
}
|
|
@@ -101,46 +102,66 @@ declare class BaseSolver {
|
|
|
101
102
|
preview(): GraphicsObject;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*/
|
|
119
|
-
declare class PackSolver extends BaseSolver {
|
|
105
|
+
type Point = {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
};
|
|
109
|
+
type Segment = [Point, Point];
|
|
110
|
+
|
|
111
|
+
type PackingPhase = "idle" | "show_candidate_points" | "show_rotations" | "show_final_placement";
|
|
112
|
+
interface RotationTrial extends PackedComponent {
|
|
113
|
+
cost: number;
|
|
114
|
+
anchorType: "pad" | "center";
|
|
115
|
+
anchorPadId?: string;
|
|
116
|
+
hasOverlap: boolean;
|
|
117
|
+
}
|
|
118
|
+
declare class PhasedPackSolver extends BaseSolver {
|
|
120
119
|
packInput: PackInput;
|
|
121
120
|
unpackedComponentQueue: InputComponent[];
|
|
122
121
|
packedComponents: PackedComponent[];
|
|
122
|
+
currentPhase: PackingPhase;
|
|
123
|
+
currentComponent?: InputComponent;
|
|
124
|
+
phaseData: {
|
|
125
|
+
candidatePoints?: Array<Point$1 & {
|
|
126
|
+
networkId: NetworkId;
|
|
127
|
+
distance: number;
|
|
128
|
+
}>;
|
|
129
|
+
goodCandidates?: Array<Point$1 & {
|
|
130
|
+
networkId: NetworkId;
|
|
131
|
+
}>;
|
|
132
|
+
bestDistance?: number;
|
|
133
|
+
rotationTrials?: Array<RotationTrial>;
|
|
134
|
+
selectedRotation?: PackedComponent;
|
|
135
|
+
outlines?: Segment[][];
|
|
136
|
+
};
|
|
123
137
|
lastBestPointsResult?: {
|
|
124
|
-
|
|
138
|
+
goodCandidates: (Point$1 & {
|
|
125
139
|
networkId: NetworkId;
|
|
126
140
|
})[];
|
|
127
141
|
distance: number;
|
|
128
142
|
};
|
|
129
143
|
lastEvaluatedPositionShadows?: Array<PackedComponent>;
|
|
144
|
+
lastCandidatePoints?: Array<Point$1 & {
|
|
145
|
+
networkId: NetworkId;
|
|
146
|
+
distance: number;
|
|
147
|
+
}>;
|
|
130
148
|
constructor(input: PackInput);
|
|
131
149
|
_setup(): void;
|
|
132
150
|
_step(): void;
|
|
151
|
+
private placeFirstComponent;
|
|
152
|
+
private computeCandidatePoints;
|
|
153
|
+
private computeRotationTrials;
|
|
154
|
+
private selectBestRotation;
|
|
155
|
+
private finalizeComponentPlacement;
|
|
156
|
+
/** Visualize the current packing state based on the current phase */
|
|
157
|
+
visualize(): GraphicsObject;
|
|
158
|
+
private visualizeCandidatePoints;
|
|
159
|
+
private visualizeRotationTrials;
|
|
160
|
+
private visualizeFinalPlacement;
|
|
133
161
|
getConstructorParams(): PackInput[];
|
|
162
|
+
getResult(): PackedComponent[];
|
|
134
163
|
private getCandidateAngles;
|
|
135
164
|
private checkOverlapWithPackedComponents;
|
|
136
|
-
private computeGlobalCenter;
|
|
137
|
-
private findBestPointForDisconnected;
|
|
138
|
-
private placeComponentAtPoint;
|
|
139
|
-
private placeComponentDisconnected;
|
|
140
|
-
/** Visualize the current packing state – components are omitted, only the outline is shown. */
|
|
141
|
-
visualize(): GraphicsObject;
|
|
142
|
-
getResult(): PackedComponent[];
|
|
143
|
-
private computeSumDistanceForPosition;
|
|
144
165
|
}
|
|
145
166
|
|
|
146
167
|
declare const convertCircuitJsonToPackOutput: (circuitJson: CircuitJson, opts?: {
|
|
@@ -164,4 +185,4 @@ declare const getGraphicsFromPackOutput: (packOutput: PackOutput) => GraphicsObj
|
|
|
164
185
|
*/
|
|
165
186
|
declare const convertPackOutputToPackInput: (packed: PackOutput) => PackInput;
|
|
166
187
|
|
|
167
|
-
export { type ComponentId, type InputComponent, type InputPad, type NetworkId, type OutputPad, type PackInput, type PackOutput,
|
|
188
|
+
export { type ComponentId, type InputComponent, type InputPad, type NetworkId, type OutputPad, type PackInput, type PackOutput, type PackedComponent, type PadId, PhasedPackSolver, convertCircuitJsonToPackOutput, convertPackOutputToPackInput, getGraphicsFromPackOutput, pack };
|