Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:57

0001 // \file BVHLevelLocator.h
0002 // \author Guilherme Amadio
0003 
0004 #ifndef VECGEOM_NAVIGATION_BVHLEVELLOCATOR_H_
0005 #define VECGEOM_NAVIGATION_BVHLEVELLOCATOR_H_
0006 
0007 #include "VecGeom/management/BVHManager.h"
0008 #include "VecGeom/navigation/VLevelLocator.h"
0009 
0010 namespace vecgeom {
0011 inline namespace VECGEOM_IMPL_NAMESPACE {
0012 
0013 class LogicalVolume;
0014 class VPlacedVolume;
0015 
0016 /**
0017  * @brief Level locator class using the bounding volume hierarchy of each logical volume for acceleration.
0018  */
0019 
0020 class BVHLevelLocator : public VLevelLocator {
0021 private:
0022   /** Constructor. Private since this is a singleton class accessed only via the @c Instance() static method. */
0023   BVHLevelLocator() = default;
0024 
0025 public:
0026   /** Returns the instance of this singleton class. */
0027   static VLevelLocator const *GetInstance()
0028   {
0029     static BVHLevelLocator instance;
0030     return &instance;
0031   }
0032 
0033   /** Returns the name of this class. */
0034   std::string GetName() const final { return "BVHLevelLocator"; }
0035 
0036   /**
0037    * Find child volume of @p lvol inside which the given point @p localpoint is located.
0038    * @param[in] lvol Logical volume being checked.
0039    * @param[in] localpoint Point in the local coordinates of the logical volume.
0040    * @param[out] daughterpvol Placed volume in which @p localpoint is contained
0041    * @param[out] daughterlocalpoint Point in the local coordinates of @p daughterpvol
0042    * @returns Whether @p localpoint falls within a child volume of @p lvol.
0043    */
0044   bool LevelLocate(LogicalVolume const *lvol, Vector3D<Precision> const &localpoint, VPlacedVolume const *&pvol,
0045                    Vector3D<Precision> &daughterlocalpoint) const final
0046   {
0047     return BVHManager::GetBVH(lvol)->LevelLocate(localpoint, pvol, daughterlocalpoint);
0048   }
0049 
0050   /**
0051    * Find child volume of @p lvol inside which the given point @p localpoint is located.
0052    * @param[in] lvol Logical volume being checked.
0053    * @param[in] localpoint Point in the local coordinates of the logical volume.
0054    * @param[out] outstate Navigation state. Gets updated if point is relocated to another volume.
0055    * @param[out] daughterlocalpoint Point in the local coordinates of newly located volume.
0056    * @returns Whether @p localpoint falls within a child volume of @p lvol.
0057    */
0058   bool LevelLocate(LogicalVolume const *lvol, Vector3D<Precision> const &localpoint, NavigationState &state,
0059                    Vector3D<Precision> &daughterlocalpoint) const final
0060   {
0061     return BVHManager::GetBVH(lvol)->LevelLocate(localpoint, state, daughterlocalpoint);
0062   }
0063 
0064   /**
0065    * Find child volume of @p lvol inside which the given point @p localpoint is located.
0066    * @param[in] lvol Logical volume being checked.
0067    * @param[in] exclvol Placed volume that should be ignored.
0068    * @param[in] localpoint Point in the local coordinates of the logical volume.
0069    * @param[out] pvol Placed volume in which @p localpoint is contained
0070    * @param[out] daughterlocalpoint Point in the local coordinates of @p daughterpvol
0071    * @returns Whether @p localpoint falls within a child volume of @p lvol.
0072    */
0073   bool LevelLocateExclVol(LogicalVolume const *lvol, VPlacedVolume const *exclvol,
0074                           Vector3D<Precision> const &localpoint, VPlacedVolume const *&pvol,
0075                           Vector3D<Precision> &daughterlocalpoint) const final
0076   {
0077     return BVHManager::GetBVH(lvol)->LevelLocate(exclvol, localpoint, pvol, daughterlocalpoint);
0078   }
0079 
0080   /**
0081    * Find child volume of @p lvol inside which the given point @p localpoint is located.
0082    * @param[in] lvol Logical volume being checked.
0083    * @param[in] exclvol Placed volume that should be ignored.
0084    * @param[in] localpoint Point in the local coordinates of the logical volume.
0085    * @param[in] localdir Direction in the local coordinates of the logical volume.
0086    * @param[out] pvol Placed volume in which @p localpoint is contained
0087    * @param[out] daughterlocalpoint Point in the local coordinates of @p daughterpvol
0088    * @returns Whether @p localpoint falls within a child volume of @p lvol.
0089    */
0090   bool LevelLocateExclVol(LogicalVolume const *lvol, VPlacedVolume const *exclvol,
0091                           Vector3D<Precision> const &localpoint, Vector3D<Precision> const &localdirection,
0092                           VPlacedVolume const *&pvol, Vector3D<Precision> &daughterlocalpoint) const final
0093   {
0094     return BVHManager::GetBVH(lvol)->LevelLocate(exclvol, localpoint, localdirection, pvol, daughterlocalpoint);
0095   }
0096 }; // end class declaration
0097 
0098 } // namespace VECGEOM_IMPL_NAMESPACE
0099 } // namespace vecgeom
0100 
0101 #endif