Skip to content

Kernel strategies: pinch/Y fillet junctions and curved graph patches - #99

Merged
NiJingzhe merged 14 commits into
devfrom
feat/y-patch-graph-patch
Nov 23, 2026
Merged

NiJingzhe merged 14 commits into
devfrom
feat/y-patch-graph-patch

Conversation

@NiJingzhe

@NiJingzhe NiJingzhe commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Kernel strategies for two geometric situations OCCT does not handle, built into the patched OCCT (patch set
fillet-robustness-4) and exposed to the SDK as explicit named booleans.

  • Concave/convex tangent fillet junctions (a post flush with a plate side, a wall a few degrees off it).
    Before this branch, fillet_rsolid failed on them ("OCC build did not complete") for every radius below about 8 mm.
    • Plain fillet_rsolid(...): the kernel runs the standard algorithm first. At such a junction, if the standard
      result fails, is invalid or self-intersects, it uses the pinch corner instead (both bands taper to a point at
      the junction vertex, like Plasticity with Y-Blend off), then the Y transition if the pinch fails.
      Valid standard results, and fillets without such a junction, are unchanged.
    • strategy_auto_y_patch=True: the Y transition first (two G1 ribbons; P* matches Plasticity Y-on to 1e-4 mm).
  • Graph patch: make_surface_patch_rface(..., strategy_graph_patch=True) fills one ordered C0/G1/G2 loop with a
    degree-8 graph patch continuing curved supports. A tube window filled G1 lies 0.00023 mm from the cylinder;
    plate filling of the same loop is 0.39 mm off.
  • simplecadapi._cpp._kernel_capabilities(); on a kernel without the patch set the flags raise ValueError.
  • tools/render/zebra.py: zebra renderings for continuity checks (img/y-patch/).
  • src/cpp/patches/occt/GUIDE.md: how to modify OCCT systematically (layout, strategy branches, SDK exposure,
    workflow, pitfalls). Decision record: design-docs/y-patch-and-graph-patch.md (D1–D10).

Evidence

  • Kernel case family (src/cpp/patches/occt/tests, cases.exe): 48 cases, failures 0. The cases cover:

    • flush post, r = 1–12, one or both sides, with the cylinder seam anywhere including on the root;
    • unequal radii; plate sides 2–10° off; walls 5–15° off;
    • a curved side and an inclined top;
    • one refused fixture whose junction region is longer than the edge.

    Every successful case is valid, has no self-interference (BOPAlgo_CheckerSI level 5), and passes strict history
    checks through MakeFillet. The graph patch probe (graphpatch.cxx) passes all 25 checks.

  • Ground truth: Plasticity 26.2.7 driven by desktop automation on 11 cases, Y-Blend off and on.

    • P* is identical in every Y-on result.
    • Pinch vs Plasticity Y-off, flush r5: 0.078 / 0.262 mm RMS / max.
  • SDK built against the patched prefix (MinGW 15.2, static): ctest 14/14, pytest src/cpp/tests/python and
    pytest test tests: 548 and 2768 passed.

Known limits

  • Pinch crease: at the section where the taper starts a pinch band tangent to the shared face, with circular
    sections, cannot be G1 to both constant-radius bands. Like Plasticity, the convex band stays G1 and the concave one
    keeps a crease (about 17° at r = 5); where that does not fit or would exceed 30°, the crease is shared (33 junctions
    convex-G1, 10 shared in the case family, largest crease 23.6°).
  • Y seam: G1 only. Near tangency the zebra stripes kink at the seam.
  • Compilers: only MinGW was compiled locally. This CI is the first GCC/Linux build of the overlay; MSVC and macOS
    run in the release workflow.

🤖 Generated with Claude Code

NiJingzhe and others added 14 commits November 23, 2026 05:46
…elog pictures

DECISION
Add tools/render/zebra.py: side-by-side zebra (reflection-line) and shaded renderings of BREP
files, plus the first pictures of the Y transition in img/y-patch/.

PROBLEM
The owner asked to judge continuity with zebra renderings and to keep the pictures for the
changelog and promotion. The SDK renderer has no zebra mode.

WHY THIS FIX
A standalone numpy rasteriser over the SDK's own BREP import and mesher: per-face vertex normals
from the surface, never averaged across B-rep faces (real G0/G1 breaks stay visible), per-pixel
interpolated normals, 2x2 supersampling, B-rep edges depth-tested, one camera for all panels.

REJECTED
Adding a zebra mode to the C++ renderer now: larger change, not needed for the evidence.

EVIDENCE
Rendered the Y cases; stripes are continuous across tangent seams and break at sharp edges in
the inputs (img/y-patch/*.png, checked by eye).

NOT DONE
Light tubes are fixed to the camera, so flat faces show one or two bands; ~10 s per panel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tYPatch

DECISION
Add patch 0004 (patch set fillet-robustness-4) and the BRepFilletAPI_YPatch overlay. A concave
and a convex constant-radius fillet meeting tangentially or nearly so between (nearly) tangent
supports get a Y transition: both bands stop where they touch the shared face (P*), two G1
ribbons close the junction. BRepFilletAPI_MakeFillet::SetYPatch(true) is the only switch; off,
Build() is the standard algorithm unchanged. NbYPatches()/YPatchJunction() report what was done.

PROBLEM
The owner asked for the Y fillet as a general kernel capability with a real strategy branch,
covering the family of tangent / near-tangent junctions of one convex and one concave fillet.
Reproduced on the patched kernel (0001-0003): the post flush with a plate side, concave root +
convex top edge, r = 5: MakeFillet IsDone() == false; the convex edge alone: invalid, 2
self-interferences. BRepFilletAPI_TangentY (PR #98) cannot help a real part: it accepts only the
canonical plate/post at the origin and rebuilds the whole solid from hard-coded faces.

WHY THIS FIX
- Detection is OCCT's own convexity (ChFi3d::DefineConnectType) at a vertex: concave Ein = T^A,
  convex Eout = T^B, A and B adjacent at V with normals within 20 degrees.
- The standard algorithm does everything it can: P* from two rolling-ball solves; V's wedge is
  cut out of T, A, B (BRepAlgoAPI_Splitter), the open shell is filleted by the standard
  algorithm (bands end at their sections through P*, far ends and all other edges are standard);
  the kernel adds only two ribbons (clamped Hermite tensor product, the construction TangentY
  validated, with cubic sections blended into the exact band section) and sews.
- Periodic supports whose parametric seam lies on a selected chain are re-seated first (same
  surface, origin turned into the largest gap): with the seam on the post's root - what
  make_cylinder_rsolid gives - the standard algorithm built a band twice.
- Gates: BRepCheck_Analyzer, BOPAlgo_CheckerSI level 5, closed sewing; any failure returns the
  standard algorithm. History (Generated/Modified/IsDeleted) answers from the Y path, so callers
  tracking faces need no special case.

REJECTED
- Dispatch in Python or in the SDK's C++ operators (owner: speed; kernel migration).
- Keeping TangentY as the entry (canonical sample only).
- A BREP text round trip of the open shell (made a marginal case pass by perturbing digits);
  splitting a periodic face without moving its origin (still fails).

EVIDENCE
src/cpp/patches/occt/tests (cases.exe, 48 cases): post flush r = 1/2.5/5/8/12, one or both sides,
moved; seam at 0..315 deg, seam on the root (the SDK default) at r = 1..12; unequal radii 3/7, 7/3; plate side 2/5/10 deg out,
2/5 deg in; planar wall 5/10/15 deg; curved side; inclined top; one too-short wedge. 47 ok
(valid, SI(5) = 0, strict history through MakeFillet + SetYPatch), the short wedge refused as
required. P* matches 2*sqrt(R r) to 1e-4 mm. Seam G1 <= 0.004 deg (0.059 deg with unequal radii),
ribbon/band/support <= 0.011 deg. 175-560 ms per solid. Kernel built with
src/cpp/tools/build_occt.py into C:/OCCT-modified/static-ypatch (MinGW 15.2, static).

NOT DONE / NOT KNOWN
- Variable radius never takes the Y path. Near tangency the ribbons inherit the support kink at
  V itself. Where the standard algorithm already returns a valid solid (several near-tangent
  cases), the Y corner replaces it; those standard shapes were not compared visually.
- Only MinGW was compiled; CI builds this patch set on Linux; MSVC not tried.
- Decision record: design-docs/y-patch-and-graph-patch.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tegy_graph_patch)

DECISION
fillet_rsolid(..., strategy_auto_y_patch=False) turns on the kernel's Y transition
(MakeFillet::SetYPatch); make_surface_patch_rface(..., strategy_graph_patch=False) fills with
BRepOffsetAPI_GraphPatch through the SurfaceFitter (FillingProblem::graph_patch). Both default
off, are recorded in the operation graph only when on (records of the standard paths are
unchanged) and are replayed by the serializer and the C++ executor.
simplecadapi._cpp._kernel_capabilities() tells which strategies the linked OCCT carries.

PROBLEM
The owner wants the new kernel capabilities usable from the SDK with explicit named booleans
(not an enum), without the SDK judging geometry itself: the strategy branch belongs to the
kernel so that the SDK stays portable to another kernel.

WHY THIS FIX
- The SDK only forwards the switch; tracking and tags work unchanged because the patched
  MakeFillet answers Generated/Modified/IsDeleted from the Y path (ribbons carry fillet.patch).
- The SDK still compiles against any OCCT: __has_include finds the strategies; a kernel without
  them raises ValueError naming the patch set (never a silent fallback when the caller asked).
- The graph patch is a fill method of the existing operator (same question: fill a constrained
  loop), not a new operator. Its preconditions are checked before the kernel call: 3-64 ordered
  boundaries, a support on each, each edge an edge of its support, no points/holes/settings.

REJECTED
- An enum parameter (owner preferred explicit named booleans).
- Falling back to plate filling when strategy_graph_patch is refused (hides the refusal).

EVIDENCE
Built against C:/OCCT-modified/static-ypatch (MinGW 15.2). ctest 14/14. test/test_kernel_strategies.py:
Y on the SDK's own post/plate (seam on the root) at r = 2.5/5/8, off == standard, record + replay;
graph patch C0 on a wall loop, G1/G2 on a hole in a plane (lid = the plane, area exact), refusals.
Full suites: see the PR.

NOT DONE / NOT KNOWN
- Release and CI builds compile OCCT from this patch set (build_occt.py, cache keyed on
  src/cpp/patches/occt/**), so wheels will carry both strategies on every platform. The overlay
  was compiled here with MinGW only; the MSVC (Windows wheels) and Clang (macOS) compiles are
  untried until CI runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…patch

DECISION
Add the decision record design-docs/y-patch-and-graph-patch.md (findings, decisions D1-D7, case
family table, what is not done), record both strategies in the Unreleased changelog (with the
zebra picture) and regenerate the
API reference pages of fillet_rsolid and make_surface_patch_rface from the native signatures and
docstrings.

EVIDENCE
tools/auto_docs_gen.py; test_auto_docs_gen, test_skill_lint, test_skill_build: 67 passed.

NOT DONE
docs/updates/<version>.md notes are written at release time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ndard result fails

DECISION
Without SetYPatch, BRepFilletAPI_MakeFillet::Build runs the standard algorithm as before; only
when BRepFilletAPI_YPatch::Detect finds a mixed-convexity tangent junction among the contours
and the standard result is not done, throws, is invalid (BRepCheck) or self-interferes
(BOPAlgo_CheckerSI level 5), the Y transition and its history replace it. YPatchFallback()
tells a fallback from a requested Y. SetYPatch(true) keeps meaning "Y first".

PROBLEM
The owner: the post/wall tangent case must have a working fillet by itself, not fail.
A plain fillet of the post flush with a plate side failed ("OCC build did not complete") for
every radius below about 8 mm, including the SDK's default cylinder.

WHY THIS FIX
- The extra checks run only when a junction is detected: ordinary fillets pay one topological
  scan and are otherwise unchanged.
- A valid standard result is kept (e.g. a wall 10 deg off the plate side, where the standard
  algorithm merges both bands into one tapering band with smooth zebra stripes): the Y
  transition is G1 only, so replacing a good standard shape would not be an improvement.

REJECTED
- Y first by default: would change results that are valid today.
- A non-Y "pinch" corner (both bands closing in one point, like Plasticity with Y-Blend off)
  as the default: built as research code behind BRepFilletAPI_YPatch::Perform(..., thePinch),
  valid on near-tangent cases (side 2-10 deg, wedge 5-15 deg) but self-intersecting on exact
  tangency (section radius ~ x^2/4R folds the Hermite fit near V). Not wired in; off.

EVIDENCE
src/cpp/patches/occt/tests cases.exe, 48 cases, failures 0, with a new plain-MakeFillet column:
every case whose standard result fails or is invalid (flush r1/2.5/5 incl. seam on the root and
the SDK fixture, both sides, moved, wedge 5 deg, curved side, inclined top, seam at 90 deg)
now succeeds through the fallback with strict history; every case with a valid standard result
keeps it. Patch 0004 regenerated against pristine sources; occt_patches.apply verifies hashes.

NOT DONE
Pinch for exact tangency (needs a different parametrisation near V).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DECISION
BRepOffsetAPI_GraphPatch fills loops on curved supports: the interior follows each support's
own surface blended by distance to its edges; when the exact boundary solve cannot meet the
rows, boundary and support are fitted together (positions 10x, support 0.1); trims fall back
to a dense B-spline when a degree-8 Bezier cannot follow the edge; acceptance is measured on
the built face (33 points per edge: gap <= 1e-3 mm, normal angle <= 1e-3 rad for G1/G2,
cross-curvature within 5 % for G2) and the face's tolerances are set to the measured gap.

PROBLEM
A window cut in a tube (4 ordered edges, G1 to the cylinder) was refused; plate filling of
the same loop is 0.39 mm off the cylinder. Root cause: solve() demanded every boundary row
within 1e-5, which a degree-8 Bezier graph cannot meet on a cylinder (residual 4.6e-3).
Relaxing that exposed interiors shaped by fairing alone (0.21 mm off on the window, 3.1 mm on
a cylinder triangle) and refused trims of edges cut from B-spline surfaces.

WHY THIS FIX
Continuing the supports is what G1/G2 filling of a hole in one smooth surface should produce;
measuring acceptance on the built face checks what the caller gets. Planar loops keep the
exact path (positions to 1e-13 mm).

REJECTED
Other fairing energies or a higher degree alone: deviations stayed around 1e-2 mm.

EVIDENCE
tests/graphpatch.cxx (25 checks, exit 0): cylinder window C0/G1/G2 deviation 1.5e-4 / 2.3e-4 /
6.3e-4 mm; cylinder triangle, sphere window, sphere cap across the seam, B-spline sheet 3/5/6
sides, plane holes, open box, hexagonal prism; edges out of order still refused.
The tests CMake project also gains the sidetail tool and YPATCH_MAKEFILLET (dev build of the
patched MakeFillet) used by the fallback commit.

NOT DONE
Loops that do not project one-to-one onto a plane remain out of scope (documented in the header).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DECISION
fillet_rsolid's docstring and FilletOptions describe the kernel's default fallback; a test pins
that a plain fillet of the flush-post junction succeeds and equals the flagged result.
make_surface_patch_rface's docs drop "model precision" for curved loops (true only where a
degree-8 graph meets the boundary) and gain tests: a tube window C0/G1/G2 within 1e-3 mm of the
cylinder, and far closer than plate filling. The refusal message names the contract. API docs
regenerated; changelog updated.

EVIDENCE
Built against C:/OCCT-modified/static-ypatch; see the PR for the full-suite numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DECISION
Add src/cpp/patches/occt/GUIDE.md and bring the patch-set README up to fillet-robustness-4
(patch 0004, overlay classes, the tests project). The guide fixes how kernel work is done:
where patches, overlay classes, tests and tools live; the strategy-branch pattern (detect,
construct with the standard algorithm doing what it can, gate, history; explicit switch plus a
default fallback that fires only on a detected situation whose standard result fails); SDK
exposure (__has_include, explicit named booleans recorded only when true, replay, capability
query, docs); the dev/rebuild/test/commit workflow; and the pitfalls met on this branch.

PROBLEM
The owner asked for a document that explains how to modify OCCT systematically: where files
go and how strategy branches are done, so the next change does not rediscover the procedure.

NOT DONE
The guide reflects MinGW static builds on Windows; MSVC/macOS specifics will be added when CI
exposes them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DECISION
At a detected concave/convex tangent junction whose standard result fails, is invalid or
self-intersects, a plain BRepFilletAPI_MakeFillet now closes the junction with the pinch
corner: both bands taper along one shared curve on the common face to a single point at the
junction vertex, no ribbons. If the pinch fails its gates, the Y transition is tried.
SetYPatch(true) still means Y first.

PROBLEM
The owner: a qualified geometry engine must make the non-Y corner work, exact tangency included
(Plasticity with Y-Blend off does: 10 faces, bands tapering to V). The first attempt
self-intersected on exact tangency.

WHY THIS FIX
The fold came from fitting sampled positions with the ribbons' tensor Hermite fit while the
section radius collapses like x^2/4R. Each pinch band is now an exact variable-radius
rolling-ball surface: exact circular sections (rational quadratic, weight cos(theta/2)), only
1D data interpolated along the rail, a degenerated edge at V. The shared curve on T is solved
from radius laws h, g ~ s^2 whose sum fills the cusp width, so it stays inside the cusp.
Non-analytic supports (inclined top) get end sections refitted to the bands OCCT actually built;
remaining short edges below the sewing tolerance are merged with their history mapped.

REJECTED
- 2D position fitting of the pinch bands (folds near V).
- Making the crease at P*'s section vanish: a pinch band tangent to T along the shared curve
  with circular sections cannot be G1 to both constant-radius bands, whose T-contacts cross at
  P* (~35 deg at r = 5). Default pinchDir = 1 balances it (7.5 / 8.0 deg at flush r5);
  pinchDir = 0 makes the convex side G1 (17.3 deg on the other), as Plasticity's face layout
  suggests. Removing the crease needs dropping T-tangency or circular sections: owner's call.

EVIDENCE
cases.exe (48 cases, failures 0, 94 strict history checks): pinch succeeds on all 47
non-refused cases (valid, SI(5) = 0); plain MakeFillet rescues all 21 cases whose standard
result fails, none needing Y; valid standard results are kept. Against Plasticity Y-off
(its exact sample points to our B-rep): flush r5 0.078 / 0.262 mm RMS / max, r1 0.018 / 0.050,
wedge 10 deg 0.013 / 0.051; about a third of the distance to Plasticity Y-on.

NOT DONE
We have 13 faces where Plasticity has 10 (two filler faces and one section split).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DECISION
fillet_rsolid's docstring, FilletOptions, the changelog, the guide and the decision record
(D10) describe the default order standard -> pinch -> Y; the SDK test now pins that a plain
fillet of the flush post junction succeeds with the pinch corner and differs from the flagged
Y result only near the junction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DECISION
Rewrite src/cpp/patches/occt/GUIDE.md in English and add the pinch lessons (exact construction
of degenerate surfaces) and the English-only rule to its pitfalls.

PROBLEM
test/test_library_is_english.py rejects Chinese text under src/; the guide was written in
Chinese next to the patch set.

REJECTED
Moving the guide to design-docs/: it belongs next to the files it describes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…law as fallback

DECISION
The pinch tries the radius law that keeps the convex band G1 at P*'s section first (the crease
goes to the concave side, about 17 deg at flush r5, as Plasticity's Y-off face layout shows);
where that law does not fit the cusp (r = 1 on a flush post, the curved side) or leaves a crease
above 30 deg, the balanced law; then the Y transition as before.

PROBLEM
The owner chose Plasticity's layout over the balanced default. Applied alone it failed on 4
cases (r = 1 single/both sides/seam on the root, curved side) and gave a 90 deg crease on the
inclined top (valid solid, unacceptable shape).

WHY THIS FIX
A fixed order of laws with a crease gate keeps the requested shape wherever it is geometrically
sound and the pinch everywhere else, instead of losing the pinch to the Y on those cases.

EVIDENCE
cases.exe, 48 cases, failures 0: 33 junctions convex-G1, 10 balanced, largest crease 23.6 deg;
all 15 standard failures in the family take the pinch through plain MakeFillet. ctest 14/14.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e side)

DECISION
fillet_rsolid's docstring, the changelog and the decision record (D11) describe the pinch
layout and the balanced fallback; API page regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PROBLEM
CI (Python 3.12, "Check the type stubs are current") failed on PR #99: the committed
_native/__init__.pyi lacked the new _kernel_capabilities binding.

WHY THIS FIX
The CI diff was exactly this one hunk; added in pybind11-stubgen's format at its position
(pybind11-stubgen is not installed on this machine; CI regenerates and compares).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@NiJingzhe
NiJingzhe merged commit 0211896 into dev Nov 23, 2026
11 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.

1 participant