Skip to content

STEP import: a closed spline edge whose vertex sits just past the start keeps its body (#3951) - #3963

Draft
raykholo wants to merge 2 commits into
tangency-labs:mainfrom
raykholo:step-closed-edge-zero-range
Draft

raykholo wants to merge 2 commits into
tangency-labs:mainfrom
raykholo:step-closed-edge-zero-range

Conversation

@raykholo

@raykholo raykholo commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3951

A closed B-spline edge is split at its vertex parameter. The reader treated a vertex within span * 1e-7 of the curve's start as "at the start", but truck's knot-range check is absolute (1e-6), so a vertex between those two (2e-7 or 8e-7 on a 0 … 1 curve) produced a piece with a zero knot range. Evaluating that piece panicked with ZeroRange and the whole body was left out.

The reader now uses max(TOLERANCE, span * 1e-7) for recognising a vertex at either end, for trimming and as the minimum piece range. Ranges are checked before cutting and again on each returned piece; a range that still cannot be evaluated is reported as a degenerate spline edge instead of panicking. The change stays in the STEP reader (crates/kernel/src/step_in/geom.rs).

Before and after

The 43-line STEP from the issue (one planar face bounded by one closed degree-1 B-spline edge round a 20 mm square, vertex at parameter 2e-7), solidcraft-cli eval closed-edge-vertex-after-start.step:

Before (current main), nothing is imported, so there is nothing to render:

thread 'main' panicked at vendor/truck-geometry/src/nurbs/bspcurve.rs:301:14:
called `Result::unwrap()` on an `Err` value: ZeroRange
error: closed-edge-vertex-after-start.step: the operation failed: STEP import: no bodies (solid 'square': not imported: kernel internal error: step brep: called `Result::unwrap()` on an `Err` value: ZeroRange)

After (this branch): one body square, 1 face (plane), 1 edge, area 400.0 mm², bounding box (0, 0, 0) … (20, 20, 0).

solidcraft-cli snapshot closed-edge-vertex-after-start.step on this branch: the 20 × 20 mm face is read, iso view.

after

Tests

Two regression tests in the existing STEP reader test module:

  • the issue's square with the vertex at t = 2e-7, 8e-7, 0 and 1 − 8e-7, both edge orientations: one face, 400 mm² each;
  • tiny trims at several parameter scales, plus a closed curve too short to split, which now reports an error instead of panicking.

Both fail on main and pass here.

Validation (Linux x86_64)

  • cargo fmt --all -- --check: clean.
  • cargo clippy -p solidcraft-kernel --all-targets -- -D warnings: clean.
  • cargo test --profile ci -p solidcraft-kernel --lib -- step_in: 64 passed, 2 manual tests ignored.

…ngency-labs#3951)

A closed B-spline edge was split at its vertex parameter, and a vertex just past the curve's start produced a piece whose parameter range is below what the curve library accepts, so evaluating it panicked and the whole body was lost. A vertex that close to either end now counts as that end, and no piece below that range is produced.

Fixes tangency-labs#3951
@raykholo
raykholo force-pushed the step-closed-edge-zero-range branch from a8bcaf0 to d7194de Compare October 21, 2026 02:11
@raykholo
raykholo marked this pull request as ready for review October 21, 2026 02:11
@raykholo

Copy link
Copy Markdown
Contributor Author

Checked against the public model in tangency-labs/models#22 (five surface bodies, each bounded by one closed spline edge whose vertex sits 1e-9, 3e-8, 2e-7, 8e-7 or 5e-6 mm past the curve's start):

bodies kept area
0.18.1 3 of 5 (2e-7 and 8e-7 lost to ZeroRange) —
this PR 5 of 5 400 mm² each

The file attached to #3951 also gives 1 body, 400 mm², no panic. An open edge that crosses a closed curve's seam (starting 3e-8 … 5e-6 before the curve's end) already reads correctly on 0.18.1, so the problem is limited to closed edges.

@jyviko
jyviko marked this pull request as draft October 21, 2026 03:20
@jyviko jyviko added the kernel-paused Kernel work is paused while a new geometry kernel is evaluated label Oct 21, 2026
@jyviko

jyviko commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Thank you for this work! We're evaluating a new geometry kernel (solidcore), so kernel pull requests are on hold for now and I've set this one to draft: see #3992.

Nothing is lost: your branch, commits and review history stay exactly as they are. The case you fixed here goes into the new kernel's regression suite, so it stays fixed whatever kernel we end up on. And if you'd like to keep going on this kind of problem, we'd love your help in solidcore, starting with porting this case over as a test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel-paused Kernel work is paused while a new geometry kernel is evaluated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

STEP import: a closed spline edge whose vertex sits just past the curve's start loses the whole body (ZeroRange panic)

2 participants