Skip to content

fix: process each component box as separate ManifoldSolidBrep in STEP export#42

Open
LiamConner10 wants to merge 1 commit intotscircuit:mainfrom
LiamConner10:fix/separate-component-solids
Open

fix: process each component box as separate ManifoldSolidBrep in STEP export#42
LiamConner10 wants to merge 1 commit intotscircuit:mainfrom
LiamConner10:fix/separate-component-solids

Conversation

@LiamConner10
Copy link

Summary

  • Each component box from scene3d.boxes is now processed individually
  • Creates a separate ManifoldSolidBrep for each component with its own ClosedShell
  • Previously all triangles were merged into a single ClosedShell, violating STEP's requirement that each solid have its own watertight boundary

Root Cause

The original code collected ALL triangles from ALL component boxes into a single allTriangles[] array, then created ONE ClosedShell and ONE ManifoldSolidBrep from them. This violated STEP's constraint that each solid must have its own closed, watertight boundary - you can't merge multiple disconnected meshes into one shell.

The Fix

Process each box separately in the loop, creating individual solids:

for (const box of scene3d.boxes) {
  let boxTriangles: GLTFTriangle[] = []
  // ... get triangles for THIS box only
  if (boxTriangles.length > 0) {
    // Create INDIVIDUAL solid for this component
    const componentShell = repo.add(new ClosedShell("", componentFaces))
    const componentSolid = repo.add(new ManifoldSolidBrep(box.label || "Component", componentShell))
    solids.push(componentSolid)
  }
}

Test Plan

  • All 10 existing tests pass (bun test)
  • Type check passes (bunx tsc --noEmit)
  • Snapshot updated for mesh-with-component01

Fixes #6

🤖 Generated with Claude Code

… export

Previously all triangles from all component boxes were merged into a single
ClosedShell, which violated STEP's requirement that each solid have its own
watertight boundary. This caused components to be missing from STEP output.

Now each box from scene3d.boxes is processed individually, creating a separate
ManifoldSolidBrep for each component with its own ClosedShell.

Fixes tscircuit#6

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

vercel bot commented Dec 27, 2025

Someone 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Determine why rectangles are missing in output

1 participant