File indexing completed on 2026-05-27 07:23:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/definitions/detail/qualifiers.hpp"
0014 #include "detray/definitions/indexing.hpp"
0015 #include "detray/material/concepts.hpp"
0016 #include "detray/material/detail/material_accessor.hpp"
0017 #include "detray/material/material.hpp"
0018 #include "detray/navigation/accelerators/search_window.hpp"
0019 #include "detray/navigation/concepts.hpp"
0020
0021 namespace detray::detail {
0022
0023
0024 struct get_material_params {
0025 template <typename mat_group_t, typename index_t, concepts::point point_t>
0026 DETRAY_HOST_DEVICE inline auto operator()(const mat_group_t &mat_group,
0027 const index_t &idx,
0028 const point_t &loc_p) const {
0029 using material_t = typename mat_group_t::value_type;
0030
0031 if constexpr (concepts::volume_material<material_t>) {
0032 if constexpr (concepts::homogeneous_material<material_t>) {
0033
0034 return &(detail::material_accessor::get(mat_group, idx, loc_p));
0035 } else {
0036
0037 return &(detail::material_accessor::get(mat_group, idx, loc_p)
0038 .get_material());
0039 }
0040 } else {
0041 using scalar_t = typename material_t::scalar_type;
0042
0043 return static_cast<const material<scalar_t> *>(nullptr);
0044 }
0045 }
0046 };
0047
0048
0049
0050 template <typename functor_t>
0051 struct apply_to_surfaces {
0052
0053 template <concepts::accelerator_collection accel_coll_t,
0054 typename accel_index_t, typename... Args>
0055 DETRAY_HOST_DEVICE inline void operator()(const accel_coll_t &coll,
0056 const accel_index_t index,
0057 Args &&...args) const {
0058 using accel_type = typename accel_coll_t::value_type;
0059
0060 if constexpr (concepts::surface_accelerator<accel_type>) {
0061
0062 for (const auto &sf : coll[index].all()) {
0063 functor_t{}(sf, std::forward<Args>(args)...);
0064 }
0065 }
0066 }
0067 };
0068
0069
0070
0071
0072 template <typename functor_t>
0073 struct apply_to_neighbourhood {
0074
0075
0076 template <concepts::accelerator_collection accel_coll_t,
0077 typename accel_index_t, typename detector_t, typename track_t,
0078 typename window_size_t, typename... Args>
0079 DETRAY_HOST_DEVICE inline void operator()(
0080 const accel_coll_t &coll, const accel_index_t index,
0081 const detector_t &det, const typename detector_t::volume_type &volume,
0082 const track_t &track, const search_window<window_size_t, 2> &win_size,
0083 const typename detector_t::geometry_context &ctx, Args &&...args) const {
0084 using accel_type = typename accel_coll_t::value_type;
0085
0086 decltype(auto) accel = coll[index];
0087
0088 if constexpr (concepts::surface_accelerator<accel_type>) {
0089
0090 for (const auto &sf : accel.search(det, volume, track, win_size, ctx)) {
0091 functor_t{}(sf, std::forward<Args>(args)...);
0092 }
0093 } else if constexpr (concepts::volume_accelerator<accel_type>) {
0094
0095
0096 for (const dindex daughter_idx :
0097 accel.search(det, volume, track, win_size, ctx)) {
0098 functor_t{}(daughter_idx, std::forward<Args>(args)...);
0099 }
0100 }
0101 }
0102 };
0103
0104
0105 template <typename functor_t>
0106 struct apply_to_volumes {
0107
0108
0109 template <concepts::accelerator_collection accel_coll_t,
0110 typename accel_index_t, typename... Args>
0111 DETRAY_HOST_DEVICE inline void operator()(const accel_coll_t & ,
0112 const accel_index_t ,
0113 Args &&...) const {
0114 using accel_type = typename accel_coll_t::value_type;
0115
0116 if constexpr (concepts::volume_accelerator<accel_type>) {
0117
0118
0119 }
0120 }
0121 };
0122
0123 }