@tscircuit/capacity-autorouter 0.0.262 → 0.0.264

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,7 +3,7 @@ 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
+ import { Point3, Polygon } from '@tscircuit/math-utils';
7
7
  import { JumperGraphSolver, JRegion, JPort } from '@tscircuit/hypergraph';
8
8
  import { CurvyTraceSolver } from '@tscircuit/curvy-trace-solver';
9
9
  import { ConnectivityMap as ConnectivityMap$1 } from 'connectivity-map';
@@ -2089,6 +2089,176 @@ declare class UniformPortDistributionSolver extends BaseSolver$1 {
2089
2089
  visualize(): GraphicsObject;
2090
2090
  }
2091
2091
 
2092
+ /**
2093
+ * ObstacleTree wraps different spatial index implementations:
2094
+ * - 'native': original spatial-hash grid
2095
+ * - 'rbush': dynamic R-tree via rbush
2096
+ * - 'flatbush': static index via flatbush
2097
+ */
2098
+ declare class ObstacleSpatialHashIndex {
2099
+ private idx;
2100
+ private storage;
2101
+ constructor(implementation?: "native" | "rbush" | "flatbush", obstacles?: Obstacle[]);
2102
+ insert(o: Obstacle): void;
2103
+ search(bbox: {
2104
+ minX: number;
2105
+ minY: number;
2106
+ maxX: number;
2107
+ maxY: number;
2108
+ }): Obstacle[];
2109
+ searchArea(centerX: number, centerY: number, width: number, height: number): Obstacle[];
2110
+ }
2111
+
2112
+ interface Point$1 {
2113
+ x: number;
2114
+ y: number;
2115
+ z: number;
2116
+ }
2117
+ type HighDensityIntraNodeRoute = {
2118
+ connectionName: string;
2119
+ rootConnectionName?: string;
2120
+ traceThickness: number;
2121
+ viaDiameter: number;
2122
+ route: Array<{
2123
+ x: number;
2124
+ y: number;
2125
+ z: number;
2126
+ insideJumperPad?: boolean;
2127
+ }>;
2128
+ vias: Array<{
2129
+ x: number;
2130
+ y: number;
2131
+ }>;
2132
+ jumpers?: Jumper[];
2133
+ };
2134
+ type HighDensityRoute = HighDensityIntraNodeRoute;
2135
+ declare class HighDensityRouteSpatialIndex {
2136
+ private segmentBuckets;
2137
+ private viaBuckets;
2138
+ private CELL_SIZE;
2139
+ constructor(routes: HighDensityRoute[], cellSize?: number);
2140
+ /**
2141
+ * Finds routes that potentially conflict with a given line segment within a margin.
2142
+ * Checks both segments and vias.
2143
+ * @param segmentStart Start point of the query segment.
2144
+ * @param segmentEnd End point of the query segment.
2145
+ * @param margin The minimum required clearance distance from the query segment's centerline.
2146
+ * @returns An array of conflicting routes and their minimum distance to the segment.
2147
+ */
2148
+ getConflictingRoutesForSegment(segmentStart: Point$1, // Keep Point for original Z data if needed elsewhere
2149
+ segmentEnd: Point$1, margin: number): Array<{
2150
+ conflictingRoute: HighDensityRoute;
2151
+ distance: number;
2152
+ }>;
2153
+ /**
2154
+ * Removes a route from the spatial index by connection name.
2155
+ * @param connectionName The connection name of the route to remove.
2156
+ */
2157
+ removeRoute(connectionName: string): void;
2158
+ /**
2159
+ * Adds a single route to the spatial index.
2160
+ * @param route The route to add.
2161
+ */
2162
+ addRoute(route: HighDensityRoute): void;
2163
+ /**
2164
+ * Finds routes that pass near a given point within a margin.
2165
+ * Checks both segments and vias.
2166
+ * @param point The query point {x, y, z}.
2167
+ * @param margin The minimum required clearance distance from the query point.
2168
+ * @returns An array of conflicting routes and their minimum distance to the point.
2169
+ */
2170
+ getConflictingRoutesNearPoint(point: Point3, margin: number): Array<{
2171
+ conflictingRoute: HighDensityRoute;
2172
+ distance: number;
2173
+ }>;
2174
+ }
2175
+
2176
+ interface Point2D$2 {
2177
+ x: number;
2178
+ y: number;
2179
+ }
2180
+ interface Point3D$1 extends Point2D$2 {
2181
+ z: number;
2182
+ }
2183
+ interface TraceWidthSolverInput {
2184
+ hdRoutes: HighDensityRoute$1[];
2185
+ connection: SimpleRouteConnection[];
2186
+ obstacles?: Obstacle[];
2187
+ connMap?: ConnectivityMap;
2188
+ colorMap?: Record<string, string>;
2189
+ minTraceWidth: number;
2190
+ obstacleMargin?: number;
2191
+ }
2192
+ /**
2193
+ * TraceWidthSolver determines the optimal trace width for each route.
2194
+ * It uses a TRACE_WIDTH_SCHEDULE to try progressively narrower widths:
2195
+ * [nominalTraceWidth, (nominalTraceWidth + minTraceWidth)/2, minTraceWidth]
2196
+ *
2197
+ * For each trace, it walks along with a cursor checking clearance.
2198
+ * If clearance is insufficient for the current width, it tries the next
2199
+ * narrower width in the schedule.
2200
+ *
2201
+ * It only runs width adjustments for routes whose connection provides a
2202
+ * nominalTraceWidth; routes without one are passed through unchanged.
2203
+ * The schedule is built per-route from that connection's nominalTraceWidth.
2204
+ */
2205
+ declare class TraceWidthSolver extends BaseSolver {
2206
+ hdRoutes: HighDensityRoute$1[];
2207
+ hdRoutesWithWidths: HighDensityRoute$1[];
2208
+ nominalTraceWidth: number;
2209
+ minTraceWidth: number;
2210
+ obstacleMargin: number;
2211
+ TRACE_WIDTH_SCHEDULE: number[];
2212
+ connectionNominalTraceWidthMap: Map<string, number>;
2213
+ unprocessedRoutes: HighDensityRoute$1[];
2214
+ processedRoutes: HighDensityRoute$1[];
2215
+ currentTrace: HighDensityRoute$1 | null;
2216
+ cursorPosition: Point3D$1 | null;
2217
+ currentTraceSegmentIndex: number;
2218
+ currentTraceSegmentT: number;
2219
+ currentScheduleIndex: number;
2220
+ currentTargetWidth: number;
2221
+ hasInsufficientClearance: boolean;
2222
+ lastCollidingObstacles: Obstacle[];
2223
+ lastCollidingRoutes: HighDensityRoute$1[];
2224
+ lastClearance: number;
2225
+ obstacles: Obstacle[];
2226
+ obstacleSHI?: ObstacleSpatialHashIndex;
2227
+ hdRouteSHI: HighDensityRouteSpatialIndex;
2228
+ connMap?: ConnectivityMap;
2229
+ colorMap?: Record<string, string>;
2230
+ constructor(input: TraceWidthSolverInput);
2231
+ private getNominalTraceWidthForRoute;
2232
+ _step(): void;
2233
+ /**
2234
+ * Initializes/resets the cursor for processing a trace
2235
+ */
2236
+ private initializeCursor;
2237
+ /**
2238
+ * Steps the cursor forward by CURSOR_STEP_DISTANCE along the trace
2239
+ * Returns false if we've reached the end of the trace
2240
+ * Skips segments where both endpoints are inside jumper pads
2241
+ */
2242
+ private stepCursorForward;
2243
+ /**
2244
+ * Checks if an obstacle is a jumper pad belonging to the current trace's jumpers.
2245
+ * This is needed because jumper pads may not have connectedTo set properly.
2246
+ */
2247
+ private isObstacleOwnJumperPad;
2248
+ /**
2249
+ * Gets the minimum clearance at a given position from obstacles and other traces
2250
+ * Also updates lastCollidingObstacles and lastCollidingRoutes for visualization
2251
+ */
2252
+ private getClearanceAtPosition;
2253
+ /**
2254
+ * Finalizes the current trace with the given width
2255
+ */
2256
+ private finalizeCurrentTrace;
2257
+ visualize(): GraphicsObject;
2258
+ /** Returns the routes with determined widths. This is the primary output of the solver. */
2259
+ getHdRoutesWithWidths(): HighDensityRoute$1[];
2260
+ }
2261
+
2092
2262
  interface CapacityMeshSolverOptions$4 {
2093
2263
  capacityDepth?: number;
2094
2264
  targetMinCapacity?: number;
@@ -2119,6 +2289,7 @@ declare class AutoroutingPipelineSolver2_PortPointPathing extends BaseSolver {
2119
2289
  portPointPathingSolver?: HyperPortPointPathingSolver;
2120
2290
  multiSectionPortPointOptimizer?: MultiSectionPortPointOptimizer;
2121
2291
  uniformPortDistributionSolver?: UniformPortDistributionSolver;
2292
+ traceWidthSolver?: TraceWidthSolver;
2122
2293
  viaDiameter: number;
2123
2294
  minTraceWidth: number;
2124
2295
  effort: number;
@@ -2132,7 +2303,7 @@ declare class AutoroutingPipelineSolver2_PortPointPathing extends BaseSolver {
2132
2303
  capacityEdges: CapacityMeshEdge[] | null;
2133
2304
  inputNodeWithPortPoints: InputNodeWithPortPoints[];
2134
2305
  cacheProvider: CacheProvider | null;
2135
- pipelineDef: (PipelineStep$4<typeof NetToPointPairsSolver2_OffBoardConnection> | PipelineStep$4<typeof RectDiffPipeline> | PipelineStep$4<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep$4<typeof AvailableSegmentPointSolver> | PipelineStep$4<typeof HyperPortPointPathingSolver> | PipelineStep$4<typeof MultiSectionPortPointOptimizer> | PipelineStep$4<typeof UniformPortDistributionSolver> | PipelineStep$4<typeof HighDensitySolver> | PipelineStep$4<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep$4<typeof TraceSimplificationSolver>)[];
2306
+ pipelineDef: (PipelineStep$4<typeof NetToPointPairsSolver2_OffBoardConnection> | PipelineStep$4<typeof RectDiffPipeline> | PipelineStep$4<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep$4<typeof AvailableSegmentPointSolver> | PipelineStep$4<typeof HyperPortPointPathingSolver> | PipelineStep$4<typeof MultiSectionPortPointOptimizer> | PipelineStep$4<typeof UniformPortDistributionSolver> | PipelineStep$4<typeof HighDensitySolver> | PipelineStep$4<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep$4<typeof TraceSimplificationSolver> | PipelineStep$4<typeof TraceWidthSolver>)[];
2136
2307
  constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions$4);
2137
2308
  getConstructorParams(): readonly [SimpleRouteJson, CapacityMeshSolverOptions$4];
2138
2309
  currentPipelineStepIndex: number;
@@ -2161,26 +2332,6 @@ declare class AutoroutingPipelineSolver2_PortPointPathing extends BaseSolver {
2161
2332
  declare const CapacityMeshSolver: typeof AutoroutingPipelineSolver2_PortPointPathing;
2162
2333
  type CapacityMeshSolver = AutoroutingPipelineSolver2_PortPointPathing;
2163
2334
 
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
2335
  interface Target$1 {
2185
2336
  x: number;
2186
2337
  y: number;
@@ -3579,88 +3730,20 @@ declare class JumperHighDensitySolver extends BaseSolver {
3579
3730
  visualize(): GraphicsObject;
3580
3731
  }
3581
3732
 
3582
- interface Point$1 {
3583
- x: number;
3584
- y: number;
3585
- z: number;
3586
- }
3587
- type Point2D$3 = {
3588
- x: number;
3589
- y: number;
3590
- };
3591
- type HighDensityIntraNodeRoute = {
3592
- connectionName: string;
3593
- rootConnectionName?: string;
3594
- traceThickness: number;
3595
- viaDiameter: number;
3596
- route: Array<{
3597
- x: number;
3598
- y: number;
3599
- z: number;
3600
- insideJumperPad?: boolean;
3601
- }>;
3602
- vias: Array<{
3603
- x: number;
3604
- y: number;
3605
- }>;
3606
- jumpers?: Jumper[];
3607
- };
3608
- type HighDensityRoute = HighDensityIntraNodeRoute;
3609
- declare class HighDensityRouteSpatialIndex {
3610
- private segmentBuckets;
3611
- private viaBuckets;
3612
- private CELL_SIZE;
3613
- constructor(routes: HighDensityRoute[], cellSize?: number);
3614
- /**
3615
- * Finds routes that potentially conflict with a given line segment within a margin.
3616
- * Checks both segments and vias.
3617
- * @param segmentStart Start point of the query segment.
3618
- * @param segmentEnd End point of the query segment.
3619
- * @param margin The minimum required clearance distance from the query segment's centerline.
3620
- * @returns An array of conflicting routes and their minimum distance to the segment.
3621
- */
3622
- getConflictingRoutesForSegment(segmentStart: Point$1, // Keep Point for original Z data if needed elsewhere
3623
- segmentEnd: Point$1, margin: number): Array<{
3624
- conflictingRoute: HighDensityRoute;
3625
- distance: number;
3626
- }>;
3627
- /**
3628
- * Removes a route from the spatial index by connection name.
3629
- * @param connectionName The connection name of the route to remove.
3630
- */
3631
- removeRoute(connectionName: string): void;
3632
- /**
3633
- * Adds a single route to the spatial index.
3634
- * @param route The route to add.
3635
- */
3636
- addRoute(route: HighDensityRoute): void;
3637
- /**
3638
- * Finds routes that pass near a given point within a margin.
3639
- * Checks both segments and vias.
3640
- * @param point The query point {x, y}. Z is ignored.
3641
- * @param margin The minimum required clearance distance from the query point.
3642
- * @returns An array of conflicting routes and their minimum distance to the point.
3643
- */
3644
- getConflictingRoutesNearPoint(point: Point2D$3, margin: number): Array<{
3645
- conflictingRoute: HighDensityRoute;
3646
- distance: number;
3647
- }>;
3648
- }
3649
-
3650
- interface Point2D$2 {
3733
+ interface Point2D$1 {
3651
3734
  x: number;
3652
3735
  y: number;
3653
3736
  }
3654
3737
  interface Segment {
3655
- start: Point2D$2;
3656
- end: Point2D$2;
3738
+ start: Point2D$1;
3739
+ end: Point2D$1;
3657
3740
  }
3658
3741
 
3659
- interface Point2D$1 {
3742
+ interface Point2D {
3660
3743
  x: number;
3661
3744
  y: number;
3662
3745
  }
3663
- interface Point3D$1 extends Point2D$1 {
3746
+ interface Point3D extends Point2D {
3664
3747
  z: number;
3665
3748
  insideJumperPad?: boolean;
3666
3749
  }
@@ -3695,12 +3778,12 @@ declare class TraceKeepoutSolver extends BaseSolver {
3695
3778
  smoothedCursorRoutes: HighDensityRoute$1[];
3696
3779
  processedRoutes: HighDensityRoute$1[];
3697
3780
  currentTrace: HighDensityRoute$1 | null;
3698
- cursorPosition: Point3D$1 | null;
3699
- lastCursorPosition: Point3D$1 | null;
3700
- drawPosition: Point2D$1 | null;
3781
+ cursorPosition: Point3D | null;
3782
+ lastCursorPosition: Point3D | null;
3783
+ drawPosition: Point2D | null;
3701
3784
  currentTraceSegmentIndex: number;
3702
3785
  currentTraceSegmentT: number;
3703
- recordedDrawPositions: Point3D$1[];
3786
+ recordedDrawPositions: Point3D[];
3704
3787
  lastCollidingSegments: Segment[];
3705
3788
  /** Maps segment index to the jumper that occupies that segment */
3706
3789
  currentTraceJumperSegments: Map<number, Jumper>;
@@ -3773,88 +3856,6 @@ declare class TraceKeepoutSolver extends BaseSolver {
3773
3856
  getRedrawnHdRoutes(): HighDensityRoute$1[];
3774
3857
  }
3775
3858
 
3776
- interface Point2D {
3777
- x: number;
3778
- y: number;
3779
- }
3780
- interface Point3D extends Point2D {
3781
- z: number;
3782
- }
3783
- interface TraceWidthSolverInput {
3784
- hdRoutes: HighDensityRoute$1[];
3785
- obstacles?: Obstacle[];
3786
- connMap?: ConnectivityMap;
3787
- colorMap?: Record<string, string>;
3788
- nominalTraceWidth?: number;
3789
- minTraceWidth: number;
3790
- obstacleMargin?: number;
3791
- }
3792
- /**
3793
- * TraceWidthSolver determines the optimal trace width for each route.
3794
- * It uses a TRACE_WIDTH_SCHEDULE to try progressively narrower widths:
3795
- * [nominalTraceWidth, (nominalTraceWidth + minTraceWidth)/2, minTraceWidth]
3796
- *
3797
- * For each trace, it walks along with a cursor checking clearance.
3798
- * If clearance is insufficient for the current width, it tries the next
3799
- * narrower width in the schedule.
3800
- *
3801
- * nominalTraceWidth defaults to minTraceWidth * 2 if not specified.
3802
- */
3803
- declare class TraceWidthSolver extends BaseSolver {
3804
- hdRoutes: HighDensityRoute$1[];
3805
- hdRoutesWithWidths: HighDensityRoute$1[];
3806
- nominalTraceWidth: number;
3807
- minTraceWidth: number;
3808
- obstacleMargin: number;
3809
- TRACE_WIDTH_SCHEDULE: number[];
3810
- unprocessedRoutes: HighDensityRoute$1[];
3811
- processedRoutes: HighDensityRoute$1[];
3812
- currentTrace: HighDensityRoute$1 | null;
3813
- cursorPosition: Point3D | null;
3814
- currentTraceSegmentIndex: number;
3815
- currentTraceSegmentT: number;
3816
- currentScheduleIndex: number;
3817
- currentTargetWidth: number;
3818
- hasInsufficientClearance: boolean;
3819
- lastCollidingObstacles: Obstacle[];
3820
- lastCollidingRoutes: HighDensityRoute$1[];
3821
- lastClearance: number;
3822
- obstacles: Obstacle[];
3823
- obstacleSHI?: ObstacleSpatialHashIndex;
3824
- hdRouteSHI: HighDensityRouteSpatialIndex;
3825
- connMap?: ConnectivityMap;
3826
- colorMap?: Record<string, string>;
3827
- constructor(input: TraceWidthSolverInput);
3828
- _step(): void;
3829
- /**
3830
- * Initializes/resets the cursor for processing a trace
3831
- */
3832
- private initializeCursor;
3833
- /**
3834
- * Steps the cursor forward by CURSOR_STEP_DISTANCE along the trace
3835
- * Returns false if we've reached the end of the trace
3836
- * Skips segments where both endpoints are inside jumper pads
3837
- */
3838
- private stepCursorForward;
3839
- /**
3840
- * Checks if an obstacle is a jumper pad belonging to the current trace's jumpers.
3841
- * This is needed because jumper pads may not have connectedTo set properly.
3842
- */
3843
- private isObstacleOwnJumperPad;
3844
- /**
3845
- * Gets the minimum clearance at a given position from obstacles and other traces
3846
- * Also updates lastCollidingObstacles and lastCollidingRoutes for visualization
3847
- */
3848
- private getClearanceAtPosition;
3849
- /**
3850
- * Finalizes the current trace with the given width
3851
- */
3852
- private finalizeCurrentTrace;
3853
- visualize(): GraphicsObject;
3854
- /** Returns the routes with determined widths. This is the primary output of the solver. */
3855
- getHdRoutesWithWidths(): HighDensityRoute$1[];
3856
- }
3857
-
3858
3859
  interface OffboardPortPoint {
3859
3860
  portPointId: string;
3860
3861
  x: number;