@tscircuit/capacity-autorouter 0.0.205 → 0.0.207

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
@@ -29,7 +29,9 @@ type ConnectionPoint = SingleLayerConnectionPoint | MultiLayerConnectionPoint;
29
29
  interface SimpleRouteJson {
30
30
  layerCount: number;
31
31
  minTraceWidth: number;
32
+ nominalTraceWidth?: number;
32
33
  minViaDiameter?: number;
34
+ defaultObstacleMargin?: number;
33
35
  obstacles: Obstacle[];
34
36
  connections: Array<SimpleRouteConnection>;
35
37
  bounds: {
@@ -1448,7 +1450,8 @@ declare class PortPointPathingSolver extends BaseSolver {
1448
1450
  * - memoryPfMap to bias away from historically high Pf regions
1449
1451
  */
1450
1452
  computeH(point: InputPortPoint, currentNodeId: CapacityMeshNodeId, endGoalNodeId: CapacityMeshNodeId, currentZ: number, distanceTraveled: number, hasTouchedOffBoardNode?: boolean): number;
1451
- getAvailableExitPortPoints(nodeId: CapacityMeshNodeId): InputPortPoint[];
1453
+ getVisitedPortPointKey(portPointId: string, hasTouchedOffBoardNode?: boolean): string;
1454
+ getAvailableExitPortPoints(nodeId: CapacityMeshNodeId, hasTouchedOffBoardNode?: boolean): InputPortPoint[];
1452
1455
  /**
1453
1456
  * Get available port points to exit from a node, but *do not* return all.
1454
1457
  *
@@ -1457,8 +1460,8 @@ declare class PortPointPathingSolver extends BaseSolver {
1457
1460
  * - If that centermost port point is already assigned, also return some next-closest
1458
1461
  * unassigned offsets as backups.
1459
1462
  */
1460
- getAvailableExitPortPointsWithOmissions(nodeId: CapacityMeshNodeId, _endGoalNodeId: CapacityMeshNodeId): InputPortPoint[];
1461
- getAvailableExitPortPointsForOffboardConnection(nodeId: CapacityMeshNodeId): (InputPortPoint & {
1463
+ getAvailableExitPortPointsWithOmissions(nodeId: CapacityMeshNodeId, _endGoalNodeId: CapacityMeshNodeId, hasTouchedOffBoardNode?: boolean): InputPortPoint[];
1464
+ getAvailableExitPortPointsForOffboardConnection(nodeId: CapacityMeshNodeId, hasTouchedOffBoardNode?: boolean): (InputPortPoint & {
1462
1465
  throughNodeId: CapacityMeshNodeId;
1463
1466
  })[];
1464
1467
  canTravelThroughObstacle(node: InputNodeWithPortPoints, connectionName: string, rootConnectionName: string): boolean;
@@ -2774,7 +2777,7 @@ interface Point$1 {
2774
2777
  y: number;
2775
2778
  z: number;
2776
2779
  }
2777
- type Point2D$2 = {
2780
+ type Point2D$3 = {
2778
2781
  x: number;
2779
2782
  y: number;
2780
2783
  };
@@ -2819,26 +2822,26 @@ declare class HighDensityRouteSpatialIndex {
2819
2822
  * @param margin The minimum required clearance distance from the query point.
2820
2823
  * @returns An array of conflicting routes and their minimum distance to the point.
2821
2824
  */
2822
- getConflictingRoutesNearPoint(point: Point2D$2, margin: number): Array<{
2825
+ getConflictingRoutesNearPoint(point: Point2D$3, margin: number): Array<{
2823
2826
  conflictingRoute: HighDensityRoute;
2824
2827
  distance: number;
2825
2828
  }>;
2826
2829
  }
2827
2830
 
2828
- interface Point2D$1 {
2831
+ interface Point2D$2 {
2829
2832
  x: number;
2830
2833
  y: number;
2831
2834
  }
2832
2835
  interface Segment {
2833
- start: Point2D$1;
2834
- end: Point2D$1;
2836
+ start: Point2D$2;
2837
+ end: Point2D$2;
2835
2838
  }
2836
2839
 
2837
- interface Point2D {
2840
+ interface Point2D$1 {
2838
2841
  x: number;
2839
2842
  y: number;
2840
2843
  }
2841
- interface Point3D extends Point2D {
2844
+ interface Point3D$1 extends Point2D$1 {
2842
2845
  z: number;
2843
2846
  }
2844
2847
  interface TraceKeepoutSolverInput {
@@ -2847,7 +2850,6 @@ interface TraceKeepoutSolverInput {
2847
2850
  connMap: ConnectivityMap;
2848
2851
  colorMap: Record<string, string>;
2849
2852
  keepoutRadiusSchedule?: number[];
2850
- smoothDistance?: number;
2851
2853
  srj?: Pick<SimpleRouteJson, "outline" | "bounds">;
2852
2854
  }
2853
2855
  /**
@@ -2864,7 +2866,6 @@ declare class TraceKeepoutSolver extends BaseSolver {
2864
2866
  originalHdRoutes: HighDensityRoute$1[];
2865
2867
  hdRoutes: HighDensityRoute$1[];
2866
2868
  redrawnHdRoutes: HighDensityRoute$1[];
2867
- smoothDistance: number;
2868
2869
  KEEPOUT_RADIUS_SCHEDULE: number[];
2869
2870
  currentScheduleIndex: number;
2870
2871
  currentKeepoutRadius: number;
@@ -2872,18 +2873,20 @@ declare class TraceKeepoutSolver extends BaseSolver {
2872
2873
  smoothedCursorRoutes: HighDensityRoute$1[];
2873
2874
  processedRoutes: HighDensityRoute$1[];
2874
2875
  currentTrace: HighDensityRoute$1 | null;
2875
- cursorPosition: Point3D | null;
2876
- lastCursorPosition: Point3D | null;
2877
- drawPosition: Point2D | null;
2876
+ cursorPosition: Point3D$1 | null;
2877
+ lastCursorPosition: Point3D$1 | null;
2878
+ drawPosition: Point2D$1 | null;
2878
2879
  currentTraceSegmentIndex: number;
2879
2880
  currentTraceSegmentT: number;
2880
- recordedDrawPositions: Point3D[];
2881
+ recordedDrawPositions: Point3D$1[];
2881
2882
  lastCollidingSegments: Segment[];
2882
2883
  obstacleSHI: ObstacleSpatialHashIndex;
2883
2884
  hdRouteSHI: HighDensityRouteSpatialIndex;
2884
2885
  boardOutlineRoutes: HighDensityRoute$1[];
2885
2886
  constructor(input: TraceKeepoutSolverInput);
2887
+ getSmoothDistance(): number;
2886
2888
  _step(): void;
2889
+ getStepDistance(): number;
2887
2890
  /**
2888
2891
  * Steps the cursor forward by CURSOR_STEP_DISTANCE along the trace
2889
2892
  * Returns false if we've reached the end of the trace
@@ -2916,6 +2919,85 @@ declare class TraceKeepoutSolver extends BaseSolver {
2916
2919
  getRedrawnHdRoutes(): HighDensityRoute$1[];
2917
2920
  }
2918
2921
 
2922
+ interface Point2D {
2923
+ x: number;
2924
+ y: number;
2925
+ }
2926
+ interface Point3D extends Point2D {
2927
+ z: number;
2928
+ }
2929
+ interface TraceWidthSolverInput {
2930
+ hdRoutes: HighDensityRoute$1[];
2931
+ obstacles?: Obstacle[];
2932
+ connMap?: ConnectivityMap;
2933
+ colorMap?: Record<string, string>;
2934
+ nominalTraceWidth?: number;
2935
+ minTraceWidth: number;
2936
+ obstacleMargin?: number;
2937
+ }
2938
+ /**
2939
+ * TraceWidthSolver determines the optimal trace width for each route.
2940
+ * It uses a TRACE_WIDTH_SCHEDULE to try progressively narrower widths:
2941
+ * [nominalTraceWidth, (nominalTraceWidth + minTraceWidth)/2, minTraceWidth]
2942
+ *
2943
+ * For each trace, it walks along with a cursor checking clearance.
2944
+ * If clearance is insufficient for the current width, it tries the next
2945
+ * narrower width in the schedule.
2946
+ *
2947
+ * nominalTraceWidth defaults to minTraceWidth * 2 if not specified.
2948
+ */
2949
+ declare class TraceWidthSolver extends BaseSolver {
2950
+ hdRoutes: HighDensityRoute$1[];
2951
+ hdRoutesWithWidths: HighDensityRoute$1[];
2952
+ nominalTraceWidth: number;
2953
+ minTraceWidth: number;
2954
+ obstacleMargin: number;
2955
+ TRACE_WIDTH_SCHEDULE: number[];
2956
+ unprocessedRoutes: HighDensityRoute$1[];
2957
+ processedRoutes: HighDensityRoute$1[];
2958
+ currentTrace: HighDensityRoute$1 | null;
2959
+ cursorPosition: Point3D | null;
2960
+ currentTraceSegmentIndex: number;
2961
+ currentTraceSegmentT: number;
2962
+ currentScheduleIndex: number;
2963
+ currentTargetWidth: number;
2964
+ hasInsufficientClearance: boolean;
2965
+ currentWalkMinClearance: number;
2966
+ bestMinClearance: number;
2967
+ bestWidth: number;
2968
+ lastCollidingObstacles: Obstacle[];
2969
+ lastCollidingRoutes: HighDensityRoute$1[];
2970
+ lastClearance: number;
2971
+ obstacles: Obstacle[];
2972
+ obstacleSHI?: ObstacleSpatialHashIndex;
2973
+ hdRouteSHI: HighDensityRouteSpatialIndex;
2974
+ connMap?: ConnectivityMap;
2975
+ colorMap?: Record<string, string>;
2976
+ constructor(input: TraceWidthSolverInput);
2977
+ _step(): void;
2978
+ /**
2979
+ * Initializes/resets the cursor for processing a trace
2980
+ */
2981
+ private initializeCursor;
2982
+ /**
2983
+ * Steps the cursor forward by CURSOR_STEP_DISTANCE along the trace
2984
+ * Returns false if we've reached the end of the trace
2985
+ */
2986
+ private stepCursorForward;
2987
+ /**
2988
+ * Gets the minimum clearance at a given position from obstacles and other traces
2989
+ * Also updates lastCollidingObstacles and lastCollidingRoutes for visualization
2990
+ */
2991
+ private getClearanceAtPosition;
2992
+ /**
2993
+ * Finalizes the current trace with the given width
2994
+ */
2995
+ private finalizeCurrentTrace;
2996
+ visualize(): GraphicsObject;
2997
+ /** Returns the routes with determined widths. This is the primary output of the solver. */
2998
+ getHdRoutesWithWidths(): HighDensityRoute$1[];
2999
+ }
3000
+
2919
3001
  interface OffboardPortPoint {
2920
3002
  portPointId: string;
2921
3003
  x: number;
@@ -3076,6 +3158,7 @@ declare class AssignableAutoroutingPipeline2 extends BaseSolver {
3076
3158
  deadEndSolver?: DeadEndSolver;
3077
3159
  traceSimplificationSolver?: TraceSimplificationSolver;
3078
3160
  traceKeepoutSolver?: TraceKeepoutSolver;
3161
+ traceWidthSolver?: TraceWidthSolver;
3079
3162
  availableSegmentPointSolver?: AvailableSegmentPointSolver;
3080
3163
  portPointPathingSolver?: PortPointPathingSolver;
3081
3164
  multiSectionPortPointOptimizer?: MultiSectionPortPointOptimizer;
@@ -3090,7 +3173,7 @@ declare class AssignableAutoroutingPipeline2 extends BaseSolver {
3090
3173
  capacityNodes: CapacityMeshNode[] | null;
3091
3174
  capacityEdges: CapacityMeshEdge[] | null;
3092
3175
  cacheProvider: CacheProvider | null;
3093
- pipelineDef: (PipelineStep$1<typeof NetToPointPairsSolver> | PipelineStep$1<typeof RectDiffPipeline> | PipelineStep$1<typeof RelateNodesToOffBoardConnectionsSolver> | PipelineStep$1<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep$1<typeof AvailableSegmentPointSolver> | PipelineStep$1<typeof HyperPortPointPathingSolver> | PipelineStep$1<typeof SimpleHighDensitySolver> | PipelineStep$1<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep$1<typeof TraceSimplificationSolver> | PipelineStep$1<typeof TraceKeepoutSolver>)[];
3176
+ pipelineDef: (PipelineStep$1<typeof NetToPointPairsSolver> | PipelineStep$1<typeof RectDiffPipeline> | PipelineStep$1<typeof RelateNodesToOffBoardConnectionsSolver> | PipelineStep$1<typeof CapacityMeshEdgeSolver2_NodeTreeOptimization> | PipelineStep$1<typeof AvailableSegmentPointSolver> | PipelineStep$1<typeof HyperPortPointPathingSolver> | PipelineStep$1<typeof SimpleHighDensitySolver> | PipelineStep$1<typeof MultipleHighDensityRouteStitchSolver> | PipelineStep$1<typeof TraceSimplificationSolver> | PipelineStep$1<typeof TraceKeepoutSolver> | PipelineStep$1<typeof TraceWidthSolver>)[];
3094
3177
  constructor(srj: SimpleRouteJson, opts?: CapacityMeshSolverOptions$1);
3095
3178
  getConstructorParams(): readonly [SimpleRouteJson, CapacityMeshSolverOptions$1];
3096
3179
  currentPipelineStepIndex: number;