Skip to content

Fix missing rectangles in STEP output#58

Open
mendarb wants to merge 1 commit intotscircuit:mainfrom
mendarb:fix/rectangle-brep-solids
Open

Fix missing rectangles in STEP output#58
mendarb wants to merge 1 commit intotscircuit:mainfrom
mendarb:fix/rectangle-brep-solids

Conversation

@mendarb
Copy link
Copy Markdown

@mendarb mendarb commented Mar 20, 2026

Summary

  • Root cause: Component boxes (resistors, capacitors, etc.) were converted to triangulated meshes with all triangles placed in a single ClosedShell. This produced invalid B-Rep geometry because multiple disconnected boxes in one shell is not a valid manifold solid, and triangular faces don't share edges properly.
  • Fix: Created a proper createBRepBoxSolid function that generates each component as its own ManifoldSolidBrep with 8 vertices, 12 shared edges, and 6 rectangular AdvancedFace entities — a valid closed shell. Boxes with custom meshes (from external models) still use the triangle approach but are now individual solids.
  • Result: OCCT now properly renders each resistor/component as a distinct rectangular box instead of dropping them.

Before: 26 separate triangle meshes (each just 1 triangle), components invisible in most viewers
After: 3-4 proper solid meshes (board + individual component boxes), all rendering correctly

Test plan

  • All existing tests pass (12/12)
  • Added basics07 test: verifies 3 resistor boxes appear as proper solids with correct dimensions (3x1.5x1.5mm)
  • Validated via occt-import-js that each component produces a proper mesh with correct bounding box
  • bunx biome format --write . applied

Closes #6

/claim #6

🤖 Generated with Claude Code

The previous implementation converted component boxes (resistors, etc.) to
triangulated meshes and placed all triangles in a single ClosedShell. This
produced invalid STEP geometry because:
1. Multiple disconnected boxes in one ClosedShell is not a valid manifold
2. Triangular faces don't share edges properly for B-Rep topology

The fix creates proper B-Rep box solids using 8 vertices, 12 shared edges,
and 6 rectangular faces per component, each as its own ManifoldSolidBrep.
Boxes with custom meshes (from external models) still use the triangle
approach but are now created as individual solids.

Closes tscircuit#6

/claim tscircuit#6

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 20, 2026

@mendarb is attempting to deploy a commit to the tscircuit Team on Vercel.

A member of the Team first needs to authorize it.

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.

Determine why rectangles are missing in output

1 participant