Skip to content

STEP import: a spline edge ending on a closed spline face's seam gets the pcurve between its ends, so its loop still closes after healing - #19590

Merged
bherbruck merged 2 commits into
tangency-labs:mainfrom
jkkicks:step-import-pcurve-ends-on-a-closed-forms-seam
Nov 19, 2026
Merged

bherbruck merged 2 commits into
tangency-labs:mainfrom
jkkicks:step-import-pcurve-ends-on-a-closed-forms-seam

Conversation

@jkkicks

@jkkicks jkkicks commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

When a STEP file's spline edge ends on the seam of a closed spline face (a cylinder's or cone's NURBS form), the reader now gives it the pcurve between its two ends. Before, it could take a straight (u, v) segment whose ends miss the edge's ends by up to half the file's tolerance, and the imported body then failed SmTrimmingTools test 0 ("Edge/Edge Gap") once healing set its edge tolerances.

Found on an imported part that cannot be attached.

Change

solidcore/crates/solidcore/src/eval/pcurve.rs, On::along: the closed form of an edge on a spline face. It tries straight segments in (u, v) in order, and takes the first that lifts onto the edge within half the record's tolerance:

  1. the segment between the projections of the edge's two ends;
  2. two segments with u or v fixed at the middle's value;
  3. "pace" segments through the middle's parameters, moving at the pace measured between the quarter and three-quarter points. Their ends are extrapolated from the middle, so they do not land on the edge's ends unless the edge really is such a line.

Defect. On a closed form, a point on the seam has two parameters, one at each end of the period. The ends were projected each on its own. An edge ending on the seam could get its end on the far side of the period from the rest of it. Segment 1 then runs the wrong way round the surface and misses. A pace segment was taken instead. For an edge that is not exactly a line in (u, v), such a segment can come within the tolerance and still have its ends off the edge's ends.

The record passes its check: every tolerance is the file's. Healing (Fix_TolSizes) then sets each edge's tolerance from the gaps of its 3D curve. The pcurve does not enter those gaps. Test 0 compares the face's surface at one pcurve's end and the next pcurve's start with the sum of the two edges' tolerances, and refuses the loop. So check_solid fails with PointersInvalid and AssertValid is skipped.

Fix. Each end's parameters are taken on the sheet of the edge's middle (uv::unwrap in each periodic direction), as the pace segments' own sample points already are. Segment 1 is then the one tried first and taken. Its ends are the edge's ends by construction. Nothing changes for an edge whose end projections were already on its middle's sheet: the parameters are the same bits, and the same candidate is taken.

Not changed. Which candidates exist, the order they are tried in, and the tolerance a candidate is checked at. A segment taken within half the record's tolerance may still lie up to that far from the edge between its ends, as before. No check measures a pcurve against its edge between its ends (docs/validity-and-tolerances.md §5.2).

Set aside.

  • Relaxing test 0 where the 3D curves meet. The gap is real in (u, v): the face's trimmed boundary does not close.
  • Raising the edge's tolerance to cover its pcurve. That covers a wrong pcurve instead of making the right one.
  • Refusing every segment that does not run through the edge's nearest points on the surface to rounding, so the kernel's trims make those pcurves (tried). It refuses a NURBS meridian whose ends lie 1e-8 beside a sphere's poles at a tolerance of 1e-7 (a_seam_from_pole_to_pole_encloses_the_whole_sphere). On imported parts it sent more uses of a face to the kernel's trims together, whose ends then failed test 0 against the closed forms left beside them.

Related: #12457 reports imports failing this same test. This is one cause of it, on the current reader. Whether the files in that issue have this cause is not shown, so this pull request does not close it. #19295 (proved bounds for kept trims on read) and #16284 (certified pcurves in pcurves_within) touch the same area: #16284 edits pcurve.rs elsewhere, not along, and neither changes which segment along takes.

Changes a default: no

Validation

New test a_spline_edge_ending_on_a_closed_forms_seam_gets_the_segment_between_its_ends (solidcore/crates/solidcore/src/eval/pcurve_tests.rs). A cubic Bézier on the NURBS form of a cylinder of radius 20: 0.05 rad round the axis, its angle quadratic in its parameter (5e-4 rad of it from the quadratic term), rising 0.35. It runs once ending on the form's seam (θ = 2π) and once ending at θ = 3. The segment between its ends and the pace segment each come within 5.0e-3 of it, under half of a tolerance of 0.02. The test asks that the pcurve's ends lift onto the edge's ends within 1e-9, and that the pcurve lifts within 0.01.

  • Without the fix, the case ending on the seam fails: the pcurve's start lifts 5.0e-3 from the edge's start.
  • With it, both cases pass.

On main at e35bc3930, compared with a run of the same commit without the change:

  • The new test fails without the change and passes with it (above).
  • cargo test --release --no-fail-fast, the six kernel packages: solidcore 7,348 passed / 0 failed / 55 ignored (without the change 7,347 / 0 / 55: the new test), solidcore-ops 913 / 0 / 12, solidcore-step 142 / 0 / 2, solidcore-convert 58 / 0 / 0, solidcore-tess 113 / 0 / 2, solidcore-record 113 / 0 / 4 (each the same without the change).
  • Goldens with upstream's test files (SOLIDCORE_REQUIRE_UPSTREAM=1): --all --goldens gives 283 units, 283 passed, 0 failed, 0 cases changed, added, removed or broken. --all --digest-dir --digest-debug: all 283 .debug files are byte-identical to those of the same commit without the change. No golden moves.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo check -p solidcore --target wasm32-unknown-unknown, python3 scripts/ci/check_panic_sites.py --base upstream/main: clean.
  • The STEP import of the part this was found on: before, check_solid fails with this test 0 line at every check level. After, the line is gone and the edge's pcurve ends on its vertices. The same user's other STEP files give byte-identical check output before and after.

Screenshots of the behavior (when observable)

None. The part this was found on cannot be attached. The new test builds the same situation in code: an edge on a closed form's seam whose pcurve's ends miss its vertices.

Integration status

Rebased onto main at 7a34819 (no conflicts). On the rebased head:

Goldens were compared digest by digest on e35bc3930 (above), not again on the rebased head.

#19531 (draft) changes close() in the same file, a different function; whichever merges second may need a textual rebase of pcurve_tests.rs, where both add a test.

Summary by CodeRabbit

  • Bug Fixes
    • Improved curve mapping across periodic boundaries, reducing inaccuracies when an edge crosses a surface seam.
    • Preserved exact endpoint alignment and improved mapping accuracy along the edge.

… the pcurve between its ends, so its loop still closes after healing

On a spline face (a NURBS form of a cylinder or cone), `On::along` gives an edge the first
straight (u, v) segment that lifts onto it within half the record's tolerance: the segment
between its ends' projections, then ones with u or v fixed at the middle's, then segments
through the middle at the middle's pace, whose ends are extrapolated from the middle.

The ends were projected each on its own. A point on a closed form's seam has two parameters,
and an edge ending there could get its end a period away from the rest of it. The segment
between the ends then ran the wrong way round and missed, and a pace segment was taken: for an
edge that is not exactly a line in (u, v), within the tolerance of it but with its ends off the
edge's ends. The record passes its check at the file's tolerances; after healing sets the edge
tolerances from the edges' 3D gaps, `SmTrimmingTools` test 0 (Edge/Edge Gap) refuses the loop.

Each end is now taken on the sheet of the edge's middle, as the pace segments' sample points
already are, so the segment between the ends is the one tried first and taken, ending on the
edge's ends. An edge whose ends were already on its middle's sheet gets the same bits.

Test: a_spline_edge_ending_on_a_closed_forms_seam_gets_the_segment_between_its_ends.
@jkkicks
jkkicks requested a review from a team as a code owner November 19, 2026 18:03
@jkkicks
jkkicks requested review from bherbruck and removed request for a team November 19, 2026 18:03
@github-actions github-actions Bot added the area:kernel B-rep kernel, booleans, blends, STEP/IGES label Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

On::along now aligns projected endpoints to the edge midpoint’s periodic parameter sheet before constructing p-curve candidates. A regression test checks endpoint lifting and sampled lift error for a spline edge on a cylinder.

Changes: Periodic p-curve endpoint alignment

Layer / File(s) Summary
Align p-curve candidates and test seam endpoints
solidcore/crates/solidcore/src/eval/pcurve.rs, solidcore/crates/solidcore/src/eval/pcurve_tests.rs
On::along uses midpoint-aligned endpoint projections for its candidates. The new test checks exact endpoint lifting and sampled lift error for a spline edge with an endpoint on the cylinder seam.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · previous review f839e

The change addresses seam-ending spline edges and adds focused regression coverage. No concrete merge-blocking defect was established; merge after normal checks pass.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Existing Defaults Unchanged Inconclusive Pull request inputs changed after this check was assessed; its verdict is no longer current. Re-run the check against the current pull request inputs.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title names the change: a STEP-imported spline edge ending on a closed spline face's seam now gets the pcurve between its ends, so its loop closes after healing. This matches the raw summary (On::…
Description check Passed The description covers the problem, the defect, the fix in On::along, what is not changed, validation (new test, golden comparisons, lint/fmt/clippy, wasm check), and integration status. It follows th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: a STEP-imported spline edge ending on a closed spline face's seam now gets the pcurve between its ends, so its loop closes after healing. This matches the raw summary (On::along unwraps endpoints to the midpoint's periodic sheet) and the PR objectives. It is specific, though long at 137 characters and 25 words, and it is a single sentence.

Full details: Description check

Explanation

The description covers the problem, the defect, the fix in On::along, what is not changed, validation (new test, golden comparisons, lint/fmt/clippy, wasm check), and integration status. It follows the template's Change, Validation, and Integration status sections and includes the required 'Changes a default: no' line. The screenshots section is present and explains why none is provided. A 'Test change:' line is not needed because the PR adds a test and does not modify existing expectations. The description is long and dense, but it is substantively complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between aa89806 and f839e54.

Files selected for processing: 2

  • solidcore/crates/solidcore/src/eval/pcurve.rs
  • solidcore/crates/solidcore/src/eval/pcurve_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@bherbruck bherbruck added the approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) label Nov 19, 2026
@bherbruck bherbruck added the ready to merge reviewed, every ask addressed; merge once CI is green label Nov 19, 2026
@bherbruck
bherbruck added this pull request to the merge queue Nov 19, 2026
Merged via the queue into tangency-labs:main with commit 20af2f5 Nov 19, 2026
88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) area:kernel B-rep kernel, booleans, blends, STEP/IGES ready to merge reviewed, every ask addressed; merge once CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants