Skip to content

Fillet: classify collapsed torus offsets in ball_zone_state so equal-radius corner balls build - #26026

Open
nullifyr wants to merge 3 commits into
tangency-labs:mainfrom
nullifyr:fix/fillet-collapsed-torus-ball-zone
Open

nullifyr wants to merge 3 commits into
tangency-labs:mainfrom
nullifyr:fix/fillet-collapsed-torus-ball-zone

Conversation

@nullifyr

@nullifyr nullifyr commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #17379
Changes a default: no

What failed

On a 40 mm sphere cut flat at z = 10 and x = -17.08, applying an R1 fillet to the side flat's circular rim (Fillet1) creates an R1 torus whose end curves run tangentially into the short straight edge (x = -17.08, z = 10) and the z = 10 sphere rim. Applying a second R1 fillet to that z = 10 closed tangent chain failed on main with unsized NoRoom:

not supported yet: the fillet is larger than the faces beside its edges allow (tangent propagation blended the picked edges' tangent chain with them; with it off, tangent_chain: false, only the picked edges are blended)

(Meanwhile R0.9 on the same chain built cleanly in 577 ms.)

Why

At R1, the earlier R1 torus's inward offset collapses onto its tube's centre circle (QuadricKind::Circle).

  • offset_collapses_by_definition (solidcore-blend/src/blend/fillet_exact.rs:978) already recognised QuadricKind::Line | Point | Circle, so ball_regular.rs flagged the torus end curves as BallCheck::Collapsed.
  • classify_ball_on_collapsed_offset and calc_ball_triangle_fillet_geom (#2403) already support QuadricKind::Circle to build the exact corner ball triangle.
  • However, ball_zone_state (fillet_exact.rs:680) and fixed_centre (fillet_exact.rs:794) only handled QuadricKind::Line and QuadricKind::Point, omitting QuadricKind::Circle. As a result, ball_zone_state returned CollapsedBallZone::Unclassified, and refuse_irregular_balls refused the edge with unsized NoRoom before #2403 could build the corner balls.

The fix

  • Expose curve_crosses_quadric from solidcore_kernel::blend::fillet_exact::class (single implementation, no duplicate solver).
  • Extend ball_zone_state in solidcore-blend/src/blend/fillet_exact.rs to handle QuadricKind::Circle:
    • use face.tube (the torus's tube radius, not major radius) as face_radius;
    • check circle-vs-end-plane closure at open ends (nearest crossing to vertex v);
    • return CollapsedBallZone::ClosedPointBall when both ends close onto a fixed centre.
  • Extend fixed_centre to handle QuadricKind::Circle (exact closed-form circle-plane crossing, delegating non-planar quadrics to curve_crosses_quadric).
  • Add regression tests:
    • fixed_centre_handles_collapsed_torus_circle in solidcore-blend/src/blend/fillet_exact.rs
    • sphere_cut_flats_chain_over_torus_end_curves_builds_corner_balls in solidcore/crates/solidcore/tests/issue_2403_chain_over_end_curve.rs

Expected vs measured

  • Expected (all three original edges rounded R1 in one fillet): closed manifold solid, 10 faces (2 planes, R20 sphere + 2 exact R1 corner ball triangles at C = (-16.08, ±sqrt(19² − 16.08² − 9²), 9), 1 cylinder, 4 tori/revolved faces), symmetric (center_of_mass.y = 0).
  • Measured (sequential #17379 repro, --validation each_feature):
    • volume = 27756.897289 mm³, matches all-at-once within < 1e-8 relative;
    • faces = 10 (plane: 2, sphere: 3, cylinder: 1, other: 4), closed = true, center_of_mass.y = 1.36e-15;
    • both corner balls lie on their analytical unit spheres within <= 1e-9 (1.85e-13 measured on -y), contact vertices within 2e-5 (twice the 40 mm body's ~1e-5 curve tolerance), G1 normal agreement 2.41e-5 rad (<= 1e-4), check_brep(Level2) 0 failures.

Tests run

  • cargo fmt --manifest-path solidcore/Cargo.toml --all --check: pass
  • cargo clippy --manifest-path solidcore/Cargo.toml -p solidcore-kernel -p solidcore-blend -p solidcore --tests -- -D warnings: pass
  • cargo check --manifest-path solidcore/Cargo.toml -p solidcore --target wasm32-unknown-unknown: pass
  • cargo test --manifest-path solidcore/Cargo.toml --profile goldens -p solidcore-blend --lib -- fillet_exact: 20 passed, 0 failed
  • cargo test --manifest-path solidcore/Cargo.toml --profile goldens -p solidcore --test blend -- issue_2403_chain_over_end_curve: 14 passed, 0 failed
  • cargo test --manifest-path solidcore/Cargo.toml --profile goldens -p solidcore --test blend -- issue_2364_round_ending_in_an_earlier_round: 2 passed, 0 failed
  • cargo test --profile ci -p solidcraft-kernel --lib -- blend::corner_tests::rounds_meeting: 2 passed, 0 failed
  • python3 solidcore/scripts/ci/check_panic_sites.py: pass
  • solidcraft-cli run 17379.json --results --validation each_feature: pass (0 errors, 0 warnings)

Before and after

Rendered headlessly with solidcraft-cli snapshot at 1280×720 from the same public example script.

Before (main at f5e1bfc58c): the model failed with: error: step 5 (solid.fillet): not supported yet: the fillet is larger than the faces beside its edges allow (tangent propagation blended the picked edges' tangent chain with them; with it off, tangent_chain: false, only the picked edges are blended)

After: this branch at 8eb6429f0f

After (this branch at 8eb6429f0f).

Summary by CodeRabbit

  • Bug Fixes
    • Improved exact fillet handling in cases where offset surfaces collapse into circles, including intersections near end boundaries.
    • Improved chained fillets around torus ends, producing valid, smooth corner geometry in more cases.
  • Tests
    • Added coverage for circle intersections and chained fillet results, including checks for geometric accuracy and model validity.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The fillet solver now handles torus offsets that collapse to circles. The changes include circle-intersection logic and tests for circle crossings and sequential fillets on a cut sphere.

Changes: Collapsed torus offsets

Layer / File(s) Summary
Recognize collapsed torus offsets
solidcore/crates/solidcore-blend/src/blend/fillet_exact.rs
Collapsed-offset classification includes circles. Torus faces use their tube radius when no focal offset supplies the face radius.
Resolve circle intersections
solidcore/crates/solidcore-blend/src/blend/fillet_exact.rs, solidcore/crates/solidcore-kernel/src/blend/fillet_exact/class.rs
fixed_centre now accepts a tolerance and near point. It handles circle-plane crossings and uses curve_crosses_quadric for other quadrics. End-closure checks handle circle offsets. Tests cover valid and rejected intersections.
Validate sequential fillets
solidcore/crates/solidcore/tests/issue_2403_chain_over_end_curve.rs
A regression test compares sequential fillets with an all-at-once result. It checks manifoldness, B-rep validity, volume, corner spheres, contact points, and G1 continuity.

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

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 8eb64

This change lets the fillet solver recognise torus offsets that collapse to a circle, so the equal-radius corner-ball case from the reported issue can be built instead of being refused. The reported regression and targeted tests pass, and no merge-blocking risk was found. A rare edge case in which an unusually symmetric corner is still refused remains possible but is unconfirmed.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: collapsed torus offsets (circle quadric) are now classified in ball_zone_state so equal-radius corner balls build. The raw summary confirms ball_zone_state and fixed_c…
Linked Issues check Passed [#17379] requires that a 1 mm fillet on the short cut edge of a 40 mm sphere succeeds after longer edges are filleted. The reported failure was unsized NoRoom from refuse_irregular_balls. The cause wa…
Out of Scope Changes check Passed All changes relate to the #17379 corner-ball failure. The fillet_exact.rs changes add Circle handling to ball_zone_state and fixed_centre, add a tolerance and near-point parameter to fixed_centre, and…
Existing Defaults Unchanged Passed Details from the previous assessment are unavailable.
Description check Passed The description follows the repository template closely. It has a Change section that explains the failure and the cause in technical terms, plus the required "Changes a default: no" line. It has a Va…
Full details: Title check

Explanation

The title names the main change: collapsed torus offsets (circle quadric) are now classified in ball_zone_state so equal-radius corner balls build. The raw summary confirms ball_zone_state and fixed_centre gained Circle handling, and the regression tests match. The title is specific, although it uses internal names and is long (94 characters).

Full details: Linked Issues check

Explanation

[#17379] requires that a 1 mm fillet on the short cut edge of a 40 mm sphere succeeds after longer edges are filleted. The reported failure was unsized NoRoom from refuse_irregular_balls. The cause was that ball_zone_state and fixed_centre in solidcore-blend/src/blend/fillet_exact.rs did not handle QuadricKind::Circle. The collapsed R1 torus end curves therefore returned CollapsedBallZone::Unclassified. The PR adds Circle handling to both functions, uses the tube radius as face_radius, checks circle-vs-end-plane closure, and returns ClosedPointBall when both ends close. This lets the existing circle corner-ball logic (#2403) run. The PR description reports that the sequential repro with the issue's R1 settings now yields a closed 10-face solid with valid corner balls and check_brep(Level2) at 0 failures. The added regression test sphere_cut_flats_chain_over_torus_end_curves_builds_corner_balls checks the same configuration. The issue reproduction steps were not provided, and the run results are author-reported; I did not execute them. The code path matches the issue's failure mode, so the evidence supports compliance.

Full details: Out of Scope Changes check

Explanation

All changes relate to the #17379 corner-ball failure. The fillet_exact.rs changes add Circle handling to ball_zone_state and fixed_centre, add a tolerance and near-point parameter to fixed_centre, and add tests for circle-plane intersection cases. The class.rs change only raises curve_crosses_quadric from private to pub, so fixed_centre can reuse the existing solver without a duplicate. The issue_2403_chain_over_end_curve.rs change adds one regression test for this scenario. No changed hunk addresses unrelated behaviour. The PR description also lists existing regression tests (issue_2364 and rounds_meeting) that exercise nearby blend paths, which supports that the change does not alter unrelated behaviour.

Full details: Description check

Explanation

The description follows the repository template closely. It has a Change section that explains the failure and the cause in technical terms, plus the required "Changes a default: no" line. It has a Validation section with commands, expected and measured values, and results. It also includes a Before and after section with images. The template has no separate Test change line, so the section is not needed here. Two gaps remain. The Change section does not explain the feature in plain words for someone new to the project. The Integration status section is missing, and the template asks for the upstream commit and PR status checked before handoff. These gaps are not critical, so the description is mostly 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 f5e1bfc and 8eb6429.

Files selected for processing: 3

  • solidcore/crates/solidcore-blend/src/blend/fillet_exact.rs
  • solidcore/crates/solidcore-kernel/src/blend/fillet_exact/class.rs
  • solidcore/crates/solidcore/tests/issue_2403_chain_over_end_curve.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.

nullifyr and others added 2 commits December 3, 2026 13:17
…-labs#17379)

When a constant-radius round runs along a tangent chain over an earlier
torus round's end curves of the same radius (such as tangency-labs#17379: a 40 mm
sphere cut flat at z = 10 and x = -17.08, R1 fillet on the side flat's
circular edge, then R1 fillet on the z = 10 tangent chain), the torus's
inward offset collapses onto its tube's centre circle (QuadricKind::Circle).

offset_collapses_by_definition already recognised QuadricKind::Circle and
flagged the edge BallCheck::Collapsed, and classify_ball_on_collapsed_offset
plus calc_ball_triangle_fillet_geom (tangency-labs#2403) already built the corner ball
triangle for QuadricKind::Circle. However, ball_zone_state and fixed_centre
in solidcore-blend/src/blend/fillet_exact.rs only handled QuadricKind::Line
and QuadricKind::Point, so ball_zone_state returned Unclassified and
refuse_irregular_balls rejected the edge with unsized NoRoom before tangency-labs#2403
could run.

Handle QuadricKind::Circle in ball_zone_state (using face.tube as the
collapsed torus radius and checking circle-vs-end-plane closure at open
ends) and in fixed_centre (closed-form circle-plane crossing, delegating
other quadrics to solidcore_kernel::blend::fillet_exact::class::curve_crosses_quadric).

Regression tests:
- fixed_centre_handles_collapsed_torus_circle in solidcore-blend fillet_exact
- sphere_cut_flats_chain_over_torus_end_curves_builds_corner_balls in
  solidcore tests/issue_2403_chain_over_end_curve.rs

Fixes tangency-labs#17379

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
nullifyr added a commit to nullifyr/solidcraft that referenced this pull request Dec 3, 2026
@nullifyr
nullifyr marked this pull request as ready for review December 3, 2026 21:44
@nullifyr
nullifyr requested a review from a team as a code owner December 3, 2026 21:44
@nullifyr
nullifyr requested review from jyviko and removed request for a team December 3, 2026 21:44
@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 Dec 3, 2026
tangency-repo-manager Bot added a commit that referenced this pull request Dec 3, 2026

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FILLET: operation failed

2 participants