@tscircuit/schematic-trace-solver 0.0.51 → 0.0.53

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.
Files changed (30) hide show
  1. package/dist/index.d.ts +65 -6
  2. package/dist/index.js +835 -80
  3. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +3 -39
  4. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +16 -0
  5. package/lib/solvers/SchematicTracePipelineSolver/colorAvailableNetOrientationLabels.ts +54 -0
  6. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/TraceAnchoredNetLabelOverlapSolver.ts +331 -0
  7. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/candidates.ts +387 -0
  8. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/geometry.ts +254 -0
  9. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/types.ts +47 -0
  10. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/visualize.ts +159 -0
  11. package/package.json +1 -1
  12. package/tests/assets/example30.json +4 -1
  13. package/tests/examples/__snapshots__/example01.snap.svg +6 -3
  14. package/tests/examples/__snapshots__/example02.snap.svg +8 -4
  15. package/tests/examples/__snapshots__/example04.snap.svg +4 -2
  16. package/tests/examples/__snapshots__/example07.snap.svg +10 -5
  17. package/tests/examples/__snapshots__/example12.snap.svg +8 -4
  18. package/tests/examples/__snapshots__/example13.snap.svg +16 -8
  19. package/tests/examples/__snapshots__/example14.snap.svg +16 -8
  20. package/tests/examples/__snapshots__/example15.snap.svg +18 -9
  21. package/tests/examples/__snapshots__/example16.snap.svg +8 -4
  22. package/tests/examples/__snapshots__/example17.snap.svg +9 -5
  23. package/tests/examples/__snapshots__/example18.snap.svg +10 -5
  24. package/tests/examples/__snapshots__/example20.snap.svg +6 -3
  25. package/tests/examples/__snapshots__/example21.snap.svg +17 -12
  26. package/tests/examples/__snapshots__/example22.snap.svg +8 -4
  27. package/tests/examples/__snapshots__/example25.snap.svg +18 -9
  28. package/tests/examples/__snapshots__/example30.snap.svg +74 -62
  29. package/tests/examples/__snapshots__/example31.snap.svg +2 -1
  30. package/tests/fixtures/matcher.ts +21 -0
package/dist/index.d.ts CHANGED
@@ -642,10 +642,10 @@ type CandidateLabel = {
642
642
  width: number;
643
643
  height: number;
644
644
  };
645
- type CandidateStatus = "valid" | "chip-collision" | "trace-collision" | "netlabel-collision";
645
+ type CandidateStatus$1 = "valid" | "chip-collision" | "trace-collision" | "netlabel-collision";
646
646
  type CandidatePhase = "rotate" | "shift";
647
647
  type EvaluatedCandidate = CandidateLabel & {
648
- status: CandidateStatus;
648
+ status: CandidateStatus$1;
649
649
  selected: boolean;
650
650
  phase: CandidatePhase;
651
651
  distance?: number;
@@ -691,11 +691,8 @@ declare class AvailableNetOrientationSolver extends BaseSolver {
691
691
  private getSearchDistanceLimit;
692
692
  private createCandidate;
693
693
  private getNetLabelWidth;
694
- private isLabelPlacementValid;
695
- private isCandidateValidWithOffset;
696
694
  private getCandidateStatus;
697
695
  private getBoundsStatus;
698
- private getOffsetCollisionBounds;
699
696
  private intersectsAnyOtherNetLabel;
700
697
  private sharesChipBoundary;
701
698
  private getChipSideForPoint;
@@ -760,6 +757,67 @@ declare class VccNetLabelCornerPlacementSolver extends BaseSolver {
760
757
  visualize(): GraphicsObject;
761
758
  }
762
759
 
760
+ interface TraceAnchoredNetLabelOverlapSolverParams {
761
+ inputProblem: InputProblem;
762
+ traces: SolvedTracePath[];
763
+ netLabelPlacements: NetLabelPlacement[];
764
+ }
765
+ type LabelOverlap = {
766
+ firstLabelIndex: number;
767
+ secondLabelIndex: number;
768
+ };
769
+ type CandidateStatus = "valid" | "chip-collision" | "trace-collision" | "netlabel-collision";
770
+ type LabelCandidate = {
771
+ anchorPoint: Point;
772
+ center: Point;
773
+ width: number;
774
+ height: number;
775
+ orientation: FacingDirection;
776
+ traceId: string;
777
+ pathDistance: number;
778
+ distanceFromOriginal: number;
779
+ status: CandidateStatus;
780
+ selected: boolean;
781
+ };
782
+
783
+ declare class TraceAnchoredNetLabelOverlapSolver extends BaseSolver {
784
+ inputProblem: InputProblem;
785
+ traces: SolvedTracePath[];
786
+ netLabelPlacements: NetLabelPlacement[];
787
+ outputNetLabelPlacements: NetLabelPlacement[];
788
+ currentOverlap: LabelOverlap | null;
789
+ currentCandidateResults: LabelCandidate[];
790
+ private activeSearch;
791
+ private skippedOverlapKeys;
792
+ constructor(params: TraceAnchoredNetLabelOverlapSolverParams);
793
+ getConstructorParams(): ConstructorParameters<typeof TraceAnchoredNetLabelOverlapSolver>[0];
794
+ _step(): void;
795
+ getOutput(): {
796
+ netLabelPlacements: NetLabelPlacement[];
797
+ };
798
+ private findNextOverlap;
799
+ private isLabelEligible;
800
+ private labelsOverlap;
801
+ private startNextOverlapSearch;
802
+ private getMoveLabelIndices;
803
+ private getNextSearchWithCandidates;
804
+ private activateNextLabelSearch;
805
+ private skipSearch;
806
+ private evaluateNextCandidate;
807
+ private getCandidatesForLabel;
808
+ private getCandidateStatus;
809
+ private applyCandidate;
810
+ private intersectsAnyChip;
811
+ private intersectsAnyOtherLabel;
812
+ private getTraceLocationsForLabel;
813
+ private isTraceAssociatedWithLabel;
814
+ private getOverlapKey;
815
+ private finish;
816
+ private setActiveSearch;
817
+ private clearActiveSearch;
818
+ visualize(): GraphicsObject;
819
+ }
820
+
763
821
  /**
764
822
  * Pipeline solver that runs a series of solvers to find the best schematic layout.
765
823
  * Coordinates the entire layout process from chip partitioning through final packing.
@@ -788,12 +846,13 @@ declare class SchematicTracePipelineSolver extends BaseSolver {
788
846
  example28Solver?: Example28Solver;
789
847
  availableNetOrientationSolver?: AvailableNetOrientationSolver;
790
848
  vccNetLabelCornerPlacementSolver?: VccNetLabelCornerPlacementSolver;
849
+ traceAnchoredNetLabelOverlapSolver?: TraceAnchoredNetLabelOverlapSolver;
791
850
  startTimeOfPhase: Record<string, number>;
792
851
  endTimeOfPhase: Record<string, number>;
793
852
  timeSpentOnPhase: Record<string, number>;
794
853
  firstIterationOfPhase: Record<string, number>;
795
854
  inputProblem: InputProblem;
796
- pipelineDef: (PipelineStep<typeof MspConnectionPairSolver> | PipelineStep<typeof SchematicTraceLinesSolver> | PipelineStep<typeof LongDistancePairSolver> | PipelineStep<typeof TraceOverlapShiftSolver> | PipelineStep<typeof NetLabelPlacementSolver> | PipelineStep<typeof TraceLabelOverlapAvoidanceSolver> | PipelineStep<typeof TraceCleanupSolver> | PipelineStep<typeof Example28Solver> | PipelineStep<typeof AvailableNetOrientationSolver> | PipelineStep<typeof VccNetLabelCornerPlacementSolver>)[];
855
+ pipelineDef: (PipelineStep<typeof MspConnectionPairSolver> | PipelineStep<typeof SchematicTraceLinesSolver> | PipelineStep<typeof LongDistancePairSolver> | PipelineStep<typeof TraceOverlapShiftSolver> | PipelineStep<typeof NetLabelPlacementSolver> | PipelineStep<typeof TraceLabelOverlapAvoidanceSolver> | PipelineStep<typeof TraceCleanupSolver> | PipelineStep<typeof Example28Solver> | PipelineStep<typeof AvailableNetOrientationSolver> | PipelineStep<typeof VccNetLabelCornerPlacementSolver> | PipelineStep<typeof TraceAnchoredNetLabelOverlapSolver>)[];
797
856
  constructor(inputProblem: InputProblem);
798
857
  getConstructorParams(): ConstructorParameters<typeof SchematicTracePipelineSolver>[0];
799
858
  currentPipelineStepIndex: number;