Skip to content

feat: add SameNetSegmentMergingSolver pipeline phase#173

Open
LuSrodri wants to merge 1 commit intotscircuit:mainfrom
LuSrodri:fix/same-net-segment-merging-phase
Open

feat: add SameNetSegmentMergingSolver pipeline phase#173
LuSrodri wants to merge 1 commit intotscircuit:mainfrom
LuSrodri:fix/same-net-segment-merging-phase

Conversation

@LuSrodri
Copy link
Copy Markdown

Summary

Implements a new pipeline phase (SameNetSegmentMergingSolver) that addresses the issue of same-net trace segments that are visually close but not aligned.

What it does

  • Groups all solved traces by their globalConnNetId
  • For each net with multiple traces, detects parallel segments (horizontal or vertical) that overlap along their primary axis and are within a configurable gapThreshold (default: 0.15 units)
  • Phase 1: Snaps movable interior segments toward the nearest anchored (endpoint) segment of the same net
  • Phase 2: Groups remaining movable segments by proximity and snaps them to their span-weighted average coordinate
  • Iterates up to 10 passes until stable
  • Normalizes paths after merging (deduplicates points, simplifies collinear segments)

Pipeline integration

The solver is inserted between TraceCleanupSolver and the final NetLabelPlacementSolver pass, so cleaned-up traces are merged before labels are re-placed.

Tests

5 unit tests added:

  • Snaps two close parallel same-net interior segments to the same coordinate
  • Does not merge segments from different nets
  • Does not merge segments farther apart than gapThreshold
  • Anchor (endpoint) segments are never moved — only interior segments snap
  • Solver correctly marks itself as solved on empty input

All 54 tests pass (was 49 before this PR), 0 regressions, 0 type errors.


/claim #29

Implements a new pipeline phase that finds trace segments on the same net
that are close together (within a configurable gapThreshold, default 0.15)
and snaps them to align, reducing visual clutter in schematic diagrams.

The solver runs after TraceCleanupSolver and before the final
NetLabelPlacementSolver pass. It groups traces by net, detects parallel
overlapping interior segments within the gap threshold, and iteratively
snaps movable segments toward anchored (endpoint) segments or to their
weighted-average coordinate. Endpoint segments are never moved.

Adds 5 unit tests covering: same-net merging, cross-net isolation,
gapThreshold enforcement, anchor preservation, and empty-trace edge case.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview, Comment Apr 11, 2026 3:53pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant