Skip to content

Support finite PCB bend regions from board outlines - #5

Merged
seveibar merged 2 commits into
mainfrom
fix/finite-bend-regions
Oct 1, 2026
Merged

seveibar merged 2 commits into
mainfrom
fix/finite-bend-regions

Conversation

@seveibar

@seveibar seveibar commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Bends on one flex-board tail currently deform every point beyond the bend's infinite line, including neighboring tails. Add an optional board-local outline to createPcbFold so a finite boundary-to-boundary chord selects the connected region it cuts off. Include widened distal tips and allow overlapping bend positions on disjoint tails.

CAD points/directions, inverse placement, rigid-mount checks, stiffeners, and surface meshes use the same selected region. getCadFoldContext automatically converts the Circuit JSON board outline from world coordinates to board-local coordinates. Existing two-argument calls retain their behavior.

Addresses the folding utility underlying item 1 of tscircuit/tscircuit#5277. Core adoption is still required: update its flex-utils dependency and pass the emitted board outline minus board.center from Board.doInitialPcbFlexRender. Viewer/GLTF callers that construct folds directly need the same outline argument.

Scope remains parallel bends sharing a moving direction on simple outlines. Incomplete chords, branching within a bend zone, and moving regions wrapping behind the proximal tangent fail explicitly.

Validation:

  • 17 tests pass, including six topology regressions with the issue's outline, independent tails, widened tips, winding/endpoint/order invariance, translated CAD, surface meshes, rigid stiffeners, and inverse placement.
  • Typecheck, build, and diff checks pass. The PoppyGL PNG regression fails when infinite-line folding is restored.
  • An isolated core adoption patch passes all six flex tests, including the exact two-tail issue fixture at the origin and at (100, -70). The left resistor folds to z ≈ 5.2146 mm and x rotation 90° while the right resistor stays flat; PCB records remain unchanged and CAD round-trips. This consumer patch is not included here because it requires adopting the new dependency release.

Visual snapshots render the locally generated surface mesh with PoppyGL and use the standard toMatchPngSnapshot fixture. The camera is identical in both images. Red RL follows the left tail through its 90° bend; blue RR stays on the flat right tail.

Flat reference Finite left-tail fold
Flat two-tail board Only the left tail folds

@tscircuitbot

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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.

2 participants