Skip to content

feat: add SameNetSegmentMergingSolver to merge close same-net trace segments#174

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

feat: add SameNetSegmentMergingSolver to merge close same-net trace segments#174
LuSrodri wants to merge 1 commit intotscircuit:mainfrom
LuSrodri:fix/same-net-merging-issue-34

Conversation

@LuSrodri
Copy link
Copy Markdown

Summary

Implements a new SameNetSegmentMergingSolver pipeline phase that merges parallel trace segments from the same net when they are within a configurable gap threshold, reducing visual clutter in schematic diagrams.

Changes

  • lib/solvers/SameNetSegmentMergingSolver/SameNetSegmentMergingSolver.ts — new solver that:

    • Groups traces by globalConnNetId
    • For each net, finds parallel horizontal/vertical segments across different traces
    • Phase 1: snaps movable interior segments toward anchored endpoint segments
    • Phase 2: groups movable segments within gapThreshold (default 0.15) and snaps them to a span-weighted average coordinate
    • Runs up to 10 iterative passes until stable
    • Normalizes (deduplicates + simplifies) paths after merging
  • lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts — integrates the solver as a new pipeline phase after TraceCleanupSolver, with a final NetLabelPlacementSolver re-run using the merged traces

  • tests/solvers/SameNetSegmentMergingSolver/SameNetSegmentMergingSolver.test.ts — 5 unit tests covering: same-net snapping, cross-net isolation, gap threshold enforcement, anchor protection, and solver lifecycle

Test results

5 pass, 0 fail

/claim #34

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.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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 4:12pm

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