Skip to content

fix: create individual B-Rep box solid per component, fixing missing rectangles#59

Open
brutusworker-arch wants to merge 1 commit intotscircuit:mainfrom
brutusworker-arch:fix/resistor-boxes-individual-brep-solids
Open

fix: create individual B-Rep box solid per component, fixing missing rectangles#59
brutusworker-arch wants to merge 1 commit intotscircuit:mainfrom
brutusworker-arch:fix/resistor-boxes-individual-brep-solids

Conversation

@brutusworker-arch
Copy link
Copy Markdown

Root Cause

The previous code merged all component box triangles into a single ClosedShell/ManifoldSolidBrep. A ClosedShell in STEP must be a single connected closed surface — multiple disconnected boxes cannot form one valid shell. STEP viewers reject this invalid topology, causing component boxes to appear missing.

Fix

Replaced the triangle tessellation approach with proper B-Rep boxes (8 vertices, 12 edges, 6 planar faces per box) and create one ManifoldSolidBrep per component box, so each box is a topologically valid closed manifold.

Key changes in lib/mesh-generation.ts:

  • Added createBRepBoxSolid() — builds a proper B-Rep box in STEP (Z=up) coordinates from a GLTF (Y=up) box
  • generateComponentMeshes() now returns one solid per component instead of one combined solid

Before vs After

Before After
All components merged into 1 ManifoldSolidBrep (invalid topology) 1 ManifoldSolidBrep per component (valid closed shells)
Component boxes missing in STEP viewers Component boxes visible as expected
repro01: 2 solids (board + invalid combined mesh) repro01: 5 solids (board + 4 individual component boxes)

Test

Added basics07 test: 3 resistors on a board, verifies 4 solids (1 board + 3 resistors) are generated and all pass occt validation.

/claim #6

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

…rectangles

The previous code merged all component box triangles into a single
ClosedShell/ManifoldSolidBrep. A ClosedShell must be a single connected
closed surface, so multiple disconnected boxes created invalid topology
that STEP viewers rejected — causing components to appear missing.

Fix: replace triangle tesselation with proper B-Rep boxes (8 vertices,
12 edges, 6 planar faces) and create one ManifoldSolidBrep per component,
so each box is a valid closed manifold.

Fixes tscircuit#6.

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

vercel bot commented Mar 22, 2026

@brutusworker-arch 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.

1 participant