12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/detail/qualifiers.hpp"
14#include "detray/definitions/indexing.hpp"
15#include "detray/geometry/concepts.hpp"
16#include "detray/geometry/shapes/cuboid3D.hpp"
17#include "detray/navigation/intersection/intersection.hpp"
44 typename links_t = std::uint_least16_t>
68 using mask_values =
typename shape::template bounds_type<scalar_type>;
70 using local_frame =
typename shape::template local_frame_type<algebra_t>;
75 constexpr mask() =
default;
79 template <
typename... Args>
80 requires(
sizeof...(Args) == shape::boundaries::e_size)
83 : _values({{std::forward<Args>(args)...}}), _volume_link(link) {}
89 : _values{
values}, _volume_link{link} {}
95 : _volume_link(link) {
96 assert(
values.size() == boundaries::e_size &&
97 " Given number of boundaries does not match mask shape.");
98 std::ranges::copy(
values, std::begin(_values));
124 return _values[value_index];
132 constexpr auto operator[](
const std::size_t value_index)
const
134 return _values[value_index];
199 template <concepts::po
int po
int_t>
201 const point_t& loc_p,
202 const scalar_type tol = std::numeric_limits<scalar_type>::epsilon(),
204 return get_shape().check_boundaries(_values, loc_p, tol, edge_tol);
215 const scalar_type tol = std::numeric_limits<scalar_type>::epsilon(),
217 return get_shape().template check_boundaries<algebra_type>(
218 _values, trf, glob_p, tol, edge_tol);
225 template <concepts::po
int po
int_t>
227 const point_t& loc_p,
229 std::numeric_limits<scalar_type>::epsilon())
const {
242 std::numeric_limits<scalar_type>::epsilon())
const {
244 get_shape().
template check_boundaries<algebra_type>(
268 template <
typename S = shape_t>
269 requires(S::dim == 2)
275 template <
typename S = shape_t>
276 requires(S::dim == 3)
293 return get_shape().min_dist_to_boundary(_values, loc_p);
305 const scalar_type env = std::numeric_limits<scalar_type>::epsilon()) const
309 static_assert(bounds.size() == cuboid3D::e_size,
310 "Shape returns incompatible bounds for bound box");
311 return {bounds, std::numeric_limits<unsigned int>::max()};
339 : detail::invalid_value<links_type>()};
343 return {std::move(merged_vals), vol_link};
350 const bool result =
get_shape().check_consistency(_values, os);
362 std::stringstream ss;
363 ss << std::string(shape::name);
364 for (
const auto& v : _values) {
379 links_type _volume_link{std::numeric_limits<links_type>::max()};
Geometrical shape of a full 3D cuboid.
Definition cuboid3D.hpp:32
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
constexpr auto volume() const -> scalar_type
Definition mask.hpp:277
auto vertices(const dindex n_seg) const -> dvector< point3_type >
Vertices of the mask in local cartesian coordinates.
Definition mask.hpp:322
dscalar< algebra_t > scalar_type
Scalar type used for boundary values.
Definition mask.hpp:51
algebra_t algebra_type
Linear algebra types.
Definition mask.hpp:49
auto centroid() const
Definition mask.hpp:282
constexpr bool self_check(std::ostream &os) const
Definition mask.hpp:349
constexpr auto operator[](const std::size_t value_index) const -> scalar_type
Subscript operator - const.
Definition mask.hpp:132
static constexpr auto to_local_frame(const transform3_type &trf, const point3_type &glob_p, const point3_type &glob_dir={}) -> point2_type
Definition mask.hpp:160
static consteval local_frame get_local_frame()
Definition mask.hpp:142
constexpr dbool< algebra_t > is_inside(const point_t &loc_p, const scalar_type tol=std::numeric_limits< scalar_type >::epsilon()) const
Definition mask.hpp:226
auto operator=(const mask_values &rhs) -> mask< shape_t, algebra_t, links_t > &
Assignment operator from an array, convenience function.
Definition mask.hpp:106
dpoint3D< algebra_t > point3_type
Three-dimensional point type in the algebra backend.
Definition mask.hpp:55
typename shape::template result_type< dbool< algebra_t > > result_type
Result type returned by shape boundary checks.
Definition mask.hpp:72
bool operator==(const mask &rhs) const =default
Equality operator.
static consteval auto get_shape() -> shape
Definition mask.hpp:139
auto volume_link() const -> const links_type &
Definition mask.hpp:255
constexpr dbool< algebra_type > is_inside(const transform3_type &trf, const point3_type &glob_p, const scalar_type tol=std::numeric_limits< scalar_type >::epsilon()) const
Definition mask.hpp:239
constexpr mask(const mask_values &values, const links_type &link)
Constructor from mask boundary array.
Definition mask.hpp:88
auto min_dist_to_boundary(const point3_type &loc_p) const -> scalar_type
Find the minimum distance to any boundary.
Definition mask.hpp:292
typename shape::template local_frame_type< algebra_t > local_frame
Coordinate frame used for shape boundary checks.
Definition mask.hpp:70
constexpr mask()=default
Default constructor.
auto volume_link() -> links_type &
Definition mask.hpp:259
dtransform3D< algebra_t > transform3_type
Transform type used to map between local and global coordinates.
Definition mask.hpp:59
constexpr auto operator[](const std::size_t value_index) -> scalar_type &
Subscript operator - non-const.
Definition mask.hpp:123
static constexpr auto to_global_frame(const transform3_type &trf, const point3_type &loc) -> point3_type
Definition mask.hpp:169
friend mask operator+(const mask &left, const mask &right)
Merge two masks to a bigger one of the same shape.
Definition mask.hpp:336
typename shape::boundaries boundaries
Boundary index enum supplied by the shape.
Definition mask.hpp:66
constexpr mask(const links_type &link, Args &&... args)
Constructor from single mask boundary values.
Definition mask.hpp:81
auto to_string() const -> std::string
Definition mask.hpp:361
static constexpr auto to_local_frame3D(const transform3_type &trf, const point3_type &glob_p, const point3_type &glob_dir={}) -> point3_type
Definition mask.hpp:150
typename shape::template bounds_type< scalar_type > mask_values
Array type that stores the shape boundary values.
Definition mask.hpp:68
dpoint2D< algebra_t > point2_type
Two-dimensional point type in the algebra backend.
Definition mask.hpp:53
dvector3D< algebra_t > vector3_type
Three-dimensional vector type in the algebra backend.
Definition mask.hpp:57
constexpr auto area() const -> scalar_type
Definition mask.hpp:270
constexpr auto measure() const -> scalar_type
Definition mask.hpp:263
auto local_min_bounds(const scalar_type env=std::numeric_limits< scalar_type >::epsilon()) const -> mask< cuboid3D, algebra_t, unsigned int >
Lower and upper point for minimum axis aligned bounding box.
Definition mask.hpp:304
constexpr result_type resolve(const transform3_type &trf, const point3_type &glob_p, const scalar_type tol=std::numeric_limits< scalar_type >::epsilon(), const scalar_type edge_tol=0.f) const
Definition mask.hpp:213
links_t links_type
Type used to link this mask to its volume.
Definition mask.hpp:62
friend std::ostream & operator<<(std::ostream &os, const mask &m)
Definition mask.hpp:372
auto values() const -> const mask_values &
Definition mask.hpp:251
mask(const std::vector< scalar_type > &values, const links_type &link)
Constructor from mask boundary vector.
Definition mask.hpp:93
shape_t shape
Geometric shape whose boundaries define this mask.
Definition mask.hpp:64
constexpr auto to_global_frame(const transform3_type &trf, const point2_type &loc, const vector3_type &dir) const -> point3_type
Definition mask.hpp:178
Algebra plugin concept.
Definition concepts.hpp:147
Concept for a geometrical shape.
Definition concepts.hpp:54
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
vecmem::vector< value_t > dvector
Vector container backed by vecmem.
Definition containers.hpp:34
unsigned int dindex
Default index type.
Definition indexing.hpp:18
get_boolean_t< A > dbool
Boolean type associated with the algebra backend.
Definition algebra.hpp:52
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_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