12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/containers.hpp"
14#include "detray/definitions/detail/qualifiers.hpp"
15#include "detray/definitions/indexing.hpp"
16#include "detray/definitions/math.hpp"
17#include "detray/geometry/coordinates/cartesian2D.hpp"
18#include "detray/geometry/coordinates/cartesian3D.hpp"
19#include "detray/geometry/detail/shape_utils.hpp"
33template <
unsigned int kCheckIndex = 0u>
37 static constexpr std::string_view
name =
"single3D";
47 template <concepts::scalar scalar_t>
51 template <concepts::algebra algebra_t>
55 template <
typename bool_t>
59 static constexpr std::size_t
dim{1u};
70 template <concepts::scalar scalar_t, concepts::po
int po
int_t>
73 return math::min(math::fabs(loc_p[kCheckIndex] - bounds[e_lower]),
74 math::fabs(bounds[e_upper] - loc_p[kCheckIndex]));
87 template <concepts::algebra algebra_t>
111 template <concepts::scalar scalar_t, concepts::po
int po
int_t>
114 const scalar_t tol = std::numeric_limits<scalar_t>::epsilon(),
115 const scalar_t edge_tol = 0.f)
const {
116 auto inside_mask{(bounds[e_lower] - tol <= loc_p[kCheckIndex] &&
117 loc_p[kCheckIndex] <= bounds[e_upper] + tol)};
119 decltype(inside_mask) inside_edge{
false};
120 if (detail::any_of(edge_tol > 0.f)) {
121 const scalar_t full_tol{tol + edge_tol};
123 inside_edge = (bounds[e_lower] - full_tol <= loc_p[kCheckIndex] &&
124 loc_p[kCheckIndex] <= bounds[e_upper] + full_tol);
127 return result_type<
decltype(inside_mask)>{inside_mask, inside_edge};
136 template <concepts::scalar scalar_t>
137 DETRAY_HOST_DEVICE
constexpr scalar_t
measure(
147 template <concepts::scalar scalar_t>
148 DETRAY_HOST_DEVICE
constexpr scalar_t
area(
150 return math::fabs(bounds[e_upper] - bounds[e_lower]);
159 template <concepts::scalar scalar_t>
165 new_bounds[e_lower] = math::min(bounds[e_lower], o_bounds[e_lower]);
166 new_bounds[e_upper] = math::max(bounds[e_upper], o_bounds[e_upper]);
180 template <concepts::algebra algebra_t>
187 o_bounds[kCheckIndex] += bounds[e_lower];
188 o_bounds[3u + kCheckIndex] += bounds[e_upper];
194 template <concepts::algebra algebra_t>
199 point3_t centr{0.f, 0.f, 0.f};
200 centr[kCheckIndex] = 0.5f * (bounds[e_lower] + bounds[e_upper]);
210 template <concepts::algebra algebra_t>
214 throw std::runtime_error(
215 "Vertex generation for single value shapes is not implemented");
225 template <concepts::scalar scalar_t>
228 if (bounds[e_upper] < bounds[e_lower]) {
229 os <<
"DETRAY ERROR (HOST): Upper bounds must be smaller than "
Underlying geometry for a single parameter bound mask.
Definition single3D.hpp:34
dvector< dpoint3D< algebra_t > > vertices(const bounds_type< dscalar< algebra_t > > &, dindex) const
Generate vertices in local cartesian frame.
Definition single3D.hpp:211
constexpr scalar_t area(const bounds_type< scalar_t > &bounds) const
The area of a the shape.
Definition single3D.hpp:148
scalar_t min_dist_to_boundary(const bounds_type< scalar_t > &bounds, const point_t &loc_p) const
Find the minimum distance to any boundary.
Definition single3D.hpp:71
static constexpr std::size_t dim
Dimension of the local coordinate system.
Definition single3D.hpp:59
darray< scalar_t, boundaries::e_size > bounds_type
Container definition for the shape boundary values.
Definition single3D.hpp:48
constexpr scalar_t measure(const bounds_type< scalar_t > &bounds) const
Measure of the shape: Range.
Definition single3D.hpp:137
detail::boundary_check_result< bool_t > result_type
Result type of a boundary check.
Definition single3D.hpp:56
auto centroid(const bounds_type< dscalar< algebra_t > > &bounds) const
Definition single3D.hpp:195
constexpr auto check_boundaries(const bounds_type< scalar_t > &bounds, const point_t &loc_p, const scalar_t tol=std::numeric_limits< scalar_t >::epsilon(), const scalar_t edge_tol=0.f) const
Definition single3D.hpp:112
constexpr result_type< dbool< algebra_t > > check_boundaries(const bounds_type< dscalar< algebra_t > > &bounds, const dtransform3D< algebra_t > &trf, const dpoint3D< algebra_t > &glob_p, const dscalar< algebra_t > tol=std::numeric_limits< dscalar< algebra_t > >::epsilon(), const dscalar< algebra_t > edge_tol=0.f) const
Check boundary values for a local point.
Definition single3D.hpp:88
boundaries
Indices describing the entries in the shape boundary array.
Definition single3D.hpp:40
cartesian2D< algebra_t > local_frame_type
Local coordinate frame for boundary checks.
Definition single3D.hpp:52
constexpr bool check_consistency(const bounds_type< scalar_t > &bounds, std::ostream &os) const
Check consistency of boundary values.
Definition single3D.hpp:226
darray< dscalar< algebra_t >, 6 > local_min_bounds(const bounds_type< dscalar< algebra_t > > &bounds, const dscalar< algebra_t > env=std::numeric_limits< dscalar< algebra_t > >::epsilon()) const
Lower and upper point for minimal axis aligned bounding box.
Definition single3D.hpp:181
static constexpr std::string_view name
The name for this shape.
Definition single3D.hpp:37
constexpr bounds_type< scalar_t > merge(const bounds_type< scalar_t > &bounds, const bounds_type< scalar_t > &o_bounds) const
Merge two 'single' shapes.
Definition single3D.hpp:160
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
std::array< value_t, kDIM > darray
Fixed-size array container.
Definition containers.hpp:30
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
Projection into a 2D cartesian coordinate frame.
Definition cartesian2D.hpp:19
static loc_point global_to_local(const transform3_type &trf, const point3_type &p, const vector3_type &)
This method transforms a point from a global cartesian 3D frame to a local 3D cartesian point Convert...
Definition cartesian3D.hpp:57