Skip to content

[geom] Fix tessellated closure checks after initialization#22457

Merged
agheata merged 1 commit into
root-project:masterfrom
agheata:fix-tessellated-closeshape-check
Jun 3, 2026
Merged

[geom] Fix tessellated closure checks after initialization#22457
agheata merged 1 commit into
root-project:masterfrom
agheata:fix-tessellated-closeshape-check

Conversation

@agheata
Copy link
Copy Markdown
Member

@agheata agheata commented Jun 2, 2026

This Pull request:

Changes or fixes:

Fixes a regression in TGeoTessellated::CloseShape() where a tessellated shape finalized with CloseShape(false) could not later be checked with CloseShape(true).

This affects GDML-imported tessellated solids because TGDMLParse::Tessellated() finalizes them with CloseShape(false). Since the BVH navigation change added an early return for already-initialized shapes, a later explicit CloseShape(true) returned before running CheckClosure(), leaving fClosedBody == false.

The fix keeps the BVH/initialization fast path for repeated unchecked closes, but lets checked closes run facet and closure validation while reusing the existing BVH. This avoids rebuilding the BVH in the GDML reproducer path.

This follows the minimal direction suggested in the issue #22395 comments while avoiding the addition of more state flags or data members. Wouter's broader suggestion of lazy BVH construction on first navigation use was not taken in this PR because it would require a larger redesign of the cache ownership/state model, including const navigation methods, thread-safety of lazy cache construction, and streaming/readback behavior. This PR is intentionally scoped to the regression.

The patch also refreshes cached normals if CheckClosure(..., fixFlipped=true) flips facets, so navigation data remains consistent with the facet winding.

A regression test was added for the failing sequence:

  1. create a closed tetrahedron matching the GDML reproducer,
  2. call CloseShape(false),
  3. call CloseShape(true),
  4. verify that IsClosedBody() becomes true.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #22395

TGeoTessellated::CloseShape(false) initializes the bounding box, BVH and normals, then marks the shape closed for initialization purposes. Since the BVH navigation change added an unconditional fast return for already-initialized shapes, a later explicit CloseShape(true) could no longer run CheckClosure(). This left GDML-imported tessellated solids stuck with fClosedBody=false because TGDMLParse finalizes them with CloseShape(false).

Allow the fast path only for repeated unchecked closes. A checked close now reuses the existing initialization data but still runs facet and closure validation, so fClosedBody can be updated without rebuilding the BVH. Also refresh cached normals if CheckClosure fixes flipped facets.

Add a regression test for the unchecked-close followed by checked-close sequence using the closed tetrahedron from the issue reproducer.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Test Results

    22 files      22 suites   3d 10h 45m 26s ⏱️
 3 864 tests  3 863 ✅ 0 💤 1 ❌
77 142 runs  77 141 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit d443536.

@dpiparo dpiparo self-requested a review June 3, 2026 07:01
@agheata agheata merged commit ede4e83 into root-project:master Jun 3, 2026
51 of 53 checks passed
@agheata agheata deleted the fix-tessellated-closeshape-check branch June 3, 2026 07:05
@agheata
Copy link
Copy Markdown
Member Author

agheata commented Jun 3, 2026

/backport to 6.40

@root-project-bot
Copy link
Copy Markdown

Preparing to backport PR #22457 to branch 6.40 requested by agheata

@root-project-bot
Copy link
Copy Markdown

This PR has been backported to branch 6.40: #22465

dpiparo pushed a commit that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TGeoTessellated volumes read from GDML impossible to be closed (6.40.00 regression)

3 participants