@tscircuit/capacity-autorouter 0.0.157 → 0.0.159

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 CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as graphics_debug from 'graphics-debug';
2
2
  import { GraphicsObject, Rect, Circle, Line, Point as Point$3 } from 'graphics-debug';
3
- import { Polygon } from '@tscircuit/math-utils';
4
3
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
4
+ import { RectDiffSolver } from '@tscircuit/rectdiff';
5
+ import { Polygon } from '@tscircuit/math-utils';
5
6
 
6
7
  type TraceId = string;
7
8
  type NetId = string;
@@ -165,168 +166,6 @@ declare class CapacityMeshEdgeSolver extends BaseSolver {
165
166
  visualize(): GraphicsObject;
166
167
  }
167
168
 
168
- /**
169
- * ObstacleTree wraps different spatial index implementations:
170
- * - 'native': original spatial-hash grid
171
- * - 'rbush': dynamic R-tree via rbush
172
- * - 'flatbush': static index via flatbush
173
- */
174
- declare class ObstacleSpatialHashIndex {
175
- private idx;
176
- private storage;
177
- constructor(implementation?: "native" | "rbush" | "flatbush", obstacles?: Obstacle[]);
178
- insert(o: Obstacle): void;
179
- search(bbox: {
180
- minX: number;
181
- minY: number;
182
- maxX: number;
183
- maxY: number;
184
- }): Obstacle[];
185
- searchArea(centerX: number, centerY: number, width: number, height: number): Obstacle[];
186
- }
187
-
188
- interface Target$1 {
189
- x: number;
190
- y: number;
191
- bounds: {
192
- minX: number;
193
- minY: number;
194
- maxX: number;
195
- maxY: number;
196
- };
197
- connectionName: string;
198
- availableZ: number[];
199
- }
200
- type BucketCoordinate = `${number}x${number}`;
201
- declare class TargetTree {
202
- targets: Target$1[];
203
- buckets: Map<BucketCoordinate, [Target$1, number][]>;
204
- CELL_SIZE: number;
205
- constructor(targets: Target$1[]);
206
- getBucketKey(x: number, y: number): BucketCoordinate;
207
- getTargetsInArea(centerX: number, centerY: number, width: number, height: number): Target$1[];
208
- }
209
-
210
- interface CapacityMeshNodeSolverOptions$2 {
211
- capacityDepth?: number;
212
- }
213
- interface Target {
214
- x: number;
215
- y: number;
216
- bounds: {
217
- minX: number;
218
- minY: number;
219
- maxX: number;
220
- maxY: number;
221
- };
222
- connectionName: string;
223
- availableZ: number[];
224
- }
225
- declare class CapacityMeshNodeSolver extends BaseSolver {
226
- srj: SimpleRouteJson;
227
- opts: CapacityMeshNodeSolverOptions$2;
228
- unfinishedNodes: CapacityMeshNode[];
229
- finishedNodes: CapacityMeshNode[];
230
- nodeToXYOverlappingObstaclesMap: Map<CapacityMeshNodeId, Obstacle[]>;
231
- layerCount: number;
232
- protected outlinePolygon?: Polygon;
233
- MAX_DEPTH: number;
234
- targets: Target[];
235
- targetTree: TargetTree;
236
- obstacleTree: ObstacleSpatialHashIndex;
237
- constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$2);
238
- computeTargets(): Target[];
239
- protected getNodeBounds(node: CapacityMeshNode): {
240
- minX: number;
241
- maxX: number;
242
- minY: number;
243
- maxY: number;
244
- };
245
- protected getNodeRect(node: CapacityMeshNode): {
246
- center: {
247
- x: number;
248
- y: number;
249
- };
250
- width: number;
251
- height: number;
252
- };
253
- _nextNodeCounter: number;
254
- getNextNodeId(): string;
255
- getCapacityFromDepth(depth: number): number;
256
- getTargetIfNodeContainsTarget(node: CapacityMeshNode): Target | null;
257
- getXYOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
258
- getXYZOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
259
- /**
260
- * Checks if the given mesh node overlaps with any obstacle.
261
- * We treat both obstacles and nodes as axis‐aligned rectangles.
262
- */
263
- doesNodeOverlapObstacle(node: CapacityMeshNode): boolean;
264
- /**
265
- * Checks if the entire node is contained within any obstacle.
266
- */
267
- isNodeCompletelyInsideObstacle(node: CapacityMeshNode): boolean;
268
- getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
269
- shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
270
- _step(): void;
271
- /**
272
- * Creates a GraphicsObject to visualize the mesh, its nodes, obstacles, and connection points.
273
- *
274
- * - Mesh nodes are rendered as rectangles.
275
- * - Nodes that have an obstacle intersection are outlined in red.
276
- * - Other nodes are outlined in green.
277
- * - Lines are drawn from a node to its parent.
278
- * - Obstacles are drawn as semi-transparent red rectangles.
279
- * - Points for each connection’s pointsToConnect are drawn in a unique color.
280
- */
281
- visualize(): GraphicsObject;
282
- }
283
-
284
- interface CapacityMeshNodeSolverOptions$1 {
285
- capacityDepth?: number;
286
- }
287
- declare class CapacityMeshNodeSolver2_NodeUnderObstacle extends CapacityMeshNodeSolver {
288
- srj: SimpleRouteJson;
289
- opts: CapacityMeshNodeSolverOptions$1;
290
- VIA_DIAMETER: number;
291
- OBSTACLE_MARGIN: number;
292
- /**
293
- * The threshold for the percentage of a single-layer node that must be
294
- * covered by obstacles to be considered "under an obstacle"
295
- */
296
- OVERLAP_THRESHOLD_FOR_SINGLE_LAYER_NODES: number;
297
- constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$1);
298
- isNodeCompletelyOutsideBounds(node: CapacityMeshNode): boolean;
299
- isNodePartiallyOutsideBounds(node: CapacityMeshNode): boolean;
300
- /**
301
- * Calculate the percentage of node area covered by obstacles
302
- */
303
- getObstacleCoveragePercentage(node: CapacityMeshNode): number;
304
- /**
305
- * Check if a single-layer node should be filtered due to obstacle coverage
306
- */
307
- shouldFilterSingleLayerNodeForObstacle(node: CapacityMeshNode): boolean;
308
- /**
309
- * Check if a node should be filtered due to obstacles.
310
- * Single-layer nodes: filtered only if >20% covered
311
- * Multi-layer nodes: filtered if any overlap
312
- */
313
- shouldFilterNodeForObstacle(node: CapacityMeshNode): boolean;
314
- createChildNodeAtPosition(parent: CapacityMeshNode, opts: {
315
- center: {
316
- x: number;
317
- y: number;
318
- };
319
- width: number;
320
- height: number;
321
- availableZ: number[];
322
- _depth?: number;
323
- }): CapacityMeshNode;
324
- getZSubdivisionChildNodes(node: CapacityMeshNode): CapacityMeshNode[];
325
- getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
326
- shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
327
- _step(): void;
328
- }
329
-
330
169
  interface NodePortSegment {
331
170
  capacityMeshNodeId: string;
332
171
  nodePortSegmentId?: string;
@@ -1888,6 +1727,26 @@ declare class DeadEndSolver extends BaseSolver {
1888
1727
  visualize(): GraphicsObject;
1889
1728
  }
1890
1729
 
1730
+ /**
1731
+ * ObstacleTree wraps different spatial index implementations:
1732
+ * - 'native': original spatial-hash grid
1733
+ * - 'rbush': dynamic R-tree via rbush
1734
+ * - 'flatbush': static index via flatbush
1735
+ */
1736
+ declare class ObstacleSpatialHashIndex {
1737
+ private idx;
1738
+ private storage;
1739
+ constructor(implementation?: "native" | "rbush" | "flatbush", obstacles?: Obstacle[]);
1740
+ insert(o: Obstacle): void;
1741
+ search(bbox: {
1742
+ minX: number;
1743
+ minY: number;
1744
+ maxX: number;
1745
+ maxY: number;
1746
+ }): Obstacle[];
1747
+ searchArea(centerX: number, centerY: number, width: number, height: number): Obstacle[];
1748
+ }
1749
+
1891
1750
  interface Point {
1892
1751
  x: number;
1893
1752
  y: number;
@@ -2113,7 +1972,7 @@ declare class AutoroutingPipelineSolver extends BaseSolver {
2113
1972
  srj: SimpleRouteJson;
2114
1973
  opts: CapacityMeshSolverOptions$1;
2115
1974
  netToPointPairsSolver?: NetToPointPairsSolver;
2116
- nodeSolver?: CapacityMeshNodeSolver;
1975
+ nodeSolver?: RectDiffSolver;
2117
1976
  nodeTargetMerger?: CapacityNodeTargetMerger;
2118
1977
  edgeSolver?: CapacityMeshEdgeSolver;
2119
1978
  initialPathingSolver?: CapacityPathingGreedySolver;
@@ -2144,7 +2003,7 @@ declare class AutoroutingPipelineSolver extends BaseSolver {
2144
2003
  capacityNodes: CapacityMeshNode[] | null;
2145
2004
  capacityEdges: CapacityMeshEdge[] | null;
2146
2005
  cacheProvider: CacheProvider | null;
2147
- pipelineDef: (PipelineStep$1<typeof NetToPointPairsSolver2_OffBoardConnection> | PipelineStep$1<typeof CapacityMeshNodeSolver2_NodeUnderObstacle> | PipelineStep$1<typeof SingleLayerNodeMergerSolver> | PipelineStep$1<typeof StrawSolver> | PipelineStep$1<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep$1<typeof DeadEndSolver> | PipelineStep$1<typeof CapacityPathingGreedySolver> | PipelineStep$1<typeof CapacityPathingMultiSectionSolver> | PipelineStep$1<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep$1<typeof CapacitySegmentToPointSolver> | PipelineStep$1<typeof UnravelMultiSectionSolver> | PipelineStep$1<typeof HighDensitySolver> | PipelineStep$1<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep$1<typeof UselessViaRemovalSolver> | PipelineStep$1<typeof MultiSimplifiedPathSolver> | PipelineStep$1<typeof SameNetViaMergerSolver>)[];
2006
+ pipelineDef: (PipelineStep$1<typeof NetToPointPairsSolver2_OffBoardConnection> | PipelineStep$1<typeof RectDiffSolver> | PipelineStep$1<typeof StrawSolver> | PipelineStep$1<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep$1<typeof DeadEndSolver> | PipelineStep$1<typeof CapacityPathingGreedySolver> | PipelineStep$1<typeof CapacityPathingMultiSectionSolver> | PipelineStep$1<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep$1<typeof CapacitySegmentToPointSolver> | PipelineStep$1<typeof UnravelMultiSectionSolver> | PipelineStep$1<typeof HighDensitySolver> | PipelineStep$1<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep$1<typeof UselessViaRemovalSolver> | PipelineStep$1<typeof MultiSimplifiedPathSolver> | PipelineStep$1<typeof SameNetViaMergerSolver>)[];
2148
2007
  constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions$1);
2149
2008
  currentPipelineStepIndex: number;
2150
2009
  _step(): void;
@@ -2305,6 +2164,148 @@ declare function getGlobalLocalStorageCache(): LocalStorageCache;
2305
2164
  declare function getGlobalInMemoryCache(): InMemoryCache;
2306
2165
  declare function setupGlobalCaches(): void;
2307
2166
 
2167
+ interface Target$1 {
2168
+ x: number;
2169
+ y: number;
2170
+ bounds: {
2171
+ minX: number;
2172
+ minY: number;
2173
+ maxX: number;
2174
+ maxY: number;
2175
+ };
2176
+ connectionName: string;
2177
+ availableZ: number[];
2178
+ }
2179
+ type BucketCoordinate = `${number}x${number}`;
2180
+ declare class TargetTree {
2181
+ targets: Target$1[];
2182
+ buckets: Map<BucketCoordinate, [Target$1, number][]>;
2183
+ CELL_SIZE: number;
2184
+ constructor(targets: Target$1[]);
2185
+ getBucketKey(x: number, y: number): BucketCoordinate;
2186
+ getTargetsInArea(centerX: number, centerY: number, width: number, height: number): Target$1[];
2187
+ }
2188
+
2189
+ interface CapacityMeshNodeSolverOptions$2 {
2190
+ capacityDepth?: number;
2191
+ }
2192
+ interface Target {
2193
+ x: number;
2194
+ y: number;
2195
+ bounds: {
2196
+ minX: number;
2197
+ minY: number;
2198
+ maxX: number;
2199
+ maxY: number;
2200
+ };
2201
+ connectionName: string;
2202
+ availableZ: number[];
2203
+ }
2204
+ declare class CapacityMeshNodeSolver extends BaseSolver {
2205
+ srj: SimpleRouteJson;
2206
+ opts: CapacityMeshNodeSolverOptions$2;
2207
+ unfinishedNodes: CapacityMeshNode[];
2208
+ finishedNodes: CapacityMeshNode[];
2209
+ nodeToXYOverlappingObstaclesMap: Map<CapacityMeshNodeId, Obstacle[]>;
2210
+ layerCount: number;
2211
+ protected outlinePolygon?: Polygon;
2212
+ MAX_DEPTH: number;
2213
+ targets: Target[];
2214
+ targetTree: TargetTree;
2215
+ obstacleTree: ObstacleSpatialHashIndex;
2216
+ constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$2);
2217
+ computeTargets(): Target[];
2218
+ protected getNodeBounds(node: CapacityMeshNode): {
2219
+ minX: number;
2220
+ maxX: number;
2221
+ minY: number;
2222
+ maxY: number;
2223
+ };
2224
+ protected getNodeRect(node: CapacityMeshNode): {
2225
+ center: {
2226
+ x: number;
2227
+ y: number;
2228
+ };
2229
+ width: number;
2230
+ height: number;
2231
+ };
2232
+ _nextNodeCounter: number;
2233
+ getNextNodeId(): string;
2234
+ getCapacityFromDepth(depth: number): number;
2235
+ getTargetIfNodeContainsTarget(node: CapacityMeshNode): Target | null;
2236
+ getXYOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
2237
+ getXYZOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
2238
+ /**
2239
+ * Checks if the given mesh node overlaps with any obstacle.
2240
+ * We treat both obstacles and nodes as axis‐aligned rectangles.
2241
+ */
2242
+ doesNodeOverlapObstacle(node: CapacityMeshNode): boolean;
2243
+ /**
2244
+ * Checks if the entire node is contained within any obstacle.
2245
+ */
2246
+ isNodeCompletelyInsideObstacle(node: CapacityMeshNode): boolean;
2247
+ getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
2248
+ shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
2249
+ _step(): void;
2250
+ /**
2251
+ * Creates a GraphicsObject to visualize the mesh, its nodes, obstacles, and connection points.
2252
+ *
2253
+ * - Mesh nodes are rendered as rectangles.
2254
+ * - Nodes that have an obstacle intersection are outlined in red.
2255
+ * - Other nodes are outlined in green.
2256
+ * - Lines are drawn from a node to its parent.
2257
+ * - Obstacles are drawn as semi-transparent red rectangles.
2258
+ * - Points for each connection’s pointsToConnect are drawn in a unique color.
2259
+ */
2260
+ visualize(): GraphicsObject;
2261
+ }
2262
+
2263
+ interface CapacityMeshNodeSolverOptions$1 {
2264
+ capacityDepth?: number;
2265
+ }
2266
+ declare class CapacityMeshNodeSolver2_NodeUnderObstacle extends CapacityMeshNodeSolver {
2267
+ srj: SimpleRouteJson;
2268
+ opts: CapacityMeshNodeSolverOptions$1;
2269
+ VIA_DIAMETER: number;
2270
+ OBSTACLE_MARGIN: number;
2271
+ /**
2272
+ * The threshold for the percentage of a single-layer node that must be
2273
+ * covered by obstacles to be considered "under an obstacle"
2274
+ */
2275
+ OVERLAP_THRESHOLD_FOR_SINGLE_LAYER_NODES: number;
2276
+ constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$1);
2277
+ isNodeCompletelyOutsideBounds(node: CapacityMeshNode): boolean;
2278
+ isNodePartiallyOutsideBounds(node: CapacityMeshNode): boolean;
2279
+ /**
2280
+ * Calculate the percentage of node area covered by obstacles
2281
+ */
2282
+ getObstacleCoveragePercentage(node: CapacityMeshNode): number;
2283
+ /**
2284
+ * Check if a single-layer node should be filtered due to obstacle coverage
2285
+ */
2286
+ shouldFilterSingleLayerNodeForObstacle(node: CapacityMeshNode): boolean;
2287
+ /**
2288
+ * Check if a node should be filtered due to obstacles.
2289
+ * Single-layer nodes: filtered only if >20% covered
2290
+ * Multi-layer nodes: filtered if any overlap
2291
+ */
2292
+ shouldFilterNodeForObstacle(node: CapacityMeshNode): boolean;
2293
+ createChildNodeAtPosition(parent: CapacityMeshNode, opts: {
2294
+ center: {
2295
+ x: number;
2296
+ y: number;
2297
+ };
2298
+ width: number;
2299
+ height: number;
2300
+ availableZ: number[];
2301
+ _depth?: number;
2302
+ }): CapacityMeshNode;
2303
+ getZSubdivisionChildNodes(node: CapacityMeshNode): CapacityMeshNode[];
2304
+ getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
2305
+ shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
2306
+ _step(): void;
2307
+ }
2308
+
2308
2309
  interface CapacityMeshNodeSolverOptions {
2309
2310
  capacityDepth?: number;
2310
2311
  }