@tscircuit/rectdiff 0.0.13 → 0.0.15
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 +16 -12
- package/dist/index.js +272 -141
- package/lib/RectDiffPipeline.ts +0 -1
- package/lib/solvers/RectDiffExpansionSolver/RectDiffExpansionSolver.ts +59 -12
- package/lib/solvers/RectDiffGridSolverPipeline/RectDiffGridSolverPipeline.ts +25 -6
- package/lib/solvers/RectDiffGridSolverPipeline/buildObstacleIndexes.ts +70 -0
- package/lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts +41 -86
- package/lib/solvers/RectDiffSeedingSolver/computeCandidates3D.ts +15 -15
- package/lib/solvers/RectDiffSeedingSolver/computeEdgeCandidates3D.ts +16 -16
- package/lib/solvers/RectDiffSeedingSolver/longestFreeSpanAroundZ.ts +17 -9
- package/lib/types/capacity-mesh-types.ts +9 -0
- package/lib/utils/finalizeRects.ts +25 -20
- package/lib/utils/getColorForZLayer.ts +17 -0
- package/lib/utils/isFullyOccupiedAtPoint.ts +23 -16
- package/lib/utils/rectToTree.ts +10 -0
- package/lib/utils/resizeSoftOverlaps.ts +36 -7
- package/lib/utils/sameTreeRect.ts +7 -0
- package/package.json +1 -1
- package/tests/examples/example01.test.tsx +18 -1
- package/tests/fixtures/getPerLayerVisualizations.ts +130 -0
- package/tests/fixtures/makeCapacityMeshNodeWithLayerInfo.ts +33 -0
- package/tests/solver/__snapshots__/rectDiffGridSolverPipeline.snap.svg +44 -0
- package/tests/solver/rectDiffGridSolverPipeline.test.ts +88 -0
package/dist/index.d.ts
CHANGED
|
@@ -108,6 +108,12 @@ interface CapacityMeshNode {
|
|
|
108
108
|
_adjacentNodeIds?: CapacityMeshNodeId[];
|
|
109
109
|
_parent?: CapacityMeshNode;
|
|
110
110
|
}
|
|
111
|
+
type RTreeRect = XYRect & {
|
|
112
|
+
minX: number;
|
|
113
|
+
minY: number;
|
|
114
|
+
maxX: number;
|
|
115
|
+
maxY: number;
|
|
116
|
+
};
|
|
111
117
|
|
|
112
118
|
interface SegmentWithAdjacentEmptySpace {
|
|
113
119
|
parent: CapacityMeshNode;
|
|
@@ -200,7 +206,9 @@ declare class GapFillSolverPipeline extends BasePipelineSolver<{
|
|
|
200
206
|
|
|
201
207
|
type RectDiffSeedingSolverInput = {
|
|
202
208
|
simpleRouteJson: SimpleRouteJson;
|
|
209
|
+
obstacleIndexByLayer: Array<RBush<RTreeRect>>;
|
|
203
210
|
gridOptions?: Partial<GridFill3DOptions>;
|
|
211
|
+
boardVoidRects?: XYRect[];
|
|
204
212
|
};
|
|
205
213
|
/**
|
|
206
214
|
* First phase of RectDiff: grid-based seeding and placement.
|
|
@@ -215,12 +223,11 @@ declare class RectDiffSeedingSolver extends BaseSolver {
|
|
|
215
223
|
private layerCount;
|
|
216
224
|
private bounds;
|
|
217
225
|
private options;
|
|
218
|
-
private
|
|
219
|
-
private boardVoidRects;
|
|
226
|
+
private boardVoidRects?;
|
|
220
227
|
private gridIndex;
|
|
221
228
|
private candidates;
|
|
222
229
|
private placed;
|
|
223
|
-
private
|
|
230
|
+
private placedIndexByLayer;
|
|
224
231
|
private expansionIndex;
|
|
225
232
|
private edgeAnalysisDone;
|
|
226
233
|
private totalSeedsThisGrid;
|
|
@@ -248,19 +255,15 @@ declare class RectDiffSeedingSolver extends BaseSolver {
|
|
|
248
255
|
gridSizes: number[];
|
|
249
256
|
maxMultiLayerSpan: number | undefined;
|
|
250
257
|
};
|
|
251
|
-
|
|
252
|
-
boardVoidRects: XYRect[];
|
|
258
|
+
boardVoidRects: XYRect[] | undefined;
|
|
253
259
|
gridIndex: number;
|
|
254
260
|
candidates: Candidate3D[];
|
|
255
261
|
placed: Placed3D[];
|
|
256
|
-
placedByLayer: XYRect[][];
|
|
257
262
|
expansionIndex: number;
|
|
258
263
|
edgeAnalysisDone: boolean;
|
|
259
264
|
totalSeedsThisGrid: number;
|
|
260
265
|
consumedSeedsThisGrid: number;
|
|
261
266
|
};
|
|
262
|
-
/** Get color based on z layer for visualization. */
|
|
263
|
-
private getColorForZLayer;
|
|
264
267
|
/** Visualization focused on the grid seeding phase. */
|
|
265
268
|
visualize(): GraphicsObject;
|
|
266
269
|
}
|
|
@@ -274,12 +277,10 @@ type RectDiffExpansionSolverSnapshot = {
|
|
|
274
277
|
gridSizes: number[];
|
|
275
278
|
[key: string]: any;
|
|
276
279
|
};
|
|
277
|
-
obstaclesByLayer: XYRect[][];
|
|
278
280
|
boardVoidRects: XYRect[];
|
|
279
281
|
gridIndex: number;
|
|
280
282
|
candidates: Candidate3D[];
|
|
281
283
|
placed: Placed3D[];
|
|
282
|
-
placedByLayer: XYRect[][];
|
|
283
284
|
expansionIndex: number;
|
|
284
285
|
edgeAnalysisDone: boolean;
|
|
285
286
|
totalSeedsThisGrid: number;
|
|
@@ -287,6 +288,7 @@ type RectDiffExpansionSolverSnapshot = {
|
|
|
287
288
|
};
|
|
288
289
|
type RectDiffExpansionSolverInput = {
|
|
289
290
|
initialSnapshot: RectDiffExpansionSolverSnapshot;
|
|
291
|
+
obstacleIndexByLayer: Array<RBush<RTreeRect>>;
|
|
290
292
|
};
|
|
291
293
|
/**
|
|
292
294
|
* Second phase of RectDiff: expand placed rects to their maximal extents.
|
|
@@ -301,12 +303,11 @@ declare class RectDiffExpansionSolver extends BaseSolver {
|
|
|
301
303
|
private layerCount;
|
|
302
304
|
private bounds;
|
|
303
305
|
private options;
|
|
304
|
-
private obstaclesByLayer;
|
|
305
306
|
private boardVoidRects;
|
|
306
307
|
private gridIndex;
|
|
307
308
|
private candidates;
|
|
308
309
|
private placed;
|
|
309
|
-
private
|
|
310
|
+
private placedIndexByLayer;
|
|
310
311
|
private expansionIndex;
|
|
311
312
|
private edgeAnalysisDone;
|
|
312
313
|
private totalSeedsThisGrid;
|
|
@@ -332,6 +333,9 @@ type RectDiffGridSolverPipelineInput = {
|
|
|
332
333
|
declare class RectDiffGridSolverPipeline extends BasePipelineSolver<RectDiffGridSolverPipelineInput> {
|
|
333
334
|
rectDiffSeedingSolver?: RectDiffSeedingSolver;
|
|
334
335
|
rectDiffExpansionSolver?: RectDiffExpansionSolver;
|
|
336
|
+
private boardVoidRects?;
|
|
337
|
+
private obstacleIndexByLayer;
|
|
338
|
+
constructor(inputProblem: RectDiffGridSolverPipelineInput);
|
|
335
339
|
pipelineDef: PipelineStep<any>[];
|
|
336
340
|
getConstructorParams(): RectDiffGridSolverPipelineInput[];
|
|
337
341
|
getOutput(): {
|