@tscircuit/capacity-autorouter 0.0.261 → 0.0.263

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,172 @@ 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
+ obstacles?: Obstacle[];
2186
+ connMap?: ConnectivityMap;
2187
+ colorMap?: Record<string, string>;
2188
+ nominalTraceWidth?: number;
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
+ * nominalTraceWidth defaults to minTraceWidth * 2 if not specified.
2202
+ */
2203
+ declare class TraceWidthSolver extends BaseSolver {
2204
+ hdRoutes: HighDensityRoute$1[];
2205
+ hdRoutesWithWidths: HighDensityRoute$1[];
2206
+ nominalTraceWidth: number;
2207
+ minTraceWidth: number;
2208
+ obstacleMargin: number;
2209
+ TRACE_WIDTH_SCHEDULE: number[];
2210
+ unprocessedRoutes: HighDensityRoute$1[];
2211
+ processedRoutes: HighDensityRoute$1[];
2212
+ currentTrace: HighDensityRoute$1 | null;
2213
+ cursorPosition: Point3D$1 | null;
2214
+ currentTraceSegmentIndex: number;
2215
+ currentTraceSegmentT: number;
2216
+ currentScheduleIndex: number;
2217
+ currentTargetWidth: number;
2218
+ hasInsufficientClearance: boolean;
2219
+ lastCollidingObstacles: Obstacle[];
2220
+ lastCollidingRoutes: HighDensityRoute$1[];
2221
+ lastClearance: number;
2222
+ obstacles: Obstacle[];
2223
+ obstacleSHI?: ObstacleSpatialHashIndex;
2224
+ hdRouteSHI: HighDensityRouteSpatialIndex;
2225
+ connMap?: ConnectivityMap;
2226
+ colorMap?: Record<string, string>;
2227
+ constructor(input: TraceWidthSolverInput);
2228
+ _step(): void;
2229
+ /**
2230
+ * Initializes/resets the cursor for processing a trace
2231
+ */
2232
+ private initializeCursor;
2233
+ /**
2234
+ * Steps the cursor forward by CURSOR_STEP_DISTANCE along the trace
2235
+ * Returns false if we've reached the end of the trace
2236
+ * Skips segments where both endpoints are inside jumper pads
2237
+ */
2238
+ private stepCursorForward;
2239
+ /**
2240
+ * Checks if an obstacle is a jumper pad belonging to the current trace's jumpers.
2241
+ * This is needed because jumper pads may not have connectedTo set properly.
2242
+ */
2243
+ private isObstacleOwnJumperPad;
2244
+ /**
2245
+ * Gets the minimum clearance at a given position from obstacles and other traces
2246
+ * Also updates lastCollidingObstacles and lastCollidingRoutes for visualization
2247
+ */
2248
+ private getClearanceAtPosition;
2249
+ /**
2250
+ * Finalizes the current trace with the given width
2251
+ */
2252
+ private finalizeCurrentTrace;
2253
+ visualize(): GraphicsObject;
2254
+ /** Returns the routes with determined widths. This is the primary output of the solver. */
2255
+ getHdRoutesWithWidths(): HighDensityRoute$1[];
2256
+ }
2257
+
2092
2258
  interface CapacityMeshSolverOptions$4 {
2093
2259
  capacityDepth?: number;
2094
2260
  targetMinCapacity?: number;
@@ -2119,6 +2285,7 @@ declare class AutoroutingPipelineSolver2_PortPointPathing extends BaseSolver {
2119
2285
  portPointPathingSolver?: HyperPortPointPathingSolver;
2120
2286
  multiSectionPortPointOptimizer?: MultiSectionPortPointOptimizer;
2121
2287
  uniformPortDistributionSolver?: UniformPortDistributionSolver;
2288
+ traceWidthSolver?: TraceWidthSolver;
2122
2289
  viaDiameter: number;
2123
2290
  minTraceWidth: number;
2124
2291
  effort: number;
@@ -2132,7 +2299,7 @@ declare class AutoroutingPipelineSolver2_PortPointPathing extends BaseSolver {
2132
2299
  capacityEdges: CapacityMeshEdge[] | null;
2133
2300
  inputNodeWithPortPoints: InputNodeWithPortPoints[];
2134
2301
  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>)[];
2302
+ 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
2303
  constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions$4);
2137
2304
  getConstructorParams(): readonly [SimpleRouteJson, CapacityMeshSolverOptions$4];
2138
2305
  currentPipelineStepIndex: number;
@@ -2161,26 +2328,6 @@ declare class AutoroutingPipelineSolver2_PortPointPathing extends BaseSolver {
2161
2328
  declare const CapacityMeshSolver: typeof AutoroutingPipelineSolver2_PortPointPathing;
2162
2329
  type CapacityMeshSolver = AutoroutingPipelineSolver2_PortPointPathing;
2163
2330
 
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
2331
  interface Target$1 {
2185
2332
  x: number;
2186
2333
  y: number;
@@ -3579,88 +3726,20 @@ declare class JumperHighDensitySolver extends BaseSolver {
3579
3726
  visualize(): GraphicsObject;
3580
3727
  }
3581
3728
 
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 {
3729
+ interface Point2D$1 {
3651
3730
  x: number;
3652
3731
  y: number;
3653
3732
  }
3654
3733
  interface Segment {
3655
- start: Point2D$2;
3656
- end: Point2D$2;
3734
+ start: Point2D$1;
3735
+ end: Point2D$1;
3657
3736
  }
3658
3737
 
3659
- interface Point2D$1 {
3738
+ interface Point2D {
3660
3739
  x: number;
3661
3740
  y: number;
3662
3741
  }
3663
- interface Point3D$1 extends Point2D$1 {
3742
+ interface Point3D extends Point2D {
3664
3743
  z: number;
3665
3744
  insideJumperPad?: boolean;
3666
3745
  }
@@ -3695,12 +3774,12 @@ declare class TraceKeepoutSolver extends BaseSolver {
3695
3774
  smoothedCursorRoutes: HighDensityRoute$1[];
3696
3775
  processedRoutes: HighDensityRoute$1[];
3697
3776
  currentTrace: HighDensityRoute$1 | null;
3698
- cursorPosition: Point3D$1 | null;
3699
- lastCursorPosition: Point3D$1 | null;
3700
- drawPosition: Point2D$1 | null;
3777
+ cursorPosition: Point3D | null;
3778
+ lastCursorPosition: Point3D | null;
3779
+ drawPosition: Point2D | null;
3701
3780
  currentTraceSegmentIndex: number;
3702
3781
  currentTraceSegmentT: number;
3703
- recordedDrawPositions: Point3D$1[];
3782
+ recordedDrawPositions: Point3D[];
3704
3783
  lastCollidingSegments: Segment[];
3705
3784
  /** Maps segment index to the jumper that occupies that segment */
3706
3785
  currentTraceJumperSegments: Map<number, Jumper>;
@@ -3773,88 +3852,6 @@ declare class TraceKeepoutSolver extends BaseSolver {
3773
3852
  getRedrawnHdRoutes(): HighDensityRoute$1[];
3774
3853
  }
3775
3854
 
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
3855
  interface OffboardPortPoint {
3859
3856
  portPointId: string;
3860
3857
  x: number;