@tscircuit/capacity-autorouter 0.0.260 → 0.0.262

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
@@ -3,10 +3,10 @@ import { GraphicsObject, Rect, Circle, Line, Point as Point$5 } from 'graphics-d
3
3
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
4
4
  import { RectDiffPipeline } from '@tscircuit/rectdiff';
5
5
  import { BaseSolver as BaseSolver$1 } from '@tscircuit/solver-utils';
6
+ import { Polygon } from '@tscircuit/math-utils';
6
7
  import { JumperGraphSolver, JRegion, JPort } from '@tscircuit/hypergraph';
7
8
  import { CurvyTraceSolver } from '@tscircuit/curvy-trace-solver';
8
9
  import { ConnectivityMap as ConnectivityMap$1 } from 'connectivity-map';
9
- import { Polygon } from '@tscircuit/math-utils';
10
10
 
11
11
  type TraceId = string;
12
12
  type NetId = string;
@@ -2161,6 +2161,168 @@ declare class AutoroutingPipelineSolver2_PortPointPathing extends BaseSolver {
2161
2161
  declare const CapacityMeshSolver: typeof AutoroutingPipelineSolver2_PortPointPathing;
2162
2162
  type CapacityMeshSolver = AutoroutingPipelineSolver2_PortPointPathing;
2163
2163
 
2164
+ /**
2165
+ * ObstacleTree wraps different spatial index implementations:
2166
+ * - 'native': original spatial-hash grid
2167
+ * - 'rbush': dynamic R-tree via rbush
2168
+ * - 'flatbush': static index via flatbush
2169
+ */
2170
+ declare class ObstacleSpatialHashIndex {
2171
+ private idx;
2172
+ private storage;
2173
+ constructor(implementation?: "native" | "rbush" | "flatbush", obstacles?: Obstacle[]);
2174
+ insert(o: Obstacle): void;
2175
+ search(bbox: {
2176
+ minX: number;
2177
+ minY: number;
2178
+ maxX: number;
2179
+ maxY: number;
2180
+ }): Obstacle[];
2181
+ searchArea(centerX: number, centerY: number, width: number, height: number): Obstacle[];
2182
+ }
2183
+
2184
+ interface Target$1 {
2185
+ x: number;
2186
+ y: number;
2187
+ bounds: {
2188
+ minX: number;
2189
+ minY: number;
2190
+ maxX: number;
2191
+ maxY: number;
2192
+ };
2193
+ connectionName: string;
2194
+ availableZ: number[];
2195
+ }
2196
+ type BucketCoordinate$1 = `${number}x${number}`;
2197
+ declare class TargetTree {
2198
+ targets: Target$1[];
2199
+ buckets: Map<BucketCoordinate$1, [Target$1, number][]>;
2200
+ CELL_SIZE: number;
2201
+ constructor(targets: Target$1[]);
2202
+ getBucketKey(x: number, y: number): BucketCoordinate$1;
2203
+ getTargetsInArea(centerX: number, centerY: number, width: number, height: number): Target$1[];
2204
+ }
2205
+
2206
+ interface CapacityMeshNodeSolverOptions$2 {
2207
+ capacityDepth?: number;
2208
+ }
2209
+ interface Target {
2210
+ x: number;
2211
+ y: number;
2212
+ bounds: {
2213
+ minX: number;
2214
+ minY: number;
2215
+ maxX: number;
2216
+ maxY: number;
2217
+ };
2218
+ connectionName: string;
2219
+ availableZ: number[];
2220
+ }
2221
+ declare class CapacityMeshNodeSolver extends BaseSolver {
2222
+ srj: SimpleRouteJson;
2223
+ opts: CapacityMeshNodeSolverOptions$2;
2224
+ unfinishedNodes: CapacityMeshNode[];
2225
+ finishedNodes: CapacityMeshNode[];
2226
+ nodeToXYOverlappingObstaclesMap: Map<CapacityMeshNodeId, Obstacle[]>;
2227
+ layerCount: number;
2228
+ protected outlinePolygon?: Polygon;
2229
+ MAX_DEPTH: number;
2230
+ targets: Target[];
2231
+ targetTree: TargetTree;
2232
+ obstacleTree: ObstacleSpatialHashIndex;
2233
+ constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$2);
2234
+ computeTargets(): Target[];
2235
+ protected getNodeBounds(node: CapacityMeshNode): {
2236
+ minX: number;
2237
+ maxX: number;
2238
+ minY: number;
2239
+ maxY: number;
2240
+ };
2241
+ protected getNodeRect(node: CapacityMeshNode): {
2242
+ center: {
2243
+ x: number;
2244
+ y: number;
2245
+ };
2246
+ width: number;
2247
+ height: number;
2248
+ };
2249
+ _nextNodeCounter: number;
2250
+ getNextNodeId(): string;
2251
+ getCapacityFromDepth(depth: number): number;
2252
+ getTargetIfNodeContainsTarget(node: CapacityMeshNode): Target | null;
2253
+ getXYOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
2254
+ getXYZOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
2255
+ /**
2256
+ * Checks if the given mesh node overlaps with any obstacle.
2257
+ * We treat both obstacles and nodes as axis‐aligned rectangles.
2258
+ */
2259
+ doesNodeOverlapObstacle(node: CapacityMeshNode): boolean;
2260
+ /**
2261
+ * Checks if the entire node is contained within any obstacle.
2262
+ */
2263
+ isNodeCompletelyInsideObstacle(node: CapacityMeshNode): boolean;
2264
+ getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
2265
+ shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
2266
+ _step(): void;
2267
+ /**
2268
+ * Creates a GraphicsObject to visualize the mesh, its nodes, obstacles, and connection points.
2269
+ *
2270
+ * - Mesh nodes are rendered as rectangles.
2271
+ * - Nodes that have an obstacle intersection are outlined in red.
2272
+ * - Other nodes are outlined in green.
2273
+ * - Lines are drawn from a node to its parent.
2274
+ * - Obstacles are drawn as semi-transparent red rectangles.
2275
+ * - Points for each connection’s pointsToConnect are drawn in a unique color.
2276
+ */
2277
+ visualize(): GraphicsObject;
2278
+ }
2279
+
2280
+ interface CapacityMeshNodeSolverOptions$1 {
2281
+ capacityDepth?: number;
2282
+ }
2283
+ declare class CapacityMeshNodeSolver2_NodeUnderObstacle extends CapacityMeshNodeSolver {
2284
+ srj: SimpleRouteJson;
2285
+ opts: CapacityMeshNodeSolverOptions$1;
2286
+ VIA_DIAMETER: number;
2287
+ OBSTACLE_MARGIN: number;
2288
+ /**
2289
+ * The threshold for the percentage of a single-layer node that must be
2290
+ * covered by obstacles to be considered "under an obstacle"
2291
+ */
2292
+ OVERLAP_THRESHOLD_FOR_SINGLE_LAYER_NODES: number;
2293
+ constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$1);
2294
+ isNodeCompletelyOutsideBounds(node: CapacityMeshNode): boolean;
2295
+ isNodePartiallyOutsideBounds(node: CapacityMeshNode): boolean;
2296
+ /**
2297
+ * Calculate the percentage of node area covered by obstacles
2298
+ */
2299
+ getObstacleCoveragePercentage(node: CapacityMeshNode): number;
2300
+ /**
2301
+ * Check if a single-layer node should be filtered due to obstacle coverage
2302
+ */
2303
+ shouldFilterSingleLayerNodeForObstacle(node: CapacityMeshNode): boolean;
2304
+ /**
2305
+ * Check if a node should be filtered due to obstacles.
2306
+ * Single-layer nodes: filtered only if >20% covered
2307
+ * Multi-layer nodes: filtered if any overlap
2308
+ */
2309
+ shouldFilterNodeForObstacle(node: CapacityMeshNode): boolean;
2310
+ createChildNodeAtPosition(parent: CapacityMeshNode, opts: {
2311
+ center: {
2312
+ x: number;
2313
+ y: number;
2314
+ };
2315
+ width: number;
2316
+ height: number;
2317
+ availableZ: number[];
2318
+ _depth?: number;
2319
+ }): CapacityMeshNode;
2320
+ getZSubdivisionChildNodes(node: CapacityMeshNode): CapacityMeshNode[];
2321
+ getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
2322
+ shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
2323
+ _step(): void;
2324
+ }
2325
+
2164
2326
  interface NodePortSegment {
2165
2327
  capacityMeshNodeId: string;
2166
2328
  nodePortSegmentId?: string;
@@ -2950,6 +3112,21 @@ declare class CapacityPathingMultiSectionSolver extends BaseSolver {
2950
3112
  visualize(): graphics_debug.GraphicsObject;
2951
3113
  }
2952
3114
 
3115
+ /**
3116
+ * A simplified version of MultipleHighDensityRouteStitchSolver that doesn't handle
3117
+ * off-board routing cases. It always uses the connection's pointsToConnect directly
3118
+ * instead of analyzing possible endpoints from route islands.
3119
+ */
3120
+ declare class NoOffBoardMultipleHighDensityRouteStitchSolver extends MultipleHighDensityRouteStitchSolver {
3121
+ constructor(params: {
3122
+ connections: SimpleRouteConnection[];
3123
+ hdRoutes: any[];
3124
+ colorMap?: Record<string, string>;
3125
+ layerCount: number;
3126
+ defaultViaDiameter?: number;
3127
+ });
3128
+ }
3129
+
2953
3130
  interface CapacityMeshSolverOptions$3 {
2954
3131
  capacityDepth?: number;
2955
3132
  targetMinCapacity?: number;
@@ -2965,7 +3142,7 @@ declare class AutoroutingPipeline1_OriginalUnravel extends BaseSolver {
2965
3142
  srj: SimpleRouteJson;
2966
3143
  opts: CapacityMeshSolverOptions$3;
2967
3144
  netToPointPairsSolver?: NetToPointPairsSolver;
2968
- nodeSolver?: RectDiffPipeline;
3145
+ nodeSolver?: CapacityMeshNodeSolver;
2969
3146
  nodeTargetMerger?: CapacityNodeTargetMerger;
2970
3147
  edgeSolver?: CapacityMeshEdgeSolver;
2971
3148
  initialPathingSolver?: CapacityPathingGreedySolver;
@@ -2976,7 +3153,7 @@ declare class AutoroutingPipeline1_OriginalUnravel extends BaseSolver {
2976
3153
  unravelMultiSectionSolver?: UnravelMultiSectionSolver;
2977
3154
  segmentToPointOptimizer?: CapacitySegmentPointOptimizer;
2978
3155
  highDensityRouteSolver?: HighDensitySolver;
2979
- highDensityStitchSolver?: MultipleHighDensityRouteStitchSolver;
3156
+ highDensityStitchSolver?: NoOffBoardMultipleHighDensityRouteStitchSolver;
2980
3157
  singleLayerNodeMerger?: SingleLayerNodeMergerSolver;
2981
3158
  strawSolver?: StrawSolver;
2982
3159
  deadEndSolver?: DeadEndSolver;
@@ -2992,7 +3169,7 @@ declare class AutoroutingPipeline1_OriginalUnravel extends BaseSolver {
2992
3169
  capacityNodes: CapacityMeshNode[] | null;
2993
3170
  capacityEdges: CapacityMeshEdge[] | null;
2994
3171
  cacheProvider: CacheProvider | null;
2995
- pipelineDef: (PipelineStep$3<typeof NetToPointPairsSolver2_OffBoardConnection> | PipelineStep$3<typeof RectDiffPipeline> | PipelineStep$3<typeof StrawSolver> | PipelineStep$3<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep$3<typeof DeadEndSolver> | PipelineStep$3<typeof CapacityPathingGreedySolver> | PipelineStep$3<typeof CapacityPathingMultiSectionSolver> | PipelineStep$3<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep$3<typeof CapacitySegmentToPointSolver> | PipelineStep$3<typeof UnravelMultiSectionSolver> | PipelineStep$3<typeof HighDensitySolver> | PipelineStep$3<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep$3<typeof TraceSimplificationSolver>)[];
3172
+ pipelineDef: (PipelineStep$3<typeof NetToPointPairsSolver2_OffBoardConnection> | PipelineStep$3<typeof CapacityMeshNodeSolver2_NodeUnderObstacle> | PipelineStep$3<typeof SingleLayerNodeMergerSolver> | PipelineStep$3<typeof StrawSolver> | PipelineStep$3<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep$3<typeof DeadEndSolver> | PipelineStep$3<typeof CapacityPathingGreedySolver> | PipelineStep$3<typeof CapacityPathingMultiSectionSolver> | PipelineStep$3<typeof CapacityEdgeToPortSegmentSolver> | PipelineStep$3<typeof CapacitySegmentToPointSolver> | PipelineStep$3<typeof UnravelMultiSectionSolver> | PipelineStep$3<typeof HighDensitySolver> | PipelineStep$3<typeof NoOffBoardMultipleHighDensityRouteStitchSolver> | PipelineStep$3<typeof TraceSimplificationSolver>)[];
2996
3173
  constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions$3);
2997
3174
  getConstructorParams(): readonly [SimpleRouteJson, CapacityMeshSolverOptions$3];
2998
3175
  currentPipelineStepIndex: number;
@@ -3402,26 +3579,6 @@ declare class JumperHighDensitySolver extends BaseSolver {
3402
3579
  visualize(): GraphicsObject;
3403
3580
  }
3404
3581
 
3405
- /**
3406
- * ObstacleTree wraps different spatial index implementations:
3407
- * - 'native': original spatial-hash grid
3408
- * - 'rbush': dynamic R-tree via rbush
3409
- * - 'flatbush': static index via flatbush
3410
- */
3411
- declare class ObstacleSpatialHashIndex {
3412
- private idx;
3413
- private storage;
3414
- constructor(implementation?: "native" | "rbush" | "flatbush", obstacles?: Obstacle[]);
3415
- insert(o: Obstacle): void;
3416
- search(bbox: {
3417
- minX: number;
3418
- minY: number;
3419
- maxX: number;
3420
- maxY: number;
3421
- }): Obstacle[];
3422
- searchArea(centerX: number, centerY: number, width: number, height: number): Obstacle[];
3423
- }
3424
-
3425
3582
  interface Point$1 {
3426
3583
  x: number;
3427
3584
  y: number;
@@ -3793,13 +3950,13 @@ declare class PortPointOffboardPathFragmentSolver extends BaseSolver {
3793
3950
  visualize(): GraphicsObject;
3794
3951
  }
3795
3952
 
3796
- type BucketCoordinate$1 = `${number}x${number}`;
3953
+ type BucketCoordinate = `${number}x${number}`;
3797
3954
  declare class CapacityNodeTree {
3798
3955
  nodes: CapacityMeshNode[];
3799
- buckets: Map<BucketCoordinate$1, CapacityMeshNode[]>;
3956
+ buckets: Map<BucketCoordinate, CapacityMeshNode[]>;
3800
3957
  CELL_SIZE: number;
3801
3958
  constructor(nodes: CapacityMeshNode[]);
3802
- getBucketKey(x: number, y: number): BucketCoordinate$1;
3959
+ getBucketKey(x: number, y: number): BucketCoordinate;
3803
3960
  getNodesInArea(centerX: number, centerY: number, width: number, height: number): CapacityMeshNode[];
3804
3961
  }
3805
3962
 
@@ -4180,148 +4337,6 @@ declare function getGlobalLocalStorageCache(): LocalStorageCache;
4180
4337
  declare function getGlobalInMemoryCache(): InMemoryCache;
4181
4338
  declare function setupGlobalCaches(): void;
4182
4339
 
4183
- interface Target$1 {
4184
- x: number;
4185
- y: number;
4186
- bounds: {
4187
- minX: number;
4188
- minY: number;
4189
- maxX: number;
4190
- maxY: number;
4191
- };
4192
- connectionName: string;
4193
- availableZ: number[];
4194
- }
4195
- type BucketCoordinate = `${number}x${number}`;
4196
- declare class TargetTree {
4197
- targets: Target$1[];
4198
- buckets: Map<BucketCoordinate, [Target$1, number][]>;
4199
- CELL_SIZE: number;
4200
- constructor(targets: Target$1[]);
4201
- getBucketKey(x: number, y: number): BucketCoordinate;
4202
- getTargetsInArea(centerX: number, centerY: number, width: number, height: number): Target$1[];
4203
- }
4204
-
4205
- interface CapacityMeshNodeSolverOptions$2 {
4206
- capacityDepth?: number;
4207
- }
4208
- interface Target {
4209
- x: number;
4210
- y: number;
4211
- bounds: {
4212
- minX: number;
4213
- minY: number;
4214
- maxX: number;
4215
- maxY: number;
4216
- };
4217
- connectionName: string;
4218
- availableZ: number[];
4219
- }
4220
- declare class CapacityMeshNodeSolver extends BaseSolver {
4221
- srj: SimpleRouteJson;
4222
- opts: CapacityMeshNodeSolverOptions$2;
4223
- unfinishedNodes: CapacityMeshNode[];
4224
- finishedNodes: CapacityMeshNode[];
4225
- nodeToXYOverlappingObstaclesMap: Map<CapacityMeshNodeId, Obstacle[]>;
4226
- layerCount: number;
4227
- protected outlinePolygon?: Polygon;
4228
- MAX_DEPTH: number;
4229
- targets: Target[];
4230
- targetTree: TargetTree;
4231
- obstacleTree: ObstacleSpatialHashIndex;
4232
- constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$2);
4233
- computeTargets(): Target[];
4234
- protected getNodeBounds(node: CapacityMeshNode): {
4235
- minX: number;
4236
- maxX: number;
4237
- minY: number;
4238
- maxY: number;
4239
- };
4240
- protected getNodeRect(node: CapacityMeshNode): {
4241
- center: {
4242
- x: number;
4243
- y: number;
4244
- };
4245
- width: number;
4246
- height: number;
4247
- };
4248
- _nextNodeCounter: number;
4249
- getNextNodeId(): string;
4250
- getCapacityFromDepth(depth: number): number;
4251
- getTargetIfNodeContainsTarget(node: CapacityMeshNode): Target | null;
4252
- getXYOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
4253
- getXYZOverlappingObstacles(node: CapacityMeshNode): Obstacle[];
4254
- /**
4255
- * Checks if the given mesh node overlaps with any obstacle.
4256
- * We treat both obstacles and nodes as axis‐aligned rectangles.
4257
- */
4258
- doesNodeOverlapObstacle(node: CapacityMeshNode): boolean;
4259
- /**
4260
- * Checks if the entire node is contained within any obstacle.
4261
- */
4262
- isNodeCompletelyInsideObstacle(node: CapacityMeshNode): boolean;
4263
- getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
4264
- shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
4265
- _step(): void;
4266
- /**
4267
- * Creates a GraphicsObject to visualize the mesh, its nodes, obstacles, and connection points.
4268
- *
4269
- * - Mesh nodes are rendered as rectangles.
4270
- * - Nodes that have an obstacle intersection are outlined in red.
4271
- * - Other nodes are outlined in green.
4272
- * - Lines are drawn from a node to its parent.
4273
- * - Obstacles are drawn as semi-transparent red rectangles.
4274
- * - Points for each connection’s pointsToConnect are drawn in a unique color.
4275
- */
4276
- visualize(): GraphicsObject;
4277
- }
4278
-
4279
- interface CapacityMeshNodeSolverOptions$1 {
4280
- capacityDepth?: number;
4281
- }
4282
- declare class CapacityMeshNodeSolver2_NodeUnderObstacle extends CapacityMeshNodeSolver {
4283
- srj: SimpleRouteJson;
4284
- opts: CapacityMeshNodeSolverOptions$1;
4285
- VIA_DIAMETER: number;
4286
- OBSTACLE_MARGIN: number;
4287
- /**
4288
- * The threshold for the percentage of a single-layer node that must be
4289
- * covered by obstacles to be considered "under an obstacle"
4290
- */
4291
- OVERLAP_THRESHOLD_FOR_SINGLE_LAYER_NODES: number;
4292
- constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions$1);
4293
- isNodeCompletelyOutsideBounds(node: CapacityMeshNode): boolean;
4294
- isNodePartiallyOutsideBounds(node: CapacityMeshNode): boolean;
4295
- /**
4296
- * Calculate the percentage of node area covered by obstacles
4297
- */
4298
- getObstacleCoveragePercentage(node: CapacityMeshNode): number;
4299
- /**
4300
- * Check if a single-layer node should be filtered due to obstacle coverage
4301
- */
4302
- shouldFilterSingleLayerNodeForObstacle(node: CapacityMeshNode): boolean;
4303
- /**
4304
- * Check if a node should be filtered due to obstacles.
4305
- * Single-layer nodes: filtered only if >20% covered
4306
- * Multi-layer nodes: filtered if any overlap
4307
- */
4308
- shouldFilterNodeForObstacle(node: CapacityMeshNode): boolean;
4309
- createChildNodeAtPosition(parent: CapacityMeshNode, opts: {
4310
- center: {
4311
- x: number;
4312
- y: number;
4313
- };
4314
- width: number;
4315
- height: number;
4316
- availableZ: number[];
4317
- _depth?: number;
4318
- }): CapacityMeshNode;
4319
- getZSubdivisionChildNodes(node: CapacityMeshNode): CapacityMeshNode[];
4320
- getChildNodes(parent: CapacityMeshNode): CapacityMeshNode[];
4321
- shouldNodeBeXYSubdivided(node: CapacityMeshNode): boolean;
4322
- _step(): void;
4323
- }
4324
-
4325
4340
  interface CapacityMeshNodeSolverOptions {
4326
4341
  capacityDepth?: number;
4327
4342
  }