ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
unbounded.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
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/geometry/detail/shape_utils.hpp"
17#include "detray/utils/string_helpers.hpp"
18
19// System include(s)
20#include <limits>
21#include <ostream>
22#include <string>
23#include <string_view>
24
25namespace detray {
26
28template <typename shape_t>
29class unbounded {
30 public:
32 using shape = shape_t;
34 using boundaries = typename shape::boundaries;
35
37 template <concepts::scalar scalar_t>
39
41 static constexpr std::string_view name_prefix = "unbounded ";
42
44 static constexpr utils::string_view_concat2 name{name_prefix, shape::name};
45
47 template <concepts::algebra algebra_t>
48 using local_frame_type = typename shape::template local_frame_type<algebra_t>;
49
51 template <typename bool_t>
52 using result_type = detail::boundary_check_result<bool_t>;
53
55 static constexpr std::size_t dim{shape_t::dim};
56
63 template <concepts::scalar scalar_t, concepts::point point_t>
64 DETRAY_HOST_DEVICE constexpr scalar_t min_dist_to_boundary(
65 const bounds_type<scalar_t>& /*bounds*/, const point_t& /*loc_p*/) const {
66 return std::numeric_limits<scalar_t>::max();
67 }
68
77 template <concepts::algebra algebra_t>
78 DETRAY_HOST_DEVICE constexpr result_type<dbool<algebra_t>> check_boundaries(
79 const bounds_type<dscalar<algebra_t>>& /*bounds*/,
80 const dtransform3D<algebra_t>& /*trf*/,
81 const dpoint3D<algebra_t>& /*glob_p*/,
82 const dscalar<algebra_t> /*tol*/ = 0.f,
83 const dscalar<algebra_t> /*edge_tol*/ = 0.f) const {
84 if constexpr (std::same_as<result_type<dbool<algebra_t>>,
86 return true;
87 } else {
88 return {true, true};
89 }
90 }
91
96 template <typename bounds_t, concepts::point point_t,
97 concepts::scalar scalar_t>
98 DETRAY_HOST_DEVICE constexpr auto check_boundaries(
99 const bounds_t& /*bounds*/, const point_t& /*loc_p*/,
100 const scalar_t tol = 0.f, const scalar_t edge_tol = 0.f) const {
101 using bool_t = decltype(tol < edge_tol);
102
103 if constexpr (std::same_as<result_type<bool_t>, bool_t>) {
104 return bool_t{true};
105 } else {
106 return result_type<bool_t>{true, true};
107 }
108 }
109
110
116 template <concepts::scalar scalar_t>
117 DETRAY_HOST_DEVICE constexpr scalar_t measure(
118 const bounds_type<scalar_t>& bounds) const {
119 if constexpr (dim == 2) {
120 return area(bounds);
121 } else {
122 return volume(bounds);
123 }
124 }
125
129 template <concepts::scalar scalar_t>
130 DETRAY_HOST_DEVICE constexpr scalar_t area(
131 const bounds_type<scalar_t>& /*unused*/) const {
132 return std::numeric_limits<scalar_t>::max();
133 }
134
138 template <concepts::scalar scalar_t>
139 DETRAY_HOST_DEVICE constexpr scalar_t volume(
140 const bounds_type<scalar_t>& /*unused*/) const {
141 return std::numeric_limits<scalar_t>::max();
142 }
143
147 template <concepts::scalar scalar_t>
148 DETRAY_HOST_DEVICE constexpr bounds_type<scalar_t> merge(
149 const bounds_type<scalar_t>& /*bounds*/,
150 const bounds_type<scalar_t>& /*o_bounds*/) const {
151 return {};
152 }
153
168 template <concepts::algebra algebra_t>
169 DETRAY_HOST_DEVICE inline darray<dscalar<algebra_t>, 6> local_min_bounds(
170 const bounds_type<dscalar<algebra_t>>& bounds,
171 const dscalar<algebra_t> env =
172 std::numeric_limits<dscalar<algebra_t>>::epsilon()) const {
173 return shape{}.template local_min_bounds<algebra_t>(bounds, env);
174 }
175
178 template <concepts::algebra algebra_t>
179 DETRAY_HOST_DEVICE auto centroid(
180 const bounds_type<dscalar<algebra_t>>& bounds) const {
181 return shape{}.template centroid<algebra_t>(bounds);
182 }
183
190 template <concepts::algebra algebra_t>
192 const bounds_type<dscalar<algebra_t>>& bounds, dindex n_seg) const {
193 return shape{}.template vertices<algebra_t>(bounds, n_seg);
194 }
195
199 template <concepts::scalar scalar_t>
200 DETRAY_HOST constexpr bool check_consistency(
201 const bounds_type<scalar_t>& /*bounds*/,
202 const std::ostream& /*os*/) const {
203 return true;
204 }
205};
206
207} // namespace detray
Wraps any shape, but does not enforce boundaries.
Definition unbounded.hpp:29
constexpr scalar_t volume(const bounds_type< scalar_t > &) const
The volume of a the shape.
Definition unbounded.hpp:139
constexpr bounds_type< scalar_t > merge(const bounds_type< scalar_t > &, const bounds_type< scalar_t > &) const
Merge two unbounded shapes.
Definition unbounded.hpp:148
constexpr scalar_t measure(const bounds_type< scalar_t > &bounds) const
Measure of the shape: Inf.
Definition unbounded.hpp:117
detail::boundary_check_result< bool_t > result_type
Result type of a boundary check.
Definition unbounded.hpp:52
typename shape::boundaries boundaries
Boundary index enum inherited from the wrapped shape.
Definition unbounded.hpp:34
static constexpr std::string_view name_prefix
Convenience member to construct the name.
Definition unbounded.hpp:41
typename shape::template local_frame_type< algebra_t > local_frame_type
Local coordinate frame for boundary checks.
Definition unbounded.hpp:48
constexpr scalar_t area(const bounds_type< scalar_t > &) const
The area of a the shape.
Definition unbounded.hpp:130
constexpr result_type< dbool< algebra_t > > check_boundaries(const bounds_type< dscalar< algebra_t > > &, const dtransform3D< algebra_t > &, const dpoint3D< algebra_t > &, const dscalar< algebra_t >=0.f, const dscalar< algebra_t >=0.f) const
Check boundary values for a local point.
Definition unbounded.hpp:78
constexpr auto check_boundaries(const bounds_t &, const point_t &, const scalar_t tol=0.f, const scalar_t edge_tol=0.f) const
Return an inside result for a point supplied in local coordinates.
Definition unbounded.hpp:98
darray< scalar_t, boundaries::e_size > bounds_type
Container definition for the shape boundary values.
Definition unbounded.hpp:38
dvector< dpoint3D< algebra_t > > vertices(const bounds_type< dscalar< algebra_t > > &bounds, dindex n_seg) const
Generate vertices in local cartesian frame.
Definition unbounded.hpp:191
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 unbounded.hpp:169
static constexpr std::size_t dim
Dimension of the local coordinate system.
Definition unbounded.hpp:55
static constexpr utils::string_view_concat2 name
The name for this shape.
Definition unbounded.hpp:44
shape_t shape
Wrapped shape whose boundary checks always accept a point.
Definition unbounded.hpp:32
auto centroid(const bounds_type< dscalar< algebra_t > > &bounds) const
Definition unbounded.hpp:179
constexpr bool check_consistency(const bounds_type< scalar_t > &, const std::ostream &) const
Check consistency of boundary values.
Definition unbounded.hpp:200
constexpr scalar_t min_dist_to_boundary(const bounds_type< scalar_t > &, const point_t &) const
Find the minimum distance to any boundary.
Definition unbounded.hpp:64
Point concepts.
Definition concepts.hpp:71
Scalar concept: Elements of vectors/matrices (can be simd vectors).
Definition concepts.hpp:40
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
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
Convenience class to statically concatenate two string views.
Definition string_helpers.hpp:22