Skip to content

STEP export: a merged partial cylinder keeps its cylinder (silent volume loss) - #1497

Merged
bherbruck merged 7 commits into
tangency-labs:mainfrom
Ian-cmd-ops:fix/step-merged-face-surface
Oct 16, 2026
Merged

bherbruck merged 7 commits into
tangency-labs:mainfrom
Ian-cmd-ops:fix/step-merged-face-surface

Conversation

@Ian-cmd-ops

Copy link
Copy Markdown
Contributor

Change

A STEP export could silently lose part of a body. The file read back closed, with no warning, but smaller.

Reproduction. Robustness seed 17, shrunk to two features:

  1. A thin three-quarter tube: a rectangle 10 to 12.5 mm from the axis, 27.5 mm tall, revolved 270°.
  2. A 1 mm shell with the bottom open.

Exported and read back, the volume drops from 2968.53 to 2754.67 mm³ (−7.2 %) and the area from 6048.43 to 5811.70 mm².

What goes wrong. Face by face, only the inner and outer walls change. Each loses 8.9 % of its area, about 24° of its 270°.

  1. truck writes each wall as three quarter-turn B-spline pieces.
  2. merge_split_faces joins them into one 270° face, which keeps one piece's surface.
  3. analytic_sheets should then rewrite that sheet as an exact cylinder, but doesn't.

In the written file, the merged ADVANCED_FACE has a 270° boundary, but its surface is still the first piece's quarter-turn B_SPLINE_SURFACE. The face runs far outside its own surface, and the reader loses part of it.

Why analytic_sheets skipped it. For a sheet that doesn't make a full turn, it puts the cylinder's seam opposite the face's middle. It took that middle as the mean direction of the face's vertices.

  • With vertices at 0°, 90°, 180° and 270°, that mean is zero, so no seam direction was found and the sheet was not rewritten.
  • For a face over 180° with only two vertices, the mean points into the gap, so the seam went into the middle of the face.

The fix. gap_middle (crates/kernel/src/step_out.rs) sorts the face's boundary vertices by angle about the axis. Every two neighbours are joined by one of the face's edges, except across the gap the face leaves. With exactly one gap, the seam goes in its middle. Faces with fewer than three vertex angles, or without exactly one gap, keep the mean as before.

Validation

  • Kernel test: step_in::tests::shelled_three_quarter_tube_round_trips (kernel calls: revolve, shell, then the existing strict round_trip). It fails without the change with the seed's volumes (2754.67 vs 2968.53) and passes with it.
  • Engine test: crates/engine/tests/step_merge_regressions.rs runs seed 17 as engine commands. It reads back closed, with no warnings, and volume and area are within 0.1 %.
  • Lint: cargo clippy --profile ci -p solidcraft-kernel -p solidcraft-engine --all-targets -- -D warnings and cargo fmt --all -- --check are clean.
  • Wider run: every kernel and engine test with step in its name passes. That includes those from feat: STEP import takes up for Y-up files and names for the bodies' names #1312, which changed STEP import. This was run on the branch merged with main, and with STEP export: shelled revolved bodies export instead of panicking #1496 (scaled revolved faces) applied as well.
  • Not run:
    • the full cargo xtask ci;
    • cargo xtask wasm, because there is no wasm32 target in my environment. The change is plain arithmetic.

Screenshots of the behavior (when observable)

Not attached. The loss shows as a volume or area difference after re-import, not in the app's view of the original body. The before and after are the numbers above.

Integration status

Merged upstream/main at 0872eb9, including #1312's STEP import changes, with no conflicts. The validation above ran after the merge.

Ian-cmd-ops and others added 2 commits October 15, 2026 00:55
The writer joins the pieces truck splits a revolved wall into (three quarter
turns of a 270° wall) into one face, and rewrites the B-spline sheet as an
exact cylinder or cone with its parameter seam opposite the face's middle. The
middle came from the mean direction of the face's vertices: zero for a face
split at 0°, 90°, 180° and 270°, so no seam was found, the sheet was not
rewritten, and the merged 270° face kept the first piece's quarter sheet. The
file's face ran far outside its own surface; read back, the body was closed,
with no warning, and 7% too small (robustness seed 17: 2968.53 mm³ became
2754.67). For a face over 180° with only two vertices the mean even put the
seam in the face's middle.

The seam now goes in the middle of the one angular gap the face leaves: its
vertices sorted by angle about the axis, each two neighbours joined by one of
its edges except across the gap. Faces with two vertices, or without exactly
one gap, keep the mean as before.

Tests: the shelled thin three-quarter tube of seed 17 round-trips at kernel
level (fails without the change with the seed's volumes) and through the
engine commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ian-cmd-ops and others added 2 commits October 15, 2026 21:31
…d-face seam

Upstream d8a088f (tangency-labs#1438) changed the seam search in analytic_sheets.
It now averages points sampled along the face's edges, not only the
edge ends. This conflicted with this branch's gap_middle in the same
match arm.

Resolution: take main's step_out.rs and drop gap_middle. Keep the two
seed 17 regression tests, so the case stays pinned in CI.

Evidence (cargo test --profile ci, 2 cores):
- step_in::tests::shelled_three_quarter_tube_round_trips fails on
  d8a088f^ (volume 2754.67 vs 2968.53) and passes on 843c548.
- step_merge_regressions passes on 843c548 with no step_out change.

Not shown: that main's mean is right for every merged face. A face
whose rim is split unevenly may still get its seam inside the face.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2968.53 mm3 read back as 2754.67 mm3: 7.2% short. Comment only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bherbruck

Copy link
Copy Markdown
Collaborator

Thanks for tracking this one down. Silent volume loss is exactly what I want caught. Main has moved under it in step_out.rs: #1198 changed the same seam fallback in analytic_sheets to sample points along the edges and fall back to the sheet's own middle. Could you rebase onto main and fit gap_middle in ahead of that fallback, so a merged partial cylinder still keeps its gap and a slot's half turn still finds its seam? Once it's rebased and CI is green I'll run the kernel checks and merge it.

…gh STEP

The merged wall of a wide partial tube leaves a gap of 60, 30 or 10 degrees.
Written against main's seam fallback; it records whether that fallback keeps
the volume on a face wider than 270 degrees.
analytic_sheets puts the parameter seam of a rewritten cylinder or cone in the
middle of the one angular gap the face leaves, found from its boundary vertices,
ahead of the edge-point fallback from tangency-labs#1198. A face with two corners (a slot's
half turn) or without exactly one gap has no such gap and keeps the fallback.
Ian-cmd-ops added a commit to Ian-cmd-ops/solidcraft that referenced this pull request Oct 15, 2026
Edit and comment for tangency-labs#1497 (tests only after the merge with main) and a
draft issue for robustness seed 55. The dry run passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bherbruck
bherbruck merged commit 42d4ebe into tangency-labs:main Oct 16, 2026
18 checks passed
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