Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:23:59

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 // Project include(s)
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/coordinates/cartesian2D.hpp"
0017 #include "detray/geometry/detail/shape_utils.hpp"
0018 
0019 // System include(s)
0020 #include <limits>
0021 #include <ostream>
0022 #include <string_view>
0023 
0024 namespace detray {
0025 
0026 /// @brief Generic shape without boundaries.
0027 template <std::size_t DIM = 2>
0028 class unmasked {
0029  public:
0030   /// The name for this shape
0031   static constexpr std::string_view name = "unmasked";
0032 
0033   enum boundaries : unsigned int { e_size = 1u };
0034 
0035   /// Container definition for the shape boundary values
0036   template <concepts::scalar scalar_t>
0037   using bounds_type = darray<scalar_t, boundaries::e_size>;
0038 
0039   /// Local coordinate frame for boundary checks
0040   template <concepts::algebra algebra_t>
0041   using local_frame_type = cartesian2D<algebra_t>;
0042 
0043   /// Result type of a boundary check
0044   template <typename bool_t>
0045   using result_type = bool_t;
0046 
0047   /// Dimension of the local coordinate system
0048   static constexpr std::size_t dim{DIM};
0049 
0050   /// @brief Find the minimum distance to any boundary.
0051   ///
0052   /// @note the point is expected to be given in local coordinates by the
0053   /// caller.
0054   ///
0055   /// @param bounds the boundary values for this shape
0056   /// @param loc_p the point to be checked in the local coordinate system
0057   ///
0058   /// @return the minimum distance.
0059   template <concepts::scalar scalar_t, concepts::point point_t>
0060   DETRAY_HOST_DEVICE inline scalar_t min_dist_to_boundary(
0061       const bounds_type<scalar_t>& /*bounds*/, const point_t& /*loc_p*/) const {
0062     return std::numeric_limits<scalar_t>::max();
0063   }
0064 
0065   /// @brief Check boundary values for a local point.
0066   ///
0067   /// @tparam bounds_t any type of boundary values
0068   ///
0069   /// @note the parameters are ignored
0070   ///
0071   /// @return always true
0072   /// @{
0073   template <concepts::algebra algebra_t>
0074   DETRAY_HOST_DEVICE constexpr dbool<algebra_t> check_boundaries(
0075       const bounds_type<dscalar<algebra_t>>& /*bounds*/,
0076       const dtransform3D<algebra_t>& /*trf*/,
0077       const dpoint3D<algebra_t>& /*glob_p*/,
0078       const dscalar<algebra_t> /*tol*/ = 0.f,
0079       const dscalar<algebra_t> /*edge_tol*/ = 0.f) const {
0080     return true;
0081   }
0082 
0083   template <concepts::scalar scalar_t, concepts::point point_t>
0084   DETRAY_HOST_DEVICE constexpr auto check_boundaries(
0085       const bounds_type<scalar_t>& /*bounds*/, const point_t& /*loc_p*/,
0086       const scalar_t tol = 0.f, const scalar_t edge_tol = 0.f) const
0087       -> decltype(tol < edge_tol) {
0088     return true;
0089   }
0090   /// @}
0091 
0092   /// @brief Measure of the shape: Inf
0093   ///
0094   /// @param bounds the boundary values for this shape
0095   ///
0096   /// @returns Inf.
0097   template <concepts::scalar scalar_t>
0098   DETRAY_HOST_DEVICE constexpr scalar_t measure(
0099       const bounds_type<scalar_t>& bounds) const {
0100     if constexpr (dim == 2) {
0101       return area(bounds);
0102     } else {
0103       return volume(bounds);
0104     }
0105   }
0106 
0107   /// @brief The area of a the shape
0108   ///
0109   /// @param bounds the boundary values for this shape
0110   ///
0111   /// @returns the stereo annulus area.
0112   template <concepts::scalar scalar_t>
0113   DETRAY_HOST_DEVICE constexpr scalar_t area(
0114       const bounds_type<scalar_t>& /*unused*/) const {
0115     return std::numeric_limits<scalar_t>::max();
0116   }
0117 
0118   /// @brief The volume of a the shape
0119   ///
0120   /// @param bounds the boundary values for this shape
0121   ///
0122   /// @returns Inf.
0123   template <concepts::scalar scalar_t>
0124   DETRAY_HOST_DEVICE constexpr scalar_t volume(
0125       const bounds_type<scalar_t>& /*unused*/) const {
0126     return std::numeric_limits<scalar_t>::max();
0127   }
0128 
0129   /// @brief Merge two unmasked shapes
0130   ///
0131   /// @param bounds the boundary values for this shape
0132   /// @param o_bounds the boundary values for the other shape
0133   ///
0134   /// @returns merged bound values
0135   template <concepts::scalar scalar_t>
0136   DETRAY_HOST_DEVICE constexpr bounds_type<scalar_t> merge(
0137       const bounds_type<scalar_t>& /*bounds*/,
0138       const bounds_type<scalar_t>& /*o_bounds*/) const {
0139     return {};
0140   }
0141 
0142   /// @brief Lower and upper point for minimal axis aligned bounding box.
0143   ///
0144   /// Computes the min and max vertices in a local cartesian frame.
0145   ///
0146   /// @param bounds the boundary values for this shape
0147   /// @param env dynamic envelope around the shape
0148   ///
0149   /// @returns and array of coordinates that contains the lower point (first
0150   /// three values) and the upper point (latter three values) .
0151   template <concepts::algebra algebra_t>
0152   DETRAY_HOST_DEVICE inline darray<dscalar<algebra_t>, 6> local_min_bounds(
0153       const bounds_type<dscalar<algebra_t>>& /*bounds*/,
0154       const dscalar<algebra_t> /*env*/ =
0155           std::numeric_limits<dscalar<algebra_t>>::epsilon()) const {
0156     using scalar_t = dscalar<algebra_t>;
0157     constexpr scalar_t inv{detail::invalid_value<scalar_t>()};
0158 
0159     return {-inv, -inv, -inv, inv, inv, inv};
0160   }
0161 
0162   /// @returns the shapes centroid in global cartesian coordinates
0163   template <concepts::algebra algebra_t>
0164   DETRAY_HOST_DEVICE dpoint3D<algebra_t> centroid(
0165       const bounds_type<dscalar<algebra_t>>& /*unused*/) const {
0166     return {0.f, 0.f, 0.f};
0167   }
0168 
0169   /// Generate vertices in local cartesian frame
0170   ///
0171   /// @param bounds the boundary values
0172   /// @param n_seg is the number of line segments
0173   ///
0174   /// @return a generated list of vertices
0175   template <concepts::algebra algebra_t>
0176   DETRAY_HOST dvector<dpoint3D<algebra_t>> vertices(
0177       const bounds_type<dscalar<algebra_t>>& bounds, dindex /*unused*/) const {
0178     return local_min_bounds(bounds);
0179   }
0180 
0181   /// @brief Check consistency of boundary values.
0182   ///
0183   /// @param bounds the boundary values for this shape
0184   /// @param os output stream for error messages
0185   ///
0186   /// @return true if the bounds are consistent.
0187   template <concepts::scalar scalar_t>
0188   DETRAY_HOST constexpr bool check_consistency(
0189       const bounds_type<scalar_t>& /*bounds*/,
0190       const std::ostream& /*os*/) const {
0191     return true;
0192   }
0193 };
0194 
0195 }  // namespace detray