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/algebra.hpp"
0013 #include "detray/geometry/concepts.hpp"
0014 #include "detray/navigation/intersection/helix_intersector.hpp"
0015 #include "detray/navigation/intersection/intersection_config.hpp"
0016 #include "detray/navigation/intersection/ray_intersector.hpp"
0017
0018 namespace detray {
0019
0020
0021
0022
0023 template <typename shape_t, concepts::algebra algebra_t,
0024 bool resolve_pos = false>
0025 struct intersector {
0026 using algebra_type = algebra_t;
0027 using scalar_type = dscalar<algebra_t>;
0028 using transform3_type = dtransform3D<algebra_t>;
0029
0030
0031 using ray_intersector_type = ray_intersector<shape_t, algebra_t, resolve_pos>;
0032
0033
0034 using helix_intersector_type = helix_intersector<shape_t, algebra_t>;
0035
0036
0037 static_assert(
0038 std::same_as<
0039 typename ray_intersector_type::template intersection_type<int>,
0040 typename helix_intersector_type::template intersection_type<int>>);
0041
0042
0043 static constexpr std::uint8_t n_solutions{math::max(
0044 ray_intersector_type::n_solutions, helix_intersector_type::n_solutions)};
0045
0046
0047 using result_type = typename helix_intersector_type::result_type;
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 template <typename S = shape_t>
0061 requires(!concepts::cylindrical_shape<S, algebra_type>)
0062 DETRAY_HOST_DEVICE constexpr result_type point_of_intersection(
0063 const detail::ray<algebra_t> &ray, const transform3_type &trf,
0064 const scalar_type overstep_tol = 0.f) const {
0065 return to_result_type(
0066 ray_intersector_type{}.point_of_intersection(ray, trf, overstep_tol));
0067 }
0068
0069 template <typename mask_t, typename S = shape_t>
0070 requires concepts::cylindrical_shape<S, algebra_type>
0071 DETRAY_HOST_DEVICE constexpr result_type point_of_intersection(
0072 const detail::ray<algebra_t> &ray, const transform3_type &trf,
0073 const mask_t &mask, const scalar_type overstep_tol = 0.f) const {
0074 return to_result_type(ray_intersector_type{}.point_of_intersection(
0075 ray, trf, mask, overstep_tol));
0076 }
0077
0078 template <typename S = shape_t>
0079 requires(!concepts::cylindrical_shape<S, algebra_type>)
0080 DETRAY_HOST_DEVICE constexpr result_type point_of_intersection(
0081 const detail::helix<algebra_t> &h, const transform3_type &trf,
0082 const scalar_type = 0.f) const {
0083 return helix_intersector_type{}.point_of_intersection(h, trf);
0084 }
0085
0086 template <typename mask_t, typename S = shape_t>
0087 requires concepts::cylindrical_shape<S, algebra_type>
0088 DETRAY_HOST_DEVICE constexpr result_type point_of_intersection(
0089 const detail::helix<algebra_t> &h, const transform3_type &trf,
0090 const mask_t &mask, const scalar_type = 0.f) const {
0091 return helix_intersector_type{}.point_of_intersection(h, trf, mask);
0092 }
0093
0094
0095
0096 template <typename surface_descr_t, typename mask_t>
0097 DETRAY_HOST_DEVICE inline decltype(auto) operator()(
0098 const detail::ray<algebra_t> &ray, const surface_descr_t &sf,
0099 const mask_t &mask, const transform3_type &trf,
0100 const intersection::config &cfg = {},
0101 const scalar_type external_mask_tol = 0.f) const {
0102 return ray_intersector_type{}(ray, sf, mask, trf, cfg, external_mask_tol);
0103 }
0104
0105
0106 template <typename surface_descr_t, typename mask_t>
0107 DETRAY_HOST_DEVICE inline decltype(auto) operator()(
0108 const detail::helix<algebra_t> &h, const surface_descr_t &sf,
0109 const mask_t &mask, const transform3_type &trf,
0110 const intersection::config &cfg = {},
0111 const scalar_type = 0.f) const {
0112 return helix_intersector_type{}(h, sf, mask, trf, cfg);
0113 }
0114
0115 private:
0116
0117 DETRAY_HOST_DEVICE
0118 constexpr result_type to_result_type(
0119 const ray_intersector_type::result_type &ray_results) const {
0120 result_type result;
0121 if constexpr (n_solutions > 1) {
0122 for (std::size_t i = 0u; i < n_solutions; ++i) {
0123 result[i] = typename result_type::value_type{ray_results[i]};
0124 }
0125 } else {
0126 result = result_type{ray_results};
0127 }
0128 return result;
0129 }
0130 };
0131
0132 }