Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-05 10:53:54

0001 /// @file SurfaceHitView.h
0002 /// @brief Optional exit-normal information returned by distance queries.
0003 
0004 #ifndef VECGEOM_VOLUMES_SURFACEHITVIEW_H_
0005 #define VECGEOM_VOLUMES_SURFACEHITVIEW_H_
0006 
0007 #include "VecGeom/base/Global.h"
0008 #include "VecGeom/base/Vector3D.h"
0009 
0010 namespace vecgeom {
0011 
0012 inline namespace VECGEOM_IMPL_NAMESPACE {
0013 
0014 /// @brief Optional exit information associated with a scalar `DistanceToOut` result.
0015 /// @details Normal storage is supplied by the caller. For every finite exit
0016 /// returned by `DistanceToOut`, a requested normal is set to the unit outward
0017 /// normal of the exit surface at the hit point. `fLeftBehind` additionally
0018 /// tells whether the complete solid lies behind or on the plane through the hit
0019 /// point with that normal. Without a finite exit (wrong-side start, no hit)
0020 /// the normal storage is left untouched. This flag is not the validity result
0021 /// returned by VecGeom's standalone `Normal()` query.
0022 template <typename Real_t = Precision>
0023 struct SurfaceHitView {
0024   Vector3D<Real_t> *fNormal = nullptr; ///< Optional destination for the unit outward exit-surface normal.
0025   bool fLeftBehind          = false;   ///< Whether the hit plane leaves the complete solid behind or on it.
0026 
0027   /// @brief Check whether normal output was requested.
0028   /// @return True when `fNormal` points to writable storage.
0029   VECCORE_ATT_HOST_DEVICE
0030   bool WantsNormal() const { return fNormal != nullptr; }
0031 
0032   /// @brief Reset validity without touching caller-owned normal storage.
0033   VECCORE_ATT_HOST_DEVICE
0034   void Clear() { fLeftBehind = false; }
0035 
0036   /// @brief Store whether the exit-surface normal defines a supporting plane.
0037   /// @param leftBehind True when the complete solid lies behind or on the hit plane.
0038   VECCORE_ATT_HOST_DEVICE
0039   void SetLeftBehind(bool leftBehind) { fLeftBehind = leftBehind; }
0040 
0041   /// @brief Store a unit outward normal if requested.
0042   /// @param normal Unit outward normal in the query-local coordinate frame.
0043   VECCORE_ATT_HOST_DEVICE
0044   void SetNormal(Vector3D<Real_t> const &normal) const
0045   {
0046     if (fNormal) *fNormal = normal;
0047   }
0048 };
0049 
0050 } // namespace VECGEOM_IMPL_NAMESPACE
0051 } // namespace vecgeom
0052 
0053 #endif // VECGEOM_VOLUMES_SURFACEHITVIEW_H_