Skip to content

STEP export: shelled revolved bodies export instead of panicking - #1496

Merged
bherbruck merged 3 commits into
tangency-labs:mainfrom
Ian-cmd-ops:fix/step-export-scaled-revolution
Oct 16, 2026
Merged

bherbruck merged 3 commits into
tangency-labs:mainfrom
Ian-cmd-ops:fix/step-export-scaled-revolution

Conversation

@Ian-cmd-ops

@Ian-cmd-ops Ian-cmd-ops commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Change

STEP export of a shelled revolved body failed, and the failure was a panic.

  • Why. A shell (or an offset) moves a revolved cylinder or cone face by a transform that scales across the axis differently from along it. truck's writer (vendor/truck-stepio/src/out/geometry.rs) only took uniform scales for a transformed surface of revolution. It refused the rest by returning fmt::Error.
  • How that became a panic. truck_step (crates/kernel/src/step.rs) called to_string() on the writer, which panics on that Err ("a Display implementation returned an error unexpectedly").
  • What users saw. On the desktop, guard catches the panic: the user sees "kernel internal error" and cannot export. The web build aborts on any panic.

How it was found. I round-tripped the robustness designs through STEP (export, then import). Seeds 19 and 24 hit it. Each shrinks to three commands: a three-quarter revolve of a rectangle, then a sphere cut or a chamfer, then a shell.

The fix has two parts:

  1. No panic on a refusal. truck_step formats the writer with write! and turns a refusal into KernelError::Failed("not supported yet: STEP export of this body (<the writer's reason>)").
  2. The writer takes more transforms. It now takes any transform that commutes with turning about the surface's axis: a similarity across the axis, with any scale along it. For those, revolving the transformed profile about the transformed axis gives exactly the transformed surface, as the uniform case already assumed. Any other transform is still refused, now as an error instead of a panic.

vendor/README.md records the vendored change.

Validation

Kernel tests:

  • step_in::tests::revolved_faces_scaled_across_the_axis_round_trip: a three-quarter revolve, scaled 1.5 across and 0.5 along its axis, exports and reads back with the same volume and area (the existing strict round_trip helper).
  • step_in::tests::revolved_faces_skewed_never_panic_on_export: scaled along one cross direction only, so no longer a surface of revolution. Export never panics. It either returns an error that says "not supported yet", or writes a file that round-trips.
  • Both fail without the change, with the seeds' panic, and pass with it.

Engine tests: crates/engine/tests/step_export_regressions.rs runs seeds 19 and 24 as engine commands. Both export and read back closed, with no warnings, and volume and area 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 runs:

Not run:

  • The full cargo xtask ci.
  • cargo xtask wasm: there is no wasm32 target in my environment. The change adds no platform code.

Screenshots of the behavior (when observable)

Not attached. Before: File → Export STEP on the seed 19 design fails with "kernel internal error". After: it writes a file that reads back with the same volume and area.

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 3 commits October 15, 2026 00:55
… refusal

A shell or an offset moves a revolved cylinder or cone face by a scale across
its axis that differs from the scale along it. truck's writer took only
uniform scales and refused the rest by returning fmt::Error, and truck_step
turned that into a panic with to_string() ("a Display implementation returned
an error unexpectedly"): STEP export of a shelled revolved body failed, and the
browser build aborts on any panic (robustness seeds 19 and 24).

- truck_step formats the writer with write! and turns a refusal into
  "not supported yet: STEP export of this body (<the writer's reason>)".
- The vendored writer takes any transform that commutes with turning about the
  surface's axis: across the axis a similarity onto the plane across the image
  axis, any scale along it. The transformed profile revolved about the
  transformed axis is then exactly the surface. Other transforms are refused as
  before.

Tests: a revolved body scaled 1.5 across and 0.5 along its axis round-trips;
one scaled along a single cross direction never panics on export; seeds 19 and
24 (shrunk to three steps each) export and read back as the same solid. The two
kernel tests fail without the change with the seeds' panic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bherbruck
bherbruck merged commit 63accec 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