12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/detail/qualifiers.hpp"
14#include "detray/definitions/indexing.hpp"
15#include "detray/definitions/math.hpp"
16#include "detray/definitions/units.hpp"
17#include "detray/geometry/concepts.hpp"
18#include "detray/geometry/detail/shape_utils.hpp"
19#include "detray/navigation/intersection/intersection.hpp"
20#include "detray/navigation/intersection/intersection_config.hpp"
21#include "detray/utils/invalid_values.hpp"
32template <
typename intersector_t>
52 template <
typename surface_descr_t>
57 template <
typename other_algebra_t>
62 static constexpr std::uint8_t
n_solutions{intersector_t::n_solutions};
82 template <
typename surface_descr_t,
typename mask_t,
91 call_intersector(traj,
mask, trf, cfg.overstep_tolerance);
107 template <
typename surface_descr_t,
typename mask_t,
108 concepts::algebra other_algebra_t, std::uint8_t N =
n_solutions>
113 const surface_descr_t &sf,
const mask_t &
mask,
118 call_intersector(traj,
mask, trf, cfg.overstep_tolerance);
123 if (detray::detail::any_of(result[i].is_valid())) {
143 template <
typename surface_descr_t,
typename mask_t,
144 concepts::algebra other_algebra_t>
145 DETRAY_HOST_DEVICE
constexpr decltype(
auto)
operator()(
151 .min_mask_tolerance =
static_cast<float>(mask_tolerance),
152 .max_mask_tolerance =
static_cast<float>(mask_tolerance),
153 .mask_tolerance_scalor = 0.f,
154 .overstep_tolerance =
static_cast<float>(overstep_tol)};
161 template <concepts::algebra other_algebra_t,
typename mask_t>
167 return intersector_t{}.point_of_intersection(traj, trf, mask,
170 return intersector_t{}.point_of_intersection(traj, trf, overstep_tol);
185template <
typename intersection_t,
typename trajectory_t,
187 typename surface_descr_t,
typename mask_t,
190 intersection_t &is,
const trajectory_t &traj,
193 const surface_descr_t sf_desc,
const mask_t &
mask,
const transform3_t &trf,
195 const scalar_t external_mask_tolerance = 0.f) {
197 if constexpr (concepts::soa<algebra_t>) {
198 using status_t =
typename intersection_t::status_type;
200 is.status()(is.path() < cfg.overstep_tolerance) =
201 static_cast<status_t
>(intersection::status::e_outside);
203 is.set_status(intersection::status::e_outside);
207 if (detray::detail::none_of(ip.path >= cfg.overstep_tolerance)) {
213 if constexpr (intersection_t::contains_pos()) {
218 const auto &origin = traj.pos();
219 const auto &dir = traj.dir();
225 glob_pos = ro + ip.path * rd;
228 glob_pos = traj.pos(ip.path);
230 is.set_local(mask_t::to_local_frame3D(trf, glob_pos, traj.dir(ip.path)));
233 scalar_t base_tol = 0.f;
234 scalar_t ext_tol = 0.f;
237 if (!sf_desc.is_portal() ||
238 cfg.min_mask_tolerance == std::numeric_limits<float>::max()) {
239 ext_tol = external_mask_tolerance;
241 math::max(
static_cast<scalar_t
>(cfg.min_mask_tolerance),
242 math::min(
static_cast<scalar_t
>(cfg.max_mask_tolerance),
243 static_cast<scalar_t
>(cfg.mask_tolerance_scalor) *
244 math::fabs(ip.path)));
248 typename mask_t::result_type mask_check{};
251 if constexpr (std::same_as<point_t, dpoint2D<algebra_t>>) {
252 mask_check =
mask.
resolve(ip.point, base_tol, ext_tol);
255 mask_check =
mask.
resolve(trf, ip.point, base_tol, ext_tol);
259 is.set_status_if(intersection::status::e_edge,
261 is.set_status_if(intersection::status::e_inside,
264 is.set_path(ip.path);
265 is.set_surface(sf_desc);
266 is.set_direction(!math::signbit(ip.path));
Mask a region on a surface and link it to a volume.
Definition mask.hpp:46
constexpr result_type resolve(const point_t &loc_p, const scalar_type tol=std::numeric_limits< scalar_type >::epsilon(), const scalar_type edge_tol=0.f) const
Mask this shape onto a surface.
Definition mask.hpp:200
auto volume_link() const -> const links_type &
Definition mask.hpp:255
Algebra plugin concept.
Definition concepts.hpp:147
Definition concepts.hpp:214
Point concepts.
Definition concepts.hpp:71
Scalar concept: Elements of vectors/matrices (can be simd vectors).
Definition concepts.hpp:40
Check if an algebra has soa layout.
Definition concepts.hpp:159
Detray include(s).
Definition array_operators.hpp:18
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
constexpr void resolve_mask(intersection_t &is, const trajectory_t &traj, const intersection_point< algebra_t, point_t, intersection::contains_pos > &ip, const surface_descr_t sf_desc, const mask_t &mask, const transform3_t &trf, const intersection::config &cfg={}, const scalar_t external_mask_tolerance=0.f)
Fill an intersection with the result of the intersection alg.
Definition intersector_base.hpp:189
std::array< value_t, kDIM > darray
Fixed-size array container.
Definition containers.hpp:30
const auto & get(const detray::tuple< Ts... > &t) noexcept
Get a tuple element by index from a const tuple.
Definition tuple.hpp:152
get_vector3D_t< A, T > dvector3D
Three-dimensional vector type for algebra A and value type T.
Definition algebra.hpp:80
get_transform3D_t< A, T > dtransform3D
Three-dimensional transform type for algebra A and value type T.
Definition algebra.hpp:84
get_value_t< A > dvalue
Value scalar type of the algebra backend.
Definition algebra.hpp:48
get_point3D_t< A, T > dpoint3D
Three-dimensional point type for algebra A and value type T.
Definition algebra.hpp:72
get_point2D_t< A, T > dpoint2D
Two-dimensional point type for algebra A and value type T.
Definition algebra.hpp:68
Intersector configuration.
Definition intersection_config.hpp:21
Result of intersector: Point of intersection on a surface.
Definition intersection.hpp:43
Base class for an intersector: Provides mask based call interfaces for convenience.
Definition intersector_base.hpp:33
dscalar< algebra_type > scalar_type
Definition intersector_base.hpp:40
dvector3D< algebra_type > vector3_type
Definition intersector_base.hpp:46
typename helix_intersector_impl< typename shape_t::template local_frame_type< algebra_t >, algebra_t >::template intersection_type< surface_descr_t > intersection_type
Definition intersector_base.hpp:53
typename helix_intersector_impl< typename shape_t::template local_frame_type< algebra_t >, algebra_t >::result_type result_type
Definition intersector_base.hpp:65
dpoint2D< algebra_type > point2_type
Definition intersector_base.hpp:42
constexpr intersection_type< surface_descr_t > operator()(const trajectory_type< other_algebra_t > &traj, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const intersection::config &cfg={}, const scalar_type external_mask_tol=0.f) const
Operator function to find intersections between trajectory and a surface.
Definition intersector_base.hpp:85
dpoint3D< algebra_type > point3_type
Definition intersector_base.hpp:44
dtransform3D< algebra_type > transform3_type
Definition intersector_base.hpp:48
typename helix_intersector_impl< typename shape_t::template local_frame_type< algebra_t >, algebra_t >::template trajectory_type< other_algebra_t > trajectory_type
Definition intersector_base.hpp:58
static constexpr std::uint8_t n_solutions
Definition intersector_base.hpp:62
typename helix_intersector_impl< typename shape_t::template local_frame_type< algebra_t >, algebra_t >::algebra_type algebra_type
Definition intersector_base.hpp:36
dvalue< algebra_type > value_type
Definition intersector_base.hpp:38