diff --git a/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts b/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts index 5a92ffcca..5ac7c9f08 100644 --- a/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +++ b/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts @@ -24,6 +24,7 @@ import { simplifyOrthogonalPath, traceCrossesBoundsInterior, tracePathCrossesAnyBounds, + tracePathCrossesAnyTrace, tracePathIntersectsBounds, } from "./geometry" import { getPinMap, getTracePins, toNetLabelPlacementPatch } from "./traces" @@ -815,9 +816,36 @@ export class AvailableNetOrientationSolver extends BaseSolver { } } + // The connector is checked against chips and other labels above, but not + // against existing traces — so a candidate could be accepted while its + // connector cut straight across another net, which reads as a short in the + // rendered schematic. Reject those and let the search try the next + // candidate. + if (this.connectorCrossesOtherNetTrace(connectorTrace, label)) { + return "trace-collision" + } + return "valid" } + /** + * True when the candidate's connector properly crosses a trace on a + * different net. Same-net traces are excluded: a connector legitimately + * meets the trace it is attaching to. + */ + private connectorCrossesOtherNetTrace( + connectorTrace: Point[], + label: NetLabelPlacement, + ) { + const otherNetTraces: Record = {} + for (const [id, trace] of Object.entries(this.traceMap)) { + if (trace.globalConnNetId === label.globalConnNetId) continue + otherNetTraces[id] = trace + } + + return tracePathCrossesAnyTrace(connectorTrace, otherNetTraces) + } + private isAcceptableTraceAnchorChipCollision( candidate: CandidateLabel, label: NetLabelPlacement, diff --git a/tests/bug-reports/bug-report-20260706T213649Z/__snapshots__/bug-report-20260706T213649Z.snap.svg b/tests/bug-reports/bug-report-20260706T213649Z/__snapshots__/bug-report-20260706T213649Z.snap.svg index b98797851..78f608ec2 100644 --- a/tests/bug-reports/bug-report-20260706T213649Z/__snapshots__/bug-report-20260706T213649Z.snap.svg +++ b/tests/bug-reports/bug-report-20260706T213649Z/__snapshots__/bug-report-20260706T213649Z.snap.svg @@ -1,6 +1,6 @@ -