Implementation of the TGeoTessellated navigation functionality #21095
Draft
BSali wants to merge 13 commits intoroot-project:masterfrom
Draft
Implementation of the TGeoTessellated navigation functionality #21095BSali wants to merge 13 commits intoroot-project:masterfrom
BSali wants to merge 13 commits intoroot-project:masterfrom
Conversation
added 6 commits
February 1, 2026 19:08
Implementation of TGeoTessellated navigation functionality using triangle-ray-intersection similar to GEANT4 G4TessellatedSolid. Due to low simulation speeds for meshes of high triangle count, additional partitioning structures such as an Octree and the BVH (using the bvh library included in ROOT) can be used to reduce required simulation time. Here, the most benefitial partitioning structure seems to be mesh dependent. However, the usage of the BVH functionality is potentially not optimal and may require more intense testing. First comparisons from the CBM collaboration indicate that this implementation approach (including the Octree) is more time consuming than the VecGeom implementation for tessellated shapes (DOI: 10.1051/epjconf/202533701268). All usage modes (without partitioning structure and with) have been regularly tested against TGeoBBox navigation results by simulations of boxes with geant3/4_vmc TVirtualMCApplications and it is being actively used in simulations. Add TGeoVector3 include to TGeoTypedefs.h Add Tessellated helper classes REQUIRES REVERT: changed top_down_sah_builder.h to only include ROOT/span.hxx Changed TGeoTessellated to TGeoArbN code Adjusted ROOT classes to Tessellated changes Add DOI to TGeoTessellated.cxx Fix up constness of TGeoTessellated::ComputeNormal Remove TGeoFacet from LinkDef1.h Removes "Warning: Unused class rule: TGeoFacet" Remove overriding TPartitioningI::Print fix compile time warnings concerning TGDMLWrite size_t/int cast Add Reference for AABB-triangle overlap test Fix TGeoTessellated in tutorial scripts Fix: After resizing recompute triangle center Fixup spacing in TGeoTessellated::InspectShape TGeoTessellated add default implementations for minor TGeoShape functions Add DistancetoPrimitive, SavePrimitive and Sizeof3D default implementations. Adjust Octree tolerance to determine directions parallel to axis The Revelles Octree Traversal approach requires a tolerance value to determine if a direction is parallel to Octree axis. If a direction component is smaller than this value, this will be interpreted to be 0. If a particle is tracked close to a octant boundary, this can be problematic, as the wrong octant can be chosen to be traversed next. This is a minute effect, never encountered before, but seen by tessellatedNav.C
Member
added 7 commits
February 2, 2026 12:24
Replace legacy TVector3 class with ROOT::Math::XYZVector. Using helper functions defined in TGeoTriangle in extra namespace Tessellated::XYZVectorHelper to make first transition from TVector3 to XYZVector easier and get everything to compile and run again.
Removing previously defined helper functions Tessellated::XYZVectorHelper::SetMag and Tessellated::XYZVectorHelper::Mag, as they "helped" with one-liners in the first place. Keeping Tessellated::XYZVectorHelper::ToArray, Tessellated::XYZVectorHelper::Orthogonal and Tessellated::XYZVectorHelper::Print.
Add script to test navigation functionality of TGeoTessellated using partitioning structures and without against results achieved by TGeoBBox. Not an exhaustive test, but in combination with TGeoChecker::CheckShape functionality it allows to catch most mistakes.
In the past, the TGeoTriangle implementation of finding the distance for a ray triangle intersection made it difficult to utilize it with the TBVH. Instead, the triangle data was duplicated by creating bvh2/Tri objects, to use their ray intersection algorithm. With the Moeller-Trimbure implementation it is now possible to use TGeoTriangle's ray intersection. Additionally, the code taken from Dr. Sandro Wenzel's TGeoParallelWorld BVH implementation is now marked as duplicated, and moved into its own namespace.
Member
|
Thanks a lot for the PR @BSali ! We are evaluating Sandro's request now and will have a look at this soon. We will likely integrate indeed his version based on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull request:
Introduce navigation functionality for TGeoTessellated using triangle-ray-intersection tests.
This is the navigation functionality as it is implemented for the historically grown, non-ROOT-implementation TGeoArbN.
To improve usability in VMC based simulations of meshes with high triangle count (>500), partitioning structures in the form of an Octree, as well as a BVH (using the bvh library included in root), are added. We found so far that the choice of partitioning structures seems to be mesh dependent (often BVH is best, however, for some particularly large meshes (~250k triangles) the Octree seems better). However, our BVH usage may be suboptimal.
As Dr. Sandro Wenzel opened a pull-request for his navigation implementation Add BVH-based navigation functions to TGeoTessellated #21045, we wanted to "offer" our implementation in parallel. Maybe something can be learned from it.
Tested using TGeoChecker CheckShape functionality (on a box mesh, the teddy.obj in tutorials/visualisation/geom/ contains triangle-intersections and hence is faulty), as well as by computing navigation information for 100 million random points for a box mesh and comparing results with TGeoBBox as quick test that no errors were introduced while translating our TGeoArbN to ROOT's TGeoTessellated.
Dr. Sandro Wenzel's 'rayTriangle' implementation was used to improve own implementation of Triangle ray intersection in TGeoTriangle.
Still required changes:
to compile for me, otherwise issues with std.span and modules