@tscircuit/schematic-trace-solver 0.0.162 → 0.0.163

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
@@ -825,7 +825,7 @@ type CandidateLabel = {
825
825
  height: number;
826
826
  };
827
827
  type CandidateStatus$2 = "valid" | "chip-collision" | "text-collision" | "trace-collision" | "trace-clearance-violation" | "netlabel-collision";
828
- type CandidatePhase = "rotate" | "trace-anchor" | "outward-trace-anchor" | "shift" | "lateral-shift";
828
+ type CandidatePhase = "rotate" | "trace-anchor" | "connected-rail-shift" | "outward-trace-anchor" | "shift" | "lateral-shift";
829
829
  type EvaluatedCandidate = CandidateLabel & {
830
830
  status: CandidateStatus$2;
831
831
  selected: boolean;
@@ -902,6 +902,7 @@ declare class AvailableNetOrientationSolver extends BaseSolver {
902
902
  private getNetLabelHeight;
903
903
  private getCandidateStatus;
904
904
  private isAcceptableTraceAnchorChipCollision;
905
+ private staysOutsideConnectedPinRow;
905
906
  private getBoundsStatus;
906
907
  private isTraceTooCloseToLabel;
907
908
  private getLabelTraceClearanceBounds;
package/dist/index.js CHANGED
@@ -8831,6 +8831,7 @@ function getPaddedBounds(bounds, padding) {
8831
8831
 
8832
8832
  // lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts
8833
8833
  var LABEL_TRACE_CLEARANCE2 = 0.1;
8834
+ var CONNECTED_PIN_ROW_OVERLAP_TOLERANCE = 0.1;
8834
8835
  var AvailableNetOrientationSolver = class extends BaseSolver {
8835
8836
  inputProblem;
8836
8837
  traces;
@@ -9852,7 +9853,7 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
9852
9853
  label
9853
9854
  });
9854
9855
  if (boundsStatus !== "valid") {
9855
- if (phase !== "trace-anchor" || boundsStatus !== "chip-collision" || !this.isAcceptableTraceAnchorChipCollision(candidate, label, bounds)) {
9856
+ if (phase !== "trace-anchor" && phase !== "connected-rail-shift" || boundsStatus !== "chip-collision" || !this.isAcceptableTraceAnchorChipCollision(candidate, label, bounds) || phase === "connected-rail-shift" && !this.staysOutsideConnectedPinRow({ candidate, label, bounds })) {
9856
9857
  return boundsStatus;
9857
9858
  }
9858
9859
  const nonChipBoundsStatus = this.getBoundsStatus({
@@ -9906,6 +9907,15 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
9906
9907
  return anchorPoint.y < chipBounds.minY - EPS12 || anchorPoint.y > chipBounds.maxY + EPS12;
9907
9908
  });
9908
9909
  }
9910
+ staysOutsideConnectedPinRow(params) {
9911
+ const { candidate, label, bounds } = params;
9912
+ const pin = this.pinMap[label.pinIds[0]];
9913
+ if (!pin || !isYOrientation(candidate.orientation)) return false;
9914
+ if (candidate.anchorPoint.x < pin.x) {
9915
+ return bounds.maxX <= pin.x + CONNECTED_PIN_ROW_OVERLAP_TOLERANCE + EPS12;
9916
+ }
9917
+ return bounds.minX >= pin.x - CONNECTED_PIN_ROW_OVERLAP_TOLERANCE - EPS12;
9918
+ }
9909
9919
  getBoundsStatus(candidateBoundsCheck) {
9910
9920
  const { bounds, labelIndex, label, ignoreChipCollisions } = candidateBoundsCheck;
9911
9921
  if (!ignoreChipCollisions) {
@@ -10060,8 +10070,9 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
10060
10070
  orientation,
10061
10071
  direction,
10062
10072
  baseAnchor: connectorSource,
10063
- maxSearchDistance: this.maxSearchDistance,
10073
+ maxSearchDistance: this.getSearchDistanceLimit(label, orientation),
10064
10074
  outwardDistance: 0,
10075
+ phase: "connected-rail-shift",
10065
10076
  stopOnTraceCollision: false,
10066
10077
  connectorSource,
10067
10078
  startDistance: 0
@@ -51,6 +51,7 @@ import { visualizeAvailableNetOrientationSolver } from "./visualize"
51
51
  import { AvailableNetOrientationObstacleIndex } from "./AvailableNetOrientationObstacleIndex"
52
52
 
53
53
  const LABEL_TRACE_CLEARANCE = 0.1
54
+ const CONNECTED_PIN_ROW_OVERLAP_TOLERANCE = 0.1
54
55
 
55
56
  export class AvailableNetOrientationSolver extends BaseSolver {
56
57
  inputProblem: InputProblem
@@ -1443,9 +1444,11 @@ export class AvailableNetOrientationSolver extends BaseSolver {
1443
1444
  })
1444
1445
  if (boundsStatus !== "valid") {
1445
1446
  if (
1446
- phase !== "trace-anchor" ||
1447
+ (phase !== "trace-anchor" && phase !== "connected-rail-shift") ||
1447
1448
  boundsStatus !== "chip-collision" ||
1448
- !this.isAcceptableTraceAnchorChipCollision(candidate, label, bounds)
1449
+ !this.isAcceptableTraceAnchorChipCollision(candidate, label, bounds) ||
1450
+ (phase === "connected-rail-shift" &&
1451
+ !this.staysOutsideConnectedPinRow({ candidate, label, bounds }))
1449
1452
  ) {
1450
1453
  return boundsStatus
1451
1454
  }
@@ -1525,6 +1528,20 @@ export class AvailableNetOrientationSolver extends BaseSolver {
1525
1528
  })
1526
1529
  }
1527
1530
 
1531
+ private staysOutsideConnectedPinRow(params: {
1532
+ candidate: CandidateLabel
1533
+ label: NetLabelPlacement
1534
+ bounds: Bounds
1535
+ }) {
1536
+ const { candidate, label, bounds } = params
1537
+ const pin = this.pinMap[label.pinIds[0]!]
1538
+ if (!pin || !isYOrientation(candidate.orientation)) return false
1539
+ if (candidate.anchorPoint.x < pin.x) {
1540
+ return bounds.maxX <= pin.x + CONNECTED_PIN_ROW_OVERLAP_TOLERANCE + EPS
1541
+ }
1542
+ return bounds.minX >= pin.x - CONNECTED_PIN_ROW_OVERLAP_TOLERANCE - EPS
1543
+ }
1544
+
1528
1545
  private getBoundsStatus(candidateBoundsCheck: {
1529
1546
  bounds: Bounds
1530
1547
  labelIndex: number
@@ -1756,8 +1773,9 @@ export class AvailableNetOrientationSolver extends BaseSolver {
1756
1773
  orientation,
1757
1774
  direction,
1758
1775
  baseAnchor: connectorSource,
1759
- maxSearchDistance: this.maxSearchDistance,
1776
+ maxSearchDistance: this.getSearchDistanceLimit(label, orientation),
1760
1777
  outwardDistance: 0,
1778
+ phase: "connected-rail-shift",
1761
1779
  stopOnTraceCollision: false,
1762
1780
  connectorSource,
1763
1781
  startDistance: 0,
@@ -39,6 +39,7 @@ export type CandidateStatus =
39
39
  export type CandidatePhase =
40
40
  | "rotate"
41
41
  | "trace-anchor"
42
+ | "connected-rail-shift"
42
43
  | "outward-trace-anchor"
43
44
  | "shift"
44
45
  | "lateral-shift"
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "https://github.com/tscircuit/schematic-trace-solver.git"
6
6
  },
7
7
  "main": "dist/index.js",
8
- "version": "0.0.162",
8
+ "version": "0.0.163",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "start": "cosmos",