@tscircuit/capacity-autorouter 0.0.239 → 0.0.240

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
@@ -2,7 +2,7 @@ import * as graphics_debug from 'graphics-debug';
2
2
  import { GraphicsObject, Rect, Circle, Line, Point as Point$5 } from 'graphics-debug';
3
3
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
4
4
  import { RectDiffPipeline } from '@tscircuit/rectdiff';
5
- import { JumperGraphSolver } from '@tscircuit/hypergraph';
5
+ import { JumperGraphSolver, JRegion } from '@tscircuit/hypergraph';
6
6
  import { ConnectivityMap as ConnectivityMap$1 } from 'connectivity-map';
7
7
  import { Polygon } from '@tscircuit/math-utils';
8
8
 
@@ -27,6 +27,17 @@ type MultiLayerConnectionPoint = {
27
27
  pcb_port_id?: string;
28
28
  };
29
29
  type ConnectionPoint = SingleLayerConnectionPoint | MultiLayerConnectionPoint;
30
+ type Jumper$1 = {
31
+ jumper_footprint: "0603" | "1206x4";
32
+ center: {
33
+ x: number;
34
+ y: number;
35
+ };
36
+ orientation: "horizontal" | "vertical";
37
+ width: number;
38
+ height: number;
39
+ pads: Obstacle[];
40
+ };
30
41
  interface SimpleRouteJson {
31
42
  layerCount: number;
32
43
  minTraceWidth: number;
@@ -46,6 +57,7 @@ interface SimpleRouteJson {
46
57
  y: number;
47
58
  }>;
48
59
  traces?: SimplifiedPcbTraces;
60
+ jumpers?: Jumper$1[];
49
61
  allowJumpers?: boolean;
50
62
  }
51
63
  interface Obstacle {
@@ -244,6 +256,7 @@ type HighDensityIntraNodeRoute$1 = {
244
256
  x: number;
245
257
  y: number;
246
258
  z: number;
259
+ insideJumperPad?: boolean;
247
260
  }>;
248
261
  vias: Array<{
249
262
  x: number;
@@ -3036,7 +3049,16 @@ declare class JumperPrepatternSolver2_HyperGraph extends BaseSolver {
3036
3049
  minY: number;
3037
3050
  maxY: number;
3038
3051
  } | null;
3052
+ jumperLocations: Array<{
3053
+ center: {
3054
+ x: number;
3055
+ y: number;
3056
+ };
3057
+ orientation: "vertical" | "horizontal";
3058
+ padRegions: JRegion[];
3059
+ }>;
3039
3060
  solvedRoutes: HighDensityIntraNodeRouteWithJumpers[];
3061
+ jumpers: Jumper$1[];
3040
3062
  constructor(params: JumperPrepatternSolver2Params);
3041
3063
  getConstructorParams(): JumperPrepatternSolver2Params;
3042
3064
  private _buildColorMap;
@@ -3044,7 +3066,26 @@ declare class JumperPrepatternSolver2_HyperGraph extends BaseSolver {
3044
3066
  private _initializeGraph;
3045
3067
  _step(): void;
3046
3068
  private _processResults;
3069
+ /**
3070
+ * Post-process routes to add offset midpoints for collinear overlapping segments.
3071
+ *
3072
+ * When two segments are collinear and overlap (arranged as A-C-D-B where AB
3073
+ * is one segment and CD is another), the outer segment (AB) needs a midpoint
3074
+ * pushed to the side to hint to the force-directed graph that it should route
3075
+ * around the inner segment.
3076
+ *
3077
+ * This handles both:
3078
+ * 1. Segments from different connections that overlap
3079
+ * 2. Segments from the SAME connection that overlap (when a route doubles back)
3080
+ */
3081
+ private _addMidpointsForCollinearOverlaps;
3047
3082
  getOutput(): HighDensityIntraNodeRouteWithJumpers[];
3083
+ /**
3084
+ * Returns all jumpers from the baseGraph as SRJ Jumper objects.
3085
+ * The pads have connectedTo set based on which routes use each jumper.
3086
+ * Must be called after the solver is solved.
3087
+ */
3088
+ getOutputJumpers(): Jumper$1[];
3048
3089
  visualize(): GraphicsObject;
3049
3090
  private _drawJumperPads;
3050
3091
  }
@@ -3078,6 +3119,7 @@ declare class HyperJumperPrepatternSolver2 extends HyperParameterSupervisorSolve
3078
3119
  connMap?: ConnectivityMap;
3079
3120
  baseHyperParameters?: JumperPrepatternSolver2HyperParameters;
3080
3121
  solvedRoutes: HighDensityIntraNodeRouteWithJumpers[];
3122
+ jumpers: Jumper$1[];
3081
3123
  constructor(params: HyperJumperPrepatternSolver2Params);
3082
3124
  getConstructorParams(): HyperJumperPrepatternSolver2Params;
3083
3125
  getHyperParameterDefs(): ({
@@ -3097,6 +3139,7 @@ declare class HyperJumperPrepatternSolver2 extends HyperParameterSupervisorSolve
3097
3139
  computeH(solver: JumperPrepatternSolver2_HyperGraph): number;
3098
3140
  onSolve(solver: SupervisedSolver<JumperPrepatternSolver2_HyperGraph>): void;
3099
3141
  getOutput(): HighDensityIntraNodeRouteWithJumpers[];
3142
+ getOutputJumpers(): Jumper$1[];
3100
3143
  visualize(): GraphicsObject;
3101
3144
  }
3102
3145
 
@@ -3127,6 +3170,7 @@ declare class JumperHighDensitySolver extends BaseSolver {
3127
3170
  jumperSolvers: HyperJumperPrepatternSolver2[];
3128
3171
  currentJumperSolverIndex: number;
3129
3172
  phase: "analyzing" | "simple" | "jumpers" | "done";
3173
+ jumpers: Jumper$1[];
3130
3174
  constructor({ nodePortPoints, colorMap, traceWidth, viaDiameter, connMap, hyperParameters, }: {
3131
3175
  nodePortPoints: NodeWithPortPoints[];
3132
3176
  colorMap?: Record<string, string>;
@@ -3152,6 +3196,13 @@ declare class JumperHighDensitySolver extends BaseSolver {
3152
3196
  connMap: ConnectivityMap | undefined;
3153
3197
  hyperParameters: Partial<HighDensityHyperParameters> | undefined;
3154
3198
  };
3199
+ /**
3200
+ * Returns ALL jumpers collected from the jumper solvers.
3201
+ * These include all jumpers placed in the grid (from baseGraph.jumperLocations),
3202
+ * not just the ones used by routes. The pads have connectedTo set based on
3203
+ * which routes use each jumper.
3204
+ */
3205
+ getOutputJumpers(): Jumper$1[];
3155
3206
  visualize(): GraphicsObject;
3156
3207
  }
3157
3208
 
@@ -3193,6 +3244,7 @@ type HighDensityIntraNodeRoute = {
3193
3244
  x: number;
3194
3245
  y: number;
3195
3246
  z: number;
3247
+ insideJumperPad?: boolean;
3196
3248
  }>;
3197
3249
  vias: Array<{
3198
3250
  x: number;
@@ -3247,10 +3299,13 @@ interface Point2D$1 {
3247
3299
  }
3248
3300
  interface Point3D$1 extends Point2D$1 {
3249
3301
  z: number;
3302
+ insideJumperPad?: boolean;
3250
3303
  }
3251
3304
  interface TraceKeepoutSolverInput {
3252
3305
  hdRoutes: HighDensityRoute$1[];
3253
3306
  obstacles: Obstacle[];
3307
+ /** SRJ Jumpers with pre-computed pad obstacles. These will be added to the obstacle index. */
3308
+ jumpers?: Jumper$1[];
3254
3309
  connMap: ConnectivityMap;
3255
3310
  colorMap: Record<string, string>;
3256
3311
  keepoutRadiusSchedule?: number[];
@@ -3284,16 +3339,38 @@ declare class TraceKeepoutSolver extends BaseSolver {
3284
3339
  currentTraceSegmentT: number;
3285
3340
  recordedDrawPositions: Point3D$1[];
3286
3341
  lastCollidingSegments: Segment[];
3342
+ /** Maps segment index to the jumper that occupies that segment */
3343
+ currentTraceJumperSegments: Map<number, Jumper>;
3287
3344
  obstacleSHI: ObstacleSpatialHashIndex;
3288
3345
  hdRouteSHI: HighDensityRouteSpatialIndex;
3289
3346
  boardOutlineRoutes: HighDensityRoute$1[];
3290
3347
  constructor(input: TraceKeepoutSolverInput);
3291
3348
  getSmoothDistance(): number;
3349
+ /**
3350
+ * Extracts pad obstacles from the passed-in SRJ jumpers.
3351
+ * The pads already have connectedTo set based on which routes use each jumper.
3352
+ */
3353
+ private getJumperPadObstacles;
3354
+ /**
3355
+ * Builds a map from segment index to the jumper that occupies that segment.
3356
+ * A segment is considered a jumper segment if it connects points near the
3357
+ * jumper's start and end positions.
3358
+ *
3359
+ * Uses a larger tolerance for matching because routes may be modified during
3360
+ * collision avoidance passes, but we still need to find the segment that
3361
+ * represents each jumper.
3362
+ */
3363
+ private buildJumperSegmentMap;
3292
3364
  _step(): void;
3293
3365
  getStepDistance(): number;
3366
+ /**
3367
+ * Check if we're about to enter a jumper segment.
3368
+ * Returns the jumper if we're at the start of a jumper segment (T=0), null otherwise.
3369
+ */
3370
+ private getJumperAtCurrentSegmentStart;
3294
3371
  /**
3295
3372
  * Steps the cursor forward by CURSOR_STEP_DISTANCE along the trace
3296
- * Returns false if we've reached the end of the trace
3373
+ * Returns: "stepped" if normal step, "end" if reached end, "jumper" if crossed a jumper
3297
3374
  */
3298
3375
  private stepCursorForward;
3299
3376
  /**
@@ -3305,12 +3382,22 @@ declare class TraceKeepoutSolver extends BaseSolver {
3305
3382
  y: number;
3306
3383
  z: number;
3307
3384
  }, margin?: number): boolean;
3385
+ /**
3386
+ * Checks if a new segment would intersect with any route from unprocessedRoutes,
3387
+ * smoothedCursorRoutes, or processedRoutes (excluding routes with the same connection name).
3388
+ */
3389
+ private segmentIntersectsOtherRoutes;
3308
3390
  /**
3309
3391
  * Finalizes the current trace with the recorded draw positions
3310
3392
  */
3311
3393
  private finalizeCurrentTrace;
3312
3394
  /**
3313
- * Simplifies the route by removing collinear points
3395
+ * Checks if a point is a jumper endpoint.
3396
+ */
3397
+ private isJumperEndpoint;
3398
+ /**
3399
+ * Simplifies the route by removing collinear points, but preserves
3400
+ * jumper endpoints which must remain fixed.
3314
3401
  */
3315
3402
  private simplifyRoute;
3316
3403
  /**
@@ -3366,9 +3453,6 @@ declare class TraceWidthSolver extends BaseSolver {
3366
3453
  currentScheduleIndex: number;
3367
3454
  currentTargetWidth: number;
3368
3455
  hasInsufficientClearance: boolean;
3369
- currentWalkMinClearance: number;
3370
- bestMinClearance: number;
3371
- bestWidth: number;
3372
3456
  lastCollidingObstacles: Obstacle[];
3373
3457
  lastCollidingRoutes: HighDensityRoute$1[];
3374
3458
  lastClearance: number;
@@ -3386,8 +3470,14 @@ declare class TraceWidthSolver extends BaseSolver {
3386
3470
  /**
3387
3471
  * Steps the cursor forward by CURSOR_STEP_DISTANCE along the trace
3388
3472
  * Returns false if we've reached the end of the trace
3473
+ * Skips segments where both endpoints are inside jumper pads
3389
3474
  */
3390
3475
  private stepCursorForward;
3476
+ /**
3477
+ * Checks if an obstacle is a jumper pad belonging to the current trace's jumpers.
3478
+ * This is needed because jumper pads may not have connectedTo set properly.
3479
+ */
3480
+ private isObstacleOwnJumperPad;
3391
3481
  /**
3392
3482
  * Gets the minimum clearance at a given position from obstacles and other traces
3393
3483
  * Also updates lastCollidingObstacles and lastCollidingRoutes for visualization