ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
detray::mask< shape_t, algebra_t, links_t > Class Template Reference

Mask a region on a surface and link it to a volume. More...

#include <detray/geometry/mask.hpp>

Inheritance diagram for detray::mask< shape_t, algebra_t, links_t >:
[legend]

Public Types

using algebra_type = algebra_t
 Linear algebra types.
using boundaries = typename shape::boundaries
 Boundary index enum supplied by the shape.
using links_type = links_t
 Type used to link this mask to its volume.
using local_frame = typename shape::template local_frame_type<algebra_t>
 Coordinate frame used for shape boundary checks.
using mask_values = typename shape::template bounds_type<scalar_type>
 Array type that stores the shape boundary values.
using point2_type = dpoint2D<algebra_t>
 Two-dimensional point type in the algebra backend.
using point3_type = dpoint3D<algebra_t>
 Three-dimensional point type in the algebra backend.
using result_type = typename shape::template result_type<dbool<algebra_t>>
 Result type returned by shape boundary checks.
using scalar_type = dscalar<algebra_t>
 Scalar type used for boundary values.
using shape = shape_t
 Geometric shape whose boundaries define this mask.
using transform3_type = dtransform3D<algebra_t>
 Transform type used to map between local and global coordinates.
using vector3_type = dvector3D<algebra_t>
 Three-dimensional vector type in the algebra backend.

Public Member Functions

constexpr mask ()=default
 Default constructor.
template<typename... Args>
requires (sizeof...(Args) == shape::boundaries::e_size)
constexpr mask (const links_type &link, Args &&... args)
 Constructor from single mask boundary values.
constexpr mask (const mask_values &values, const links_type &link)
 Constructor from mask boundary array.
 mask (const std::vector< scalar_type > &values, const links_type &link)
 Constructor from mask boundary vector.
template<typename S = shape_t>
requires (S::dim == 2)
constexpr auto area () const -> scalar_type
auto centroid () const
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.
constexpr auto measure () const -> scalar_type
auto min_dist_to_boundary (const point3_type &loc_p) const -> scalar_type
 Find the minimum distance to any boundary.
auto operator= (const mask_values &rhs) -> mask< shape_t, algebra_t, links_t > &
 Assignment operator from an array, convenience function.
bool operator== (const mask &rhs) const =default
 Equality operator.
constexpr auto operator[] (const std::size_t value_index) -> scalar_type &
 Subscript operator - non-const.
constexpr auto operator[] (const std::size_t value_index) const -> scalar_type
 Subscript operator - const.
constexpr bool self_check (std::ostream &os) const
constexpr auto to_global_frame (const transform3_type &trf, const point2_type &loc, const vector3_type &dir) const -> point3_type
auto to_string () const -> std::string
auto values () const -> const mask_values &
auto vertices (const dindex n_seg) const -> dvector< point3_type >
 Vertices of the mask in local cartesian coordinates.
template<typename S = shape_t>
requires (S::dim == 3)
constexpr auto volume () const -> scalar_type
auto volume_link () -> links_type &
auto volume_link () const -> const links_type &
template<concepts::point point_t>
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.
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
template<concepts::point point_t>
constexpr dbool< algebra_t > is_inside (const point_t &loc_p, const scalar_type tol=std::numeric_limits< scalar_type >::epsilon()) const
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

Static Public Member Functions

static consteval local_frame get_local_frame ()
static consteval auto get_shape () -> shape
static constexpr auto to_global_frame (const transform3_type &trf, const point3_type &loc) -> point3_type
static constexpr auto to_local_frame (const transform3_type &trf, const point3_type &glob_p, const point3_type &glob_dir={}) -> point2_type
static constexpr auto to_local_frame3D (const transform3_type &trf, const point3_type &glob_p, const point3_type &glob_dir={}) -> point3_type

Detailed Description

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
requires concepts::shape<shape_t, algebra_t>
class detray::mask< shape_t, algebra_t, links_t >

Mask a region on a surface and link it to a volume.

The class uses a lightweight 'shape' that defines the local geometry of a surface (local coordinates and how to check boundaries on local point that lies on the surface). A simple example is rectangle2D , can be used to mask a rectangle on an underlying plane. This class can then be instantiated as a concrete mask that holds the boundary values, as well as the link to a particular volume, which is needed during geometry navigation.

Template Parameters
shape_tunderlying geometrical shape of the mask, rectangle etc
links_tthe type of link into the volume container (e.g. single index vs range)

Constructor & Destructor Documentation

◆ mask() [1/3]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
template<typename... Args>
requires (sizeof...(Args) == shape::boundaries::e_size)
detray::mask< shape_t, algebra_t, links_t >::mask ( const links_type & link,
Args &&... args )
explicitconstexpr

Constructor from single mask boundary values.

Parameters
argsand volume link
link

◆ mask() [2/3]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
detray::mask< shape_t, algebra_t, links_t >::mask ( const mask_values & values,
const links_type & link )
constexpr

Constructor from mask boundary array.

Parameters
valuesand volume link
link

◆ mask() [3/3]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
detray::mask< shape_t, algebra_t, links_t >::mask ( const std::vector< scalar_type > & values,
const links_type & link )

Constructor from mask boundary vector.

Parameters
valuesand volume link
link

Member Function Documentation

◆ area()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
template<typename S = shape_t>
requires (S::dim == 2)
auto detray::mask< shape_t, algebra_t, links_t >::area ( ) const->scalar_type
constexpr
Returns
the area the mask defines on the local geometry (2D)

◆ centroid()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::centroid ( ) const
Returns
the masks centroid in local cartesian coordinates

◆ get_local_frame()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
consteval local_frame detray::mask< shape_t, algebra_t, links_t >::get_local_frame ( )
staticconsteval
Returns
return local frame object (used in geometrical checks)

◆ get_shape()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
consteval auto detray::mask< shape_t, algebra_t, links_t >::get_shape ( ) ->shape
staticconsteval
Returns
the mask shape

◆ is_inside() [1/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
template<concepts::point point_t>
dbool< algebra_t > detray::mask< shape_t, algebra_t, links_t >::is_inside ( const point_t & loc_p,
const scalar_type tol = std::numeric_limits<scalar_type>::epsilon() ) const
constexpr
Parameters
loc_pthe point to be checked in the local system (2D or 3D)
toldynamic tolerance determined by caller
Returns
an intersection status e_inside / e_outside

◆ is_inside() [2/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
dbool< algebra_type > detray::mask< shape_t, algebra_t, links_t >::is_inside ( const transform3_type & trf,
const point3_type & glob_p,
const scalar_type tol = std::numeric_limits<scalar_type>::epsilon() ) const
constexpr
Parameters
trfthe (contextual) surface transform
glob_pthe point to be checked in the global cartesian system
toldynamic tolerance determined by caller
Returns
an intersection status e_inside / e_outside

◆ local_min_bounds()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::local_min_bounds ( const scalar_type env = std::numeric_limits<scalar_type>::epsilon()) const->mask< cuboid3D, algebra_t, unsignedint >

Lower and upper point for minimum axis aligned bounding box.

Computes the min and max vertices in a local 3 dim cartesian frame.

Parameters
envdynamic envelope around the shape
Returns
a cuboid3D mask that is equivalent to the minimum local aabb.

◆ measure()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::measure ( ) const->scalar_type
constexpr
Returns
the masks measure (area or volume covered by boundary check on local positions)

◆ min_dist_to_boundary()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::min_dist_to_boundary ( const point3_type & loc_p) const->scalar_type

Find the minimum distance to any boundary.

Parameters
loc_pthe point to be checked in the local system
Returns
the minimum distance.

◆ operator=()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::operator= ( const mask_values & rhs) ->mask< shape_t, algebra_t, links_t > &

Assignment operator from an array, convenience function.

Parameters
rhsis the right hand side object
Returns
Reference to this mask after assignment.

◆ operator==()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
bool detray::mask< shape_t, algebra_t, links_t >::operator== ( const mask< shape_t, algebra_t, links_t > & rhs) const
default

Equality operator.

Parameters
rhsis the mask to be compared
Returns
a boolean if the values and links are equal.

◆ operator[]() [1/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::operator[] ( const std::size_t value_index) ->scalar_type &
constexpr

Subscript operator - non-const.

Parameters
value_indexIndex of the boundary value to access.
Returns
the reference to the member variable

◆ operator[]() [2/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::operator[] ( const std::size_t value_index) const->scalar_type
constexpr

Subscript operator - const.

Parameters
value_indexIndex of the boundary value to access.
Returns
a copy of the member variable

◆ resolve() [1/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
template<concepts::point point_t>
result_type detray::mask< shape_t, algebra_t, links_t >::resolve ( const point_t & loc_p,
const scalar_type tol = std::numeric_limits<scalar_type>::epsilon(),
const scalar_type edge_tol = 0.f ) const
constexpr

Mask this shape onto a surface.

Note
the point is expected to be given in local coordinates and to lie on the underlying surface geometry. For the projection from global to local coordinates, the method to_local_frame() can be used. To check that a point lies on the surface, use the corresponding intersector.
Parameters
loc_pthe point to be checked in the local system (2D or 3D)
toldynamic tolerance determined by caller
edge_toltolerance that allows for an edge around the mask
Returns
a mask check result (contains checks with and without edges)

◆ resolve() [2/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
result_type detray::mask< shape_t, algebra_t, links_t >::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
constexpr
Parameters
trfthe (contextual) surface transform
glob_pthe point to be checked in the global cartesian system
toldynamic tolerance determined by caller
edge_toltolerance that allows for an edge around the mask
Returns
a mask check result (contains checks with and without edges)

◆ self_check()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
bool detray::mask< shape_t, algebra_t, links_t >::self_check ( std::ostream & os) const
constexpr
Parameters
osStream that receives consistency diagnostics.
Returns
true if the mask boundary values are consistent

◆ to_global_frame() [1/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::to_global_frame ( const transform3_type & trf,
const point2_type & loc,
const vector3_type & dir ) const->point3_type
constexpr
Parameters
trfTransform from the local surface frame to global coordinates.
locPoint in the local two-dimensional frame.
dirDirection used to resolve the three-dimensional point.
Returns
the global point for a 2D local position on the surface

◆ to_global_frame() [2/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
constexpr auto detray::mask< shape_t, algebra_t, links_t >::to_global_frame ( const transform3_type & trf,
const point3_type & loc )->point3_type
staticconstexpr
Parameters
trfTransform from the local surface frame to global coordinates.
locPoint in the local three-dimensional frame.
Returns
the global point for a 3D local position on the surface

◆ to_local_frame()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
constexpr auto detray::mask< shape_t, algebra_t, links_t >::to_local_frame ( const transform3_type & trf,
const point3_type & glob_p,
const point3_type & glob_dir = {} )->point2_type
staticconstexpr
Parameters
trfTransform from the local surface frame to global coordinates.
glob_pGlobal point to project into the local frame.
glob_dirDirection associated with the global point.
Returns
the global point projected onto the surface (2D)

◆ to_local_frame3D()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
constexpr auto detray::mask< shape_t, algebra_t, links_t >::to_local_frame3D ( const transform3_type & trf,
const point3_type & glob_p,
const point3_type & glob_dir = {} )->point3_type
staticconstexpr
Parameters
trfTransform from the local surface frame to global coordinates.
glob_pGlobal point to project into the local frame.
glob_dirDirection associated with the global point.
Returns
the global point projected onto the surface (3D)

◆ to_string()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::to_string ( ) const->std::string
Returns
a string representation of the mask

◆ values()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::values ( ) const->constmask_values &
Returns
the boundary values

◆ vertices()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::vertices ( const dindex n_seg) const->dvector< point3_type >

Vertices of the mask in local cartesian coordinates.

Computes vertices along the mask boundary.

Parameters
n_segthe number of segments in for arcs
Returns
a vector of vertices.

◆ volume()

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
template<typename S = shape_t>
requires (S::dim == 3)
auto detray::mask< shape_t, algebra_t, links_t >::volume ( ) const->scalar_type
constexpr
Returns
the area the mask defines on the local geometry (3D)

◆ volume_link() [1/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::volume_link ( ) ->links_type &
Returns
the volume link - non-const access

◆ volume_link() [2/2]

template<typename shape_t, concepts::algebra algebra_t, typename links_t = std::uint_least16_t>
auto detray::mask< shape_t, algebra_t, links_t >::volume_link ( ) const->constlinks_type &
Returns
the volume link - const reference