File indexing completed on 2026-05-27 07:24:01
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/definitions/detail/qualifiers.hpp"
0013 #include "detray/definitions/indexing.hpp"
0014 #include "detray/definitions/navigation.hpp"
0015 #include "detray/definitions/units.hpp"
0016 #include "detray/geometry/surface.hpp"
0017 #include "detray/navigation/detail/intersection_kernel.hpp"
0018 #include "detray/navigation/detail/navigation_functions.hpp"
0019 #include "detray/navigation/intersection/intersection.hpp"
0020 #include "detray/navigation/intersection/ray_intersector.hpp"
0021 #include "detray/navigation/navigation_config.hpp"
0022 #include "detray/navigation/navigation_state.hpp"
0023 #include "detray/utils/logging.hpp"
0024
0025 namespace detray {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 template <typename navigator_impl_t>
0045 class navigator_base {
0046 public:
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 template <typename track_t, typename nav_state_t, typename context_t>
0057 DETRAY_HOST_DEVICE constexpr void init(
0058 const track_t &track, nav_state_t &navigation,
0059 const navigation::config &cfg, const context_t &ctx,
0060 const bool resolve_overstepping = false) const {
0061
0062 navigation::local_navigation(track, navigation, cfg, ctx,
0063 resolve_overstepping);
0064
0065 DETRAY_VERBOSE_HOST("Status: " << navigation.status() << " (next sf.: "
0066 << navigation.next_surface().index() << ")");
0067 if (navigation.is_on_surface()) {
0068 DETRAY_VERBOSE_HOST("-> Current surface: "
0069 << navigation.current_surface().index()
0070 << ", has material: " << std::boolalpha
0071 << navigation.current_surface().has_material()
0072 << std::noboolalpha);
0073 }
0074 DETRAY_VERBOSE_HOST_DEVICE("Update complete: dist to next %f mm",
0075 navigation());
0076 }
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 template <typename track_t, typename nav_state_t, typename context_t>
0095 DETRAY_HOST_DEVICE DETRAY_INLINE constexpr bool update(
0096 const track_t &track, nav_state_t &navigation,
0097 const navigation::config &cfg, const context_t &ctx) const {
0098 assert(navigation.is_alive());
0099 assert(!track.is_invalid());
0100
0101
0102 if (navigation.trust_level() == navigation::trust_level::e_full) {
0103 DETRAY_VERBOSE_HOST_DEVICE(
0104 "-> Full trust, nothing left to do: dist to next %f mm",
0105 navigation());
0106 return false;
0107 }
0108
0109
0110
0111 constexpr const navigator_impl_t navigation_impl{};
0112 bool is_init = navigation_impl.update_impl(track, navigation, cfg, ctx);
0113
0114
0115 if (navigation.is_on_portal()) {
0116 navigation::volume_switch(track, navigation, cfg, ctx);
0117 is_init = true;
0118
0119
0120 if (!navigation.is_alive()) {
0121 return false;
0122 }
0123 }
0124
0125
0126 if (navigation.trust_level() != navigation::trust_level::e_full ||
0127 navigation.cache_exhausted()) {
0128 is_init = true;
0129 navigation::init_loose_cfg(track, navigation, cfg, ctx);
0130
0131 navigation.run_inspector(cfg, track.pos(), track.dir(), "Re-init: ");
0132 }
0133
0134 DETRAY_VERBOSE_HOST("Status: " << navigation.status() << " (vol.:"
0135 << navigation.volume() << ", next sf.: "
0136 << navigation.next_surface().index() << ")");
0137 if (navigation.is_on_surface()) {
0138 DETRAY_VERBOSE_HOST("-> Current surface: "
0139 << navigation.current_surface().index()
0140 << ", has material: " << std::boolalpha
0141 << navigation.current_surface().has_material()
0142 << std::noboolalpha);
0143 }
0144 DETRAY_VERBOSE_HOST_DEVICE("Update complete: dist to next %f mm",
0145 navigation());
0146
0147 return is_init;
0148 }
0149 };
0150
0151 }