File indexing completed on 2025-09-17 08:59:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #pragma once
0013
0014 #include <VecGeom/base/Config.h>
0015 #include <VecGeom/base/Global.h>
0016 #include <VecGeom/base/Vector3D.h>
0017 #include <VecGeom/navigation/NavigationState.h>
0018 #include <VecGeom/surfaces/BVHSurfNavigator.h>
0019
0020 #ifdef VECGEOM_ENABLE_CUDA
0021 # include <VecGeom/backend/cuda/Interface.h>
0022 #endif
0023 #include "corecel/Macros.hh"
0024
0025 namespace celeritas
0026 {
0027 namespace detail
0028 {
0029
0030 class SurfNavigator
0031 {
0032 public:
0033 using Precision = vecgeom::Precision;
0034 using Vector3D = vecgeom::Vector3D<vecgeom::Precision>;
0035 using SurfData = vgbrep::SurfData<Precision>;
0036 using Real_b = typename SurfData::Real_b;
0037 using VPlacedVolumePtr_t = vecgeom::VPlacedVolume const*;
0038
0039 static constexpr Precision kBoundaryPush = 10 * vecgeom::kTolerance;
0040
0041
0042
0043
0044
0045
0046
0047
0048 CELER_FUNCTION static int LocatePointIn(int pvol_id,
0049 Vector3D const& point,
0050 vecgeom::NavigationState& path,
0051 bool top,
0052 int* exclude = nullptr)
0053 {
0054 return vgbrep::protonav::BVHSurfNavigator<Precision>::LocatePointIn(
0055 pvol_id, point, path, top, exclude);
0056 }
0057
0058
0059
0060
0061
0062 CELER_FUNCTION static Precision
0063 ComputeSafety(Vector3D const& globalpoint,
0064 vecgeom::NavigationState const& state)
0065 {
0066 auto safety
0067 = vgbrep::protonav::BVHSurfNavigator<Precision>::ComputeSafety(
0068 globalpoint, state);
0069 return safety;
0070 }
0071
0072
0073
0074
0075
0076
0077
0078
0079 CELER_FUNCTION static Precision
0080 ComputeStepAndNextVolume(Vector3D const& globalpoint,
0081 Vector3D const& globaldir,
0082 Precision step_limit,
0083 vecgeom::NavigationState const& in_state,
0084 vecgeom::NavigationState& out_state,
0085 long& hitsurf)
0086 {
0087 if (step_limit <= 0)
0088 {
0089 in_state.CopyTo(&out_state);
0090 out_state.SetBoundaryState(false);
0091 return step_limit;
0092 }
0093
0094 auto step = vgbrep::protonav::BVHSurfNavigator<
0095 Precision>::ComputeStepAndNextSurface(globalpoint,
0096 globaldir,
0097 in_state,
0098 out_state,
0099 hitsurf,
0100 step_limit);
0101 return step;
0102 }
0103
0104
0105
0106
0107
0108 CELER_FUNCTION static Precision
0109 ComputeStepAndPropagatedState(Vector3D const& globalpoint,
0110 Vector3D const& globaldir,
0111 Precision step_limit,
0112 long& hit_surf,
0113 vecgeom::NavigationState const& in,
0114 vecgeom::NavigationState& out)
0115 {
0116 return ComputeStepAndNextVolume(
0117 globalpoint, globaldir, step_limit, in, out, hit_surf);
0118 }
0119
0120
0121
0122
0123 CELER_FUNCTION static void
0124 RelocateToNextVolume(Vector3D const& globalpoint,
0125 Vector3D const& globaldir,
0126 long hitsurf_index,
0127 vecgeom::NavigationState& out_state)
0128 {
0129 CELER_EXPECT(!out_state.IsOutside());
0130 vgbrep::CrossedSurface crossed_surf;
0131 vgbrep::protonav::BVHSurfNavigator<Precision>::RelocateToNextVolume(
0132 globalpoint,
0133 globaldir,
0134 Precision(0),
0135 hitsurf_index,
0136 out_state,
0137 crossed_surf);
0138 }
0139 };
0140
0141 }
0142 }