Skip to content

solidcore: a body whose trim ends in a span shorter than the knot zero saves to a record again (tangency-labs/solidcore#3387) - #23969

Merged
tangency-repo-manager[bot] merged 8 commits into
tangency-labs:mainfrom
MarkusReichart:fix/sc3387-record-knot-multiplicity
Nov 29, 2026
Merged

tangency-repo-manager[bot] merged 8 commits into
tangency-labs:mainfrom
MarkusReichart:fix/sc3387-record-knot-multiplicity

Conversation

@MarkusReichart

@MarkusReichart MarkusReichart commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Change

Fixes tangency-labs/solidcore#3387.

A solid of the NIST PMI file nist_ftc_09_asme1_rd.stp (#5384) builds, but saving it as a B-rep record failed with knot multiplicity. Now it saves and reads back.

Cause: a hole's trim on a plane face has knots [e, e, e, 1, 1, 2, 2, d, d, d], d = 2 + 1.28e-12, which is valid. The kernel's knot fix-up (fixup_knot_vector, port of sm_FixupKnotVector) makes knots closer than the scaled zero of the end knots (3e-12) one knot, so its copy has knot 2 five times at degree 2, and keeps the two control points of the emptied span. The record refuses that.

Change: the record of a kernel curve (spline_record for an edge, record_trim for a pcurve) leaves out each control point P_j whose window u_j..u_(j+p+1) is one knot, with u_j (drop_empty_basis). N_(j,p) is zero there (The NURBS Book P2.1) and the other basis functions keep their knots, so the record's curve is the kernel's on its domain. The kernel's curves stay as ported: its evaluation already skips empty spans. Dropping the points in the fix-up itself moved the goldens of four units, and two blend.fillet_geom_p1 cases no longer built their face. Upstream defect: plan/upstream-issues/WR-23969--….

Changes a default: no

Validation

  • a_pcurve_span_shorter_than_the_kernels_knot_zero_goes_round (solidcore-convert/tests/brep.rs): a square sheet whose pcurve ends in a 1.2785e-12 span goes round twice; saved pcurve [0, 0, 1, 1], (0, 0) to (1, 0); 1 face, 4 edges, 4 vertices. Red at 5f924d2 (Invalid("knot multiplicity")), green at the head.
  • a_record_leaves_out_a_control_point_of_an_emptied_span, a_span_the_fixup_empties_loses_its_control_points, runs_at_the_start_and_inside_lose_their_dead_points: knots and points by hand.
  • NIST THREAD: operation failed #5384 at 396440c (later commits: a test case, a doc comment), default flags and every flag on, trusted true and false: 158 faces and 454 edges, as read; the record reads back. At main 3f0e582 all four failed.
  • Full gate at 11180b9: cargo test -p solidcore -p solidcore-convert 9854 passed, 0 failed; goldens: 283 unit(s), 283 passed, 0 failed.

Not run: the test suites of crates this change does not touch, doctests, publish dry run and the kernel rig, left to CI.

Units: nurbs.nurbs_crv
In scope: a kernel curve's record keeps every knot at most degree + 1 times.
Expected edits: curve/from_parameters.rs and its tests, nurbs/nurbs_crv.rs, solidcore-convert/tests/brep.rs, plan/upstream-issues/
Evidence: under Validation.
Related PRs / dependencies: #23227, #22637, #14683, #11776 touch the same test files.
Available follow-ups: the fix-up in the kernel's own curves, surfaces and volumes. ftc_06, ftc_08 and ctc_04 fail earlier, at import.
Status / blockers / next step: ready for review.

Screenshots of the behavior (when observable)

Nothing in the body changes on screen. The sketch shows the mechanism: the knot vectors of the trim as imported (valid), after the kernel's fix-up (knot 2 five times), and in the record (knot 2 three times).

Knot vectors of the trim: the import's (valid), after the kernel's fix-up (knot 2 five times), and the record (knot 2 three times)

Integration status

Branched from main c94db18; merges into main 4ab8112 without conflicts.

Co-written and tested with Claude Code (AI).

Summary by CodeRabbit

  • Bug Fixes
    • Fixed curve and trim conversions that could retain control points for empty spans. Saved records now omit unsupported control points and their associated knots.
    • Improved round-trip consistency for curves with very short end spans, including rational trims. Converting affected geometry to a record and back preserves a valid body and avoids excess knot multiplicity.

…zero going round (solidcore#3387)

A record pcurve whose last span is shorter than the scaled zero of its
end knots (the span a STEP import cut at 2 + 1.2785e-12 on the knot 2 of
a circle's form, NIST nist_ftc_09_asme1_rd.stp tangency-labs#5384) reads into the
kernel, but its record fails with "knot multiplicity": the kernel makes
the close knots one and keeps the control point of the empty span.

The test fails until the fix.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Serialization now removes control points with unsupported NURBS basis functions and their corresponding knots from spline and trim records. Regression tests cover curve behavior, trim serialization, and B-rep round trips.

Changes: NURBS record serialization

Layer / File(s) Summary
Detect and remove empty basis functions
solidcore/crates/solidcore/src/nurbs/nurbs_crv.rs, solidcore/plan/upstream-issues/WR-23969--fixupknotvector-empties-a-span-and-keeps-its-control-points.md
Adds drop_empty_basis to remove unsupported control points and corresponding knots when curve checks pass and rebuilding succeeds. Tests check knot runs, retained evaluations, and no-op behavior. The issue report describes the knot and control-point mismatch and the scope of this change.
Apply pruning during record serialization
solidcore/crates/solidcore/src/curve/from_parameters.rs, solidcore/crates/solidcore/src/curve/from_parameters/tests.rs, solidcore/crates/solidcore-convert/tests/brep.rs
Spline and trim serialization clone NURBS curves and prune unsupported basis functions before writing knots and control points. Regression tests cover spline and trim records and B-rep round trips.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 11180

Record export now omits control points that have no basis support, which lets the NIST #5384 body save and read back. The kernel fix-up is unchanged and the pruning only affects the written record. The investigation found no concrete defect, and the author reports the targeted test suites passing.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the actual fix: a body whose trim ends in a span shorter than the knot zero now saves to a record again. The changeset matches it: a regression test, a curve-record change that drops c…
Description check Passed The description follows the template's main sections (Change, Validation, Screenshots, Integration status). The Change section explains the problem, cause, and fix, and links the issue. It states that…
Linked Issues check Passed Directly linked issue #3387 requires that a body assembled from an accepted record exports back to a record. The reported failure is Record("knot multiplicity") for NIST #5384 with trusted true an…
Out of Scope Changes check Passed All changed files match the expected edits in the PR: curve/from_parameters.rs and its tests, nurbs/nurbs_crv.rs, solidcore-convert/tests/brep.rs, and plan/upstream-issues/. Each change connects to th…
Existing Defaults Unchanged Passed The check fails only when a UX default a user relies on changes, or when the change is not purely additive. The PR changes no UX default. Evidence: - The changed files are `solidcore/crates/solidcore-…
Full details: Title check

Explanation

The title names the actual fix: a body whose trim ends in a span shorter than the knot zero now saves to a record again. The changeset matches it: a regression test, a curve-record change that drops control points of emptied spans, and an upstream issue note. The title is long (125 characters, 20 words) and carries the issue reference, but it still describes the main change.

Full details: Description check

Explanation

The description follows the template's main sections (Change, Validation, Screenshots, Integration status). The Change section explains the problem, cause, and fix, and links the issue. It states that the change does not alter defaults, and it gives concrete validation results. The screenshot section explains that nothing changes on screen and provides a diagram of the knot mechanism. The template's guidance asks for observable-behaviour evidence, and this kernel-level fix has no UI change, so the explanation is acceptable. The Change section uses internal jargon (sm_FixupKnotVector, NURBS terms) without a plain-words introduction for newcomers to the project, and the PR states that the test-change line is absent even though no existing test expectation is changed (the goldens of four units moved only in an abandoned approach). Minor gaps remain, but the description is mostly complete.

Full details: Linked Issues check

Explanation

Directly linked issue #3387 requires that a body assembled from an accepted record exports back to a record. The reported failure is Record("knot multiplicity") for NIST #5384 with trusted true and false.

The change implements this. spline_record (curve/from_parameters.rs) and record_trim (same file) now clone the NURBS and call drop_empty_basis before serializing. drop_empty_basis (nurbs/nurbs_crv.rs) removes each control point P_j whose window u_j..u_(j+p+1) is one repeated knot, together with one copy of that knot. Such a span has N_(j,p) = 0, so the remaining knot vector has no knot repeated more than degree + 1 times. The added tests check that the knots and control points are as expected and that evaluations match the fixed-up curve on its domain. The regression test a_pcurve_span_shorter_than_the_kernels_knot_zero_goes_round in solidcore-convert/tests/brep.rs covers the saved pcurve knots [0, 0, 1, 1].

The PR reports that #5384 reads back at the head (158 faces, 454 edges, record reads back) with all flags, and that it failed on main. I did not run the tests. The result rests on the diff and the PR's reported validation.

The linked issue also names ftc_06, ctc_04 and ftc_08. The PR states that these fail at import, before assembly. They are not assembled bodies, and the issue did not re-run them at the reviewed revision. This does not change the verdict for the reported case.

Full details: Out of Scope Changes check

Explanation

All changed files match the expected edits in the PR: curve/from_parameters.rs and its tests, nurbs/nurbs_crv.rs, solidcore-convert/tests/brep.rs, and plan/upstream-issues/. Each change connects to the #3387 record failure:

  • drop_empty_basis and its three unit tests implement the control-point removal.
  • spline_record and record_trim call the helper before serializing.
  • The doc-comment updates in from_parameters.rs and the module table in nurbs_crv.rs describe the new helper. They are documentation for the same change.
  • The brep.rs regression test covers the same empty-span case.
  • The upstream-issues note records the defect and the record-only workaround.

The kernel fix-up (fixup_knot_vector) is unchanged, as the PR states. The PR also reports that changing the fix-up moved four goldens, so it was not changed. I found no unrelated change in the diff.

Full details: Existing Defaults Unchanged

Explanation

The check fails only when a UX default a user relies on changes, or when the change is not purely additive. The PR changes no UX default. Evidence: - The changed files are solidcore/crates/solidcore-convert/tests/brep.rs, solidcore/crates/solidcore/src/curve/from_parameters.rs and its tests.rs, solidcore/crates/solidcore/src/nurbs/nurbs_crv.rs, and one new plan document under solidcore/plan/upstream-issues/. No settings, preferences, shortcuts, layout, or CLI defaults files are touched. - A search of added and removed diff lines for default, preference, setting, config, shortcut, keybind, flag, and layout found only one doc line. It describes test runs with default flags and is not a default change. - The change alters kernel record output. spline_record and record_trim now omit control points whose basis functions have no support. Under the check's own wording, a changed kernel or geometry result, including anything under solidcore/, is not a changed default. The NIST case moves from refused to saved. That is also a "case that now builds or is now refused" change, which the check excludes. - The PR description states Changes a default: no. The code does not contradict that statement. Note: the kernel fix-up itself stays as ported. The PR changes only the record export path. This does not affect the verdict.

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 c94db18 and 11180b9.

Files selected for processing: 5

  • solidcore/crates/solidcore-convert/tests/brep.rs
  • solidcore/crates/solidcore/src/curve/from_parameters.rs
  • solidcore/crates/solidcore/src/curve/from_parameters/tests.rs
  • solidcore/crates/solidcore/src/nurbs/nurbs_crv.rs
  • solidcore/plan/upstream-issues/WR-23969--fixupknotvector-empties-a-span-and-keeps-its-control-points.md

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

@github-actions github-actions Bot added the area:kernel B-rep kernel, booleans, blends, STEP/IGES label Nov 29, 2026
MarkusReichart and others added 7 commits November 29, 2026 02:24
…t empties (solidcore#3387)

fixup_knot_vector (sm_FixupKnotVector) makes knots closer than the
scaled zero of the end knots one knot. Where that empties a span (a trim
cut 1.28e-12 past a knot of a circle's form, NIST
nist_ftc_09_asme1_rd.stp tangency-labs#5384), the control points that bore only on
it stayed, and the knot repeated more than degree + 1 times: the body's
record was refused with "knot multiplicity".

Every fix-up of a B-spline curve's knots now goes through
fixup_curve_knots, which drops each control point P_j with
u_j = u_(j+p+1) together with u_j. N_(j,p) is zero there (local support,
The NURBS Book P2.1), and the other basis functions keep their windows
of p + 2 knots, so the curve is the same on its domain.

Co-Authored-By: Claude Code <noreply@anthropic.com>
crv_eval fails at the domain's ends (sm_BasisEval's flag), so the
comparison runs on interior parameters; rustfmt.

Co-Authored-By: Claude Code <noreply@anthropic.com>
… a span it empties

Co-Authored-By: Claude Code <noreply@anthropic.com>
A degree near usize::MAX (piecewise_c0_rejects_unrepresentable_endpoint_
multiplicity) overflowed j + p + 1; the size check now comes first and
is checked. The test's weight 1/sqrt(2) is the constant.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…rops a point

drop_empty_basis compares the whole window u_j..u_(j+p+1). New tests: runs
longer than degree + 1 at the start and inside (the curve is the same on
both sides of each run's knot), and a copy that drops a point reports
Uncertified, not Preserved. The constructors' docs say n can shrink.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…emptied span; the kernel's fix-up stays as ported (solidcore#3387)

Dropping the points inside the kernel's knot fix-up moved the goldens of
nurbs.b_spline_curve_p3 (58 cases), intersect.surface_drop_lib_p2 (23),
intersect.surface_tracer (4) and blend.fillet_geom_p1 (2 cases no longer
built their face). The kernel's curves keep upstream's knots and points
again (b_spline_curve/p1.rs as on main).

The record needs a valid B-spline, so the export does it instead:
spline_record (an edge's spline) and record_trim (a use's pcurve) write
the kernel's curve without each control point P_j with
u_j = ... = u_(j+p+1), together with u_j (drop_empty_basis). The record's
curve is the kernel's on its domain. WR-23969 says so.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…rational trim

The test moves to the end of the file, apart from the record_of tests
other open PRs extend, and checks a rational trim mapped onto an
interval twice as long and scaled as a plane's. record_of's doc says a
NURBS is written without the points of an empty support.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@MarkusReichart MarkusReichart changed the title [WIP] solidcore: an imported body whose trim ends in a 1e-12 span saves to a record again (tangency-labs/solidcore#3387) solidcore: a body whose trim ends in a span shorter than the knot zero saves to a record again (tangency-labs/solidcore#3387) Nov 29, 2026
@MarkusReichart
MarkusReichart marked this pull request as ready for review November 29, 2026 09:03
@MarkusReichart
MarkusReichart requested a review from a team as a code owner November 29, 2026 09:03
@MarkusReichart
MarkusReichart requested review from bherbruck and removed request for a team November 29, 2026 09:03
@bherbruck bherbruck added approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) ready to merge reviewed, every ask addressed; merge once CI is green labels Nov 29, 2026
@tangency-repo-manager
tangency-repo-manager Bot merged commit 73d881c into tangency-labs:main Nov 29, 2026
157 checks passed
@MarkusReichart
MarkusReichart deleted the fix/sc3387-record-knot-multiplicity branch November 29, 2026 11:26
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.

to_record fails with "knot multiplicity" on a body assembled from NIST nist_ftc_09_asme1_rd.stp #5384

2 participants