|
|
|||
File indexing completed on 2025-10-29 07:53:41
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 #include "Acts/Definitions/Algebra.hpp" 0012 #include "Acts/Geometry/BoundarySurfaceFace.hpp" 0013 #include "Acts/Geometry/Volume.hpp" 0014 #include "Acts/Geometry/VolumeBounds.hpp" 0015 #include "Acts/Utilities/AxisDefinitions.hpp" 0016 #include "Acts/Utilities/BoundingBox.hpp" 0017 0018 #include <array> 0019 #include <cmath> 0020 #include <cstddef> 0021 #include <iomanip> 0022 #include <iosfwd> 0023 #include <memory> 0024 #include <ostream> 0025 #include <stdexcept> 0026 #include <vector> 0027 0028 namespace Acts { 0029 0030 class RectangleBounds; 0031 0032 /// @class CuboidVolumeBounds 0033 /// 0034 /// Bounds for a cubical Volume, the orientedSurfaces(...) method creates a 0035 /// vector of 6 surfaces: 0036 /// 0037 /// BoundarySurfaceFace [index]: 0038 /// 0039 /// - negativeFaceXY [0] : Rectangular Acts::PlaneSurface, parallel to \f$ xy 0040 /// \f$ plane at negative \f$ z \f$ 0041 /// - positiveFaceXY [1] : Rectangular Acts::PlaneSurface, parallel to \f$ xy 0042 /// \f$ plane at positive \f$ z \f$ 0043 /// - negativeFaceXY [2] : Rectangular Acts::PlaneSurface, attached to \f$ yz 0044 /// \f$ plane at negative \f$ x \f$ 0045 /// - positiveFaceXY [3] : Rectangular Acts::PlaneSurface, attached to \f$ yz 0046 /// \f$ plane at negative \f$ x \f$ 0047 /// - negativeFaceXY [4] : Rectangular Acts::PlaneSurface, parallel to \f$ zx 0048 /// \f$ plane at negative \f$ y \f$ 0049 /// - positiveFaceXY [5] : Rectangular Acts::PlaneSurface, parallel to \f$ zx 0050 /// \f$ plane at positive \f$ y \f$ 0051 /// 0052 class CuboidVolumeBounds : public VolumeBounds { 0053 public: 0054 /// @enum BoundValues for streaming and access 0055 enum BoundValues : unsigned int { 0056 eHalfLengthX = 0, 0057 eHalfLengthY = 1, 0058 eHalfLengthZ = 2, 0059 eSize 0060 }; 0061 0062 /// Enum describing the possible faces of a cuboid volume 0063 /// @note These values are synchronized with the BoundarySurfaceFace enum. 0064 /// Once Gen1 is removed, this can be changed. 0065 enum class Face : unsigned int { 0066 NegativeZFace = BoundarySurfaceFace::negativeFaceXY, 0067 PositiveZFace = BoundarySurfaceFace::positiveFaceXY, 0068 NegativeXFace = BoundarySurfaceFace::negativeFaceYZ, 0069 PositiveXFace = BoundarySurfaceFace::positiveFaceYZ, 0070 NegativeYFace = BoundarySurfaceFace::negativeFaceZX, 0071 PositiveYFace = BoundarySurfaceFace::positiveFaceZX 0072 }; 0073 0074 CuboidVolumeBounds() = delete; 0075 0076 /// Constructor - the box boundaries 0077 /// 0078 /// @param halex is the half length of the cube in x 0079 /// @param haley is the half length of the cube in y 0080 /// @param halez is the half length of the cube in z 0081 CuboidVolumeBounds(double halex, double haley, double halez) noexcept(false); 0082 0083 /// Constructor - from a fixed size array 0084 /// 0085 /// @param values iw the bound values 0086 explicit CuboidVolumeBounds(const std::array<double, eSize>& values); 0087 0088 /// Constructor with initializer list of key-value pairs 0089 /// @param keyValues List of bound value identifiers and their corresponding values 0090 CuboidVolumeBounds( 0091 std::initializer_list<std::pair<BoundValues, double>> keyValues); 0092 0093 /// Copy Constructor 0094 /// 0095 /// @param bobo is the source volume bounds to be copied 0096 CuboidVolumeBounds(const CuboidVolumeBounds& bobo) = default; 0097 0098 /// Assignment operator 0099 /// 0100 /// @param bobo is the source volume bounds to be assigned 0101 /// @return Reference to this object after assignment 0102 CuboidVolumeBounds& operator=(const CuboidVolumeBounds& bobo) = default; 0103 0104 ~CuboidVolumeBounds() override = default; 0105 0106 VolumeBounds::BoundsType type() const final { return VolumeBounds::eCuboid; } 0107 0108 /// Return the bound values as dynamically sized vector 0109 /// 0110 /// @return this returns a copy of the internal values 0111 std::vector<double> values() const final; 0112 0113 /// This method checks if position in the 3D volume 0114 /// frame is inside the cylinder 0115 /// 0116 /// @param pos is the position in volume frame to be checked 0117 /// @param tol is the absolute tolerance to be applied 0118 /// @return True if the position is inside the cuboid bounds 0119 bool inside(const Vector3& pos, double tol = 0.) const override; 0120 0121 /// Oriented surfaces, i.e. the decomposed boundary surfaces and the 0122 /// according navigation direction into the volume given the normal 0123 /// vector on the surface 0124 /// 0125 /// @param transform is the 3D transform to be applied to the boundary 0126 /// surfaces to position them in 3D space 0127 /// 0128 /// It will throw an exception if the orientation prescription is not adequate 0129 /// 0130 /// @return a vector of surfaces bounding this volume 0131 std::vector<OrientedSurface> orientedSurfaces( 0132 const Transform3& transform = Transform3::Identity()) const override; 0133 0134 /// Construct bounding box for this shape 0135 /// @param trf Optional transform 0136 /// @param envelope Optional envelope to add / subtract from min/max 0137 /// @param entity Entity to associate this bounding box with 0138 /// @return Constructed bounding box 0139 Volume::BoundingBox boundingBox(const Transform3* trf = nullptr, 0140 const Vector3& envelope = {0, 0, 0}, 0141 const Volume* entity = nullptr) const final; 0142 0143 /// Get the canonical binning direction, i.e. the binning directions 0144 /// for that fully describe the shape's extent 0145 /// 0146 /// @return vector of canonical binning values 0147 std::vector<AxisDirection> canonicalAxes() const override { 0148 using enum AxisDirection; 0149 return {AxisX, AxisY, AxisZ}; 0150 }; 0151 0152 /// Binning borders in double 0153 /// 0154 /// @param aDir is the axis direction for which the 0155 /// reference border is requested 0156 /// 0157 /// @return float offset to be used for the binning 0158 double referenceBorder(AxisDirection aDir) const final; 0159 0160 /// Access to the bound values 0161 /// @param bValue the class nested enum for the array access 0162 /// @return The requested bound value 0163 double get(BoundValues bValue) const { return m_values[bValue]; } 0164 0165 /// Set a bound value 0166 /// @param bValue the bound value identifier 0167 /// @param value the value to be set 0168 void set(BoundValues bValue, double value); 0169 0170 /// Set a range of bound values 0171 /// @param keyValues the initializer list of key value pairs 0172 void set(std::initializer_list<std::pair<BoundValues, double>> keyValues); 0173 0174 /// Convert axis direction to a corresponding bound value 0175 /// in local coordinate convention 0176 /// @param direction the axis direction to convert 0177 /// @return The bound value corresponding to the axis direction 0178 static BoundValues boundsFromAxisDirection(AxisDirection direction); 0179 0180 /// Convert axis direction to a set of corresponding cuboid faces 0181 /// in local coordinate convention 0182 /// @param direction the axis direction to convert 0183 /// @return A tuple of cuboid faces with the following ordering convention: 0184 /// (1) negative face orthogonal to the axis direction 0185 /// (2) positive face orthogonal to the axis direction 0186 /// (3) list of side faces parallel to the axis direction 0187 static std::tuple<Face, Face, std::array<Face, 4>> facesFromAxisDirection( 0188 AxisDirection direction); 0189 0190 /// Output Method for std::ostream 0191 /// 0192 /// @param os is ostream operator to be dumped into 0193 /// @return Reference to the output stream after writing 0194 std::ostream& toStream(std::ostream& os) const override; 0195 0196 private: 0197 /// The bound values ordered in a fixed size array 0198 std::array<double, eSize> m_values; 0199 0200 std::shared_ptr<const RectangleBounds> m_xyBounds{nullptr}; 0201 std::shared_ptr<const RectangleBounds> m_yzBounds{nullptr}; 0202 std::shared_ptr<const RectangleBounds> m_zxBounds{nullptr}; 0203 0204 /// Create the surface bounds 0205 void buildSurfaceBounds(); 0206 0207 /// Check the input values for consistency, 0208 /// will throw a logic_exception if consistency is not given 0209 void checkConsistency() noexcept(false); 0210 }; 0211 0212 std::ostream& operator<<(std::ostream& os, CuboidVolumeBounds::Face face); 0213 0214 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|