Skip to content

Flat arrays: a Ball patch goes through as itself, its sphere kept (the shell of a fully rounded box builds again) - #121

Merged
jyviko merged 4 commits into
replay/1.0.1from
fix102-flat-ball-patch
Nov 2, 2026
Merged

jyviko merged 4 commits into
replay/1.0.1from
fix102-flat-ball-patch

Conversation

@jyviko

@jyviko jyviko commented Nov 2, 2026

Copy link
Copy Markdown

Closes tangency-labs/solidcore#102 (its flat part; USD is a follow-up in tangency-labs/solidcraft#13826).

The defect. SMLib's Ball corner is an SmBallPatch, a rational patch that carries its sphere (centre and radius) as its definition, so its offset is exact. The C API's flat arrays wrote it as plain NURBS and read it back as an SmBSplineSurface, which lost the sphere. A box rounded all round and then shelled through the flat arrays therefore failed with status 1034: the corners no longer collapsed exactly under the offset. SolidCraft keeps bodies in the flat arrays between commands, so its develop went red on exactly this case.

The fix.

  • A new flat surface kind, SMLIB_FLAT_SURFACE_BALL_PATCH = 6. It carries its NURBS block as a NURBS face does, plus a per-face definition record:
    • SMLIB_FLAT_FACE_DEFINITION_REAL_COUNT = 36: 4 for a ball patch;
    • SMLIB_FLAT_FACE_DEFINITION_REALS = 166: cx, cy, cz, R.
  • On import, a face becomes an SmBallPatch only after IsOnSphere certifies its net. That is an exact Bernstein identity per Bézier piece, to 1e-12 of ((R + |C|)·maxW)². A net that fails is refused (1007).
  • A reader that doesn't know kind 6 can read it as NURBS, but it must write ids 36 and 166 back unchanged.

Tests (failing first):

  • The shelled box, in process and through a flat round trip: 8 ball patches, 8 of 8 definitions, every corner on its sphere, and the shell built (status 0, 15305.435784173).
  • A net cut by inserted knots still certifies.
  • A sphere 1e-9 larger is refused.

Docs: the CHANGELOG, capi/README.md (the flat definitions), and docs/generic-blend.md §6 (status).

Gate (aarch64 box, against a fresh dda881f reference): ctest 22/22, default 0, all 8 known-failing lists exit 0. The only moved lines are the new cases' own.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ

jyviko and others added 4 commits November 2, 2026 03:06
…at the front, in process and through the flat arrays (failing)

The shell of the rounded box held in process builds (the rounds and
balls collapse, the cavity the sharp box 36 x 28 x 56): a regression
guard in the shell block. Through the flat arrays first, as SolidCraft
keeps a body between commands, the corner faces come back without
their spheres and the shell fails with status 1034: listed as a Ball
case known to fail, with its reason.

Refs #102

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT
…d, its sphere as its definition, and refuse one its net is not on (failing)

smlib.h gains the kind SMLIB_FLAT_SURFACE_BALL_PATCH (6) and the arrays
a surface's definition rides in beside its net:
FACE_DEFINITION_REAL_COUNT (int64, id 36, per face whose kind has one)
and FACE_DEFINITION_REALS (double, id 166; a ball patch's center and
radius). The round-trip case now checks them: eight ball patches, each
with its corner's center and radius 1.5, and an import whose radius is
1e-9 off its net refused. Export writes none yet: still listed as
failing. flat_roundtrip's id ranges take the two new ids (int64 1..36,
double 101..166; 37 and 167 now the first that name no array).

Refs #102

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT
… kept, and the shell of a box rounded all round builds again

Export writes an SmBallPatch face as SMLIB_FLAT_SURFACE_BALL_PATCH: its
net as a NURBS face's block (range and trims in its parameters), its
sphere's center and radius as its definition. Import takes it back as
that patch only when SmBallPatch::IsOnSphere certifies the net: over
each Bezier piece (interior knots raised to the degree) every
Bernstein coefficient of |X - C W|^2 - R^2 W^2 is zero to 1e-12 of
((R + |C|) max W)^2, rounding at the part's scale, decided on the net,
not at sample points; otherwise the B-rep is refused (1007).

Before, the patch came back a bare SmBSplineSurface: its offset 2 in
did not collapse (SmBSplineSurface has no OffsetCollapses), the rounds'
beside it did, and the shell left 23 edges unbridged (status 1034).
Before the Ball the corners were SmSphere, which the arrays keep, and
the shell built. The round-trip case now passes: eight ball patches
with their corners' spheres, a radius 1e-9 off refused, a net cut by
inserted knots still certified and not on a sphere 1e-9 larger, and
the shell's volume 15305.435784173 against 15305.435766881 (1.1e-9).

Refs #102

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT
…ADME); the blend page's status as SMLib construction ends

- CHANGELOG.md: an Unreleased section, with the flat arrays' new surface kind 6 and definition
  arrays 36 and 166, the import certificate, and what a reader that doesn't know kind 6 must do.
- capi/README.md: the flat arrays' definitions, and an entry under the changes from upstream.
- docs/generic-blend.md section 6: step 4's merged pieces (#79, #104, #110, #113) and those
  landing (#81, #86, #82); step 7 with #102; the open-work table says where each item continues
  (SMLib, or its solidcore issue) now that SMLib construction has ended (owner, 2026-11-02).

Refs #102

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT
@jyviko
jyviko force-pushed the fix102-flat-ball-patch branch from 4e8e471 to 9bb0459 Compare November 2, 2026 08:06
@jyviko
jyviko merged commit d5995c3 into replay/1.0.1 Nov 2, 2026
5 checks passed
@jyviko
jyviko deleted the fix102-flat-ball-patch branch November 2, 2026 15:06
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.

1 participant