Skip to content

fix: preserve real board outline from DSN boundary path - #542

Open
BySergiMM wants to merge 3 commits into
tscircuit:mainfrom
BySergiMM:patch-1
Open

BySergiMM wants to merge 3 commits into
tscircuit:mainfrom
BySergiMM:patch-1

Conversation

@BySergiMM

Copy link
Copy Markdown

Incremental progress on #54 (Smoothie Board conversion).

Problem

convertDsnPcbToCircuitJson reads the DSN (boundary (path ...)) but only uses it to derive center, width and height. The polygon itself is discarded, so every board is emitted as its bounding rectangle.

For the Smoothieboard fixture the boundary path has 38 distinct vertices (rounded corners, non-rectangular edges). The rendered SVG collapsed all of that into 4 corners:

before:  <path class="pcb-board" d="M ... L ... L ... L ... Z">   // 3 L commands
after:   <path class="pcb-board" d="M ... 37 L commands ... Z">   // 38 vertices

Change

PcbBoard in circuit-json already supports outline?: Point[] and shape?: "rect" | "polygon" — nothing was populating them. This fills them from the boundary path, transformed with the same transformDsnUnitToMm matrix used everywhere else in the converter.

The closing vertex is dropped when present, and the outline is only emitted when the path has more than 4 distinct points, so genuinely rectangular boards keep their current output.

Verification

  • bun test -> 54 pass, 1 skip. The only snapshot affected is repro7-smoothie-board, which is the intended effect.
  • bunx tsc --noEmit clean, bunx biome format clean.
  • width / height / center are unchanged (129.548 x 105.029 mm) — this only adds geometry that was being thrown away.

Note: tests/repros/__snapshots__/repro7-smoothie-board.snap.svg needs regenerating (bun test -u); I could not attach the 214 KB SVG through the web editor. Happy to push it if you prefer.

Written with AI assistance (Claude). Happy to adjust the >4-point heuristic or split this further.

The DSN (boundary (path ...)) describes the true board shape, but only its bounding box was used. PcbBoard already supports outline/shape, so populate them from the boundary path using the same transformDsnUnitToMm matrix.

For the Smoothieboard fixture the outline goes from 4 corners to its real 38 vertices. Guarded to >4 distinct points so rectangular boards are unchanged; width/height/center are untouched.

Incremental progress on tscircuit#54. Written with AI assistance (Claude).
@BySergiMM

Copy link
Copy Markdown
Author

The single failing check (Bun Test) is only the SVG snapshot: tests/repros/__snapshots__/repro7-smoothie-board.snap.svg still holds the old 4-corner rectangle path and needs regenerating.

bun test -u is enough — the only diff is inside the <path class="pcb-board"> d attribute, which goes from 3 L commands to 37. Type Check, Format Check and Format PR all pass, so the change itself is clean.

I could not attach the regenerated 214 KB SVG through the web editor. If you enable "Allow edits by maintainers" pushes or just run bun test -u on the branch, this goes green. Happy to open a follow-up PR with the snapshot alone if that is easier to review.

BySergiMM and others added 2 commits September 30, 2026 22:14
Convert DSN boundary paths to a pcb_board and assert that a
non-rectangular path yields a polygon outline with its real vertices
(closed and open paths, plus the Smoothieboard fixture), while a
rectangular path keeps the bounding box and gets no outline.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Uve3CM6GBS4y8gdk9KSHw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant