Skip to content

Combine close same-net trace segments during cleanup#392

Open
SadmanPinon wants to merge 2 commits into
tscircuit:mainfrom
SadmanPinon:combine-close-same-net-segments-29
Open

Combine close same-net trace segments during cleanup#392
SadmanPinon wants to merge 2 commits into
tscircuit:mainfrom
SadmanPinon:combine-close-same-net-segments-29

Conversation

@SadmanPinon
Copy link
Copy Markdown

@SadmanPinon SadmanPinon commented May 21, 2026

/claim #29
/claim #34
Refs #29
Refs #34

Summary

  • Adds a TraceCleanupSolver phase that combines close, parallel same-net trace segments.
  • Detects overlapping horizontal/vertical segments on the same net within the cleanup padding distance.
  • Snaps the shorter close segment onto the longer one, then simplifies the resulting path.
  • Preserves terminal pin legs so cleanup does not move component endpoints.
  • Rejects snaps that would create coincident overlap with a different-net segment.
  • Adds focused tests for same-net snapping, different-net safety, endpoint preservation, threshold behavior, and the issue Merge same-net trace lines that are close together (make at the same Y or same X) #34 example.

Before/After Proof For #34

Focused regression: tests/functions/combine-close-same-net-segments.test.ts

  • Before: trace a has same-net horizontal run (0, 0) -> (10, 0), while trace b has nearby overlapping run (1, 0.05) -> (9, 0.05).
  • After: trace b snaps onto the shared Y coordinate, so its internal run becomes (1, 0) -> (9, 0).
  • Endpoint safety: terminal legs on trace b remain attached through (-1, 2) -> (1, 0) and (9, 0) -> (9, 2); component endpoints are not moved.
  • Collision safety: the different-net regression keeps b at y = 0.05 when snapping would overlap a trace on another net.
  • Threshold safety: the outside-padding regression leaves traces unchanged when the offset is too large.

Validation

  • npx biome check lib/solvers/TraceCleanupSolver/combineCloseSameNetSegments.ts lib/solvers/TraceCleanupSolver/TraceCleanupSolver.ts tests/functions/combine-close-same-net-segments.test.ts
  • npx --yes -p typescript@5 tsc --noEmit
  • npx --yes bun test tests/functions/combine-close-same-net-segments.test.ts tests/examples/example17.test.ts
  • npx --yes bun test tests/examples/example34.test.ts tests/functions/combine-close-same-net-segments.test.ts
  • npm run build

Demo Video

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 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 May 21, 2026 8:40am

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