File indexing completed on 2026-05-27 07:23:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/definitions/containers.hpp"
0014 #include "detray/definitions/detail/qualifiers.hpp"
0015 #include "detray/definitions/indexing.hpp"
0016 #include "detray/geometry/detail/shape_utils.hpp"
0017 #include "detray/utils/string_helpers.hpp"
0018
0019
0020 #include <limits>
0021 #include <ostream>
0022 #include <string>
0023 #include <string_view>
0024
0025 namespace detray {
0026
0027
0028 template <typename shape_t>
0029 class unbounded {
0030 public:
0031 using shape = shape_t;
0032 using boundaries = typename shape::boundaries;
0033
0034
0035 template <concepts::scalar scalar_t>
0036 using bounds_type = darray<scalar_t, boundaries::e_size>;
0037
0038
0039 static constexpr std::string_view name_prefix = "unbounded ";
0040
0041
0042 static constexpr utils::string_view_concat2 name{name_prefix, shape::name};
0043
0044
0045 template <concepts::algebra algebra_t>
0046 using local_frame_type = typename shape::template local_frame_type<algebra_t>;
0047
0048
0049 template <typename bool_t>
0050 using result_type = detail::boundary_check_result<bool_t>;
0051
0052
0053 static constexpr std::size_t dim{shape_t::dim};
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 template <concepts::scalar scalar_t, concepts::point point_t>
0065 DETRAY_HOST_DEVICE constexpr scalar_t min_dist_to_boundary(
0066 const bounds_type<scalar_t>& , const point_t& ) const {
0067 return std::numeric_limits<scalar_t>::max();
0068 }
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 template <concepts::algebra algebra_t>
0079 DETRAY_HOST_DEVICE constexpr result_type<dbool<algebra_t>> check_boundaries(
0080 const bounds_type<dscalar<algebra_t>>& ,
0081 const dtransform3D<algebra_t>& ,
0082 const dpoint3D<algebra_t>& ,
0083 const dscalar<algebra_t> = 0.f,
0084 const dscalar<algebra_t> = 0.f) const {
0085 if constexpr (std::same_as<result_type<dbool<algebra_t>>,
0086 dbool<algebra_t>>) {
0087 return true;
0088 } else {
0089 return {true, true};
0090 }
0091 }
0092
0093 template <typename bounds_t, concepts::point point_t,
0094 concepts::scalar scalar_t>
0095 DETRAY_HOST_DEVICE constexpr auto check_boundaries(
0096 const bounds_t& , const point_t& ,
0097 const scalar_t tol = 0.f, const scalar_t edge_tol = 0.f) const {
0098 using bool_t = decltype(tol < edge_tol);
0099
0100 if constexpr (std::same_as<result_type<bool_t>, bool_t>) {
0101 return bool_t{true};
0102 } else {
0103 return result_type<bool_t>{true, true};
0104 }
0105 }
0106
0107
0108
0109
0110
0111
0112
0113 template <concepts::scalar scalar_t>
0114 DETRAY_HOST_DEVICE constexpr scalar_t measure(
0115 const bounds_type<scalar_t>& bounds) const {
0116 if constexpr (dim == 2) {
0117 return area(bounds);
0118 } else {
0119 return volume(bounds);
0120 }
0121 }
0122
0123
0124
0125
0126
0127
0128 template <concepts::scalar scalar_t>
0129 DETRAY_HOST_DEVICE constexpr scalar_t area(
0130 const bounds_type<scalar_t>& ) const {
0131 return std::numeric_limits<scalar_t>::max();
0132 }
0133
0134
0135
0136
0137
0138
0139 template <concepts::scalar scalar_t>
0140 DETRAY_HOST_DEVICE constexpr scalar_t volume(
0141 const bounds_type<scalar_t>& ) const {
0142 return std::numeric_limits<scalar_t>::max();
0143 }
0144
0145
0146
0147
0148
0149
0150
0151 template <concepts::scalar scalar_t>
0152 DETRAY_HOST_DEVICE constexpr bounds_type<scalar_t> merge(
0153 const bounds_type<scalar_t>& ,
0154 const bounds_type<scalar_t>& ) const {
0155 return {};
0156 }
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173 template <concepts::algebra algebra_t>
0174 DETRAY_HOST_DEVICE inline darray<dscalar<algebra_t>, 6> local_min_bounds(
0175 const bounds_type<dscalar<algebra_t>>& bounds,
0176 const dscalar<algebra_t> env =
0177 std::numeric_limits<dscalar<algebra_t>>::epsilon()) const {
0178 return shape{}.template local_min_bounds<algebra_t>(bounds, env);
0179 }
0180
0181
0182 template <concepts::algebra algebra_t>
0183 DETRAY_HOST_DEVICE auto centroid(
0184 const bounds_type<dscalar<algebra_t>>& bounds) const {
0185 return shape{}.template centroid<algebra_t>(bounds);
0186 }
0187
0188
0189
0190
0191
0192
0193
0194 template <concepts::algebra algebra_t>
0195 DETRAY_HOST dvector<dpoint3D<algebra_t>> vertices(
0196 const bounds_type<dscalar<algebra_t>>& bounds, dindex n_seg) const {
0197 return shape{}.template vertices<algebra_t>(bounds, n_seg);
0198 }
0199
0200
0201
0202
0203
0204
0205
0206 template <concepts::scalar scalar_t>
0207 DETRAY_HOST constexpr bool check_consistency(
0208 const bounds_type<scalar_t>& ,
0209 const std::ostream& ) const {
0210 return true;
0211 }
0212 };
0213
0214 }