|
|
|||
File indexing completed on 2026-08-02 08:44:27
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/GeometryContext.hpp" 0013 #include "Acts/Geometry/GeometryObject.hpp" 0014 #include "Acts/Geometry/VolumePlacementBase.hpp" 0015 #include "Acts/Utilities/BoundingBox.hpp" 0016 #include "Acts/Utilities/CloneablePtr.hpp" 0017 #include "Acts/Utilities/Logger.hpp" 0018 0019 #include <iosfwd> 0020 #include <memory> 0021 #include <optional> 0022 0023 namespace Acts { 0024 0025 class VolumeBounds; 0026 0027 /// @class Volume 0028 /// 0029 /// It inherits from GeometryObject for geometry identification 0030 /// 0031 /// Base class for all volumes inside the tracking realm, it defines the 0032 /// interface for inherited Volume classes regarding the geometrical 0033 /// information. 0034 class Volume : public GeometryObject { 0035 public: 0036 /// Type alias for the axis-aligned bounding box of the volume 0037 /// @details Used to define the spatial extent of the volume in 3D space 0038 using BoundingBox = AxisAlignedBoundingBox<Volume, double, 3>; 0039 0040 /// Explicit constructor with shared arguments 0041 /// 0042 /// @param transform is the transform to position the volume in 3D space 0043 /// @param volbounds is the volume boundary definitions 0044 Volume(const Transform3& transform, 0045 std::shared_ptr<VolumeBounds> volbounds) noexcept; 0046 /// Constructor that connects the volume to an external alignment 0047 /// I.e. the volume may move with the alignment of the surfaces 0048 /// The placement of the volume is delegated to the positioner 0049 /// @param positioner: Reference to the object aligning the volume 0050 /// @param volbounds is the volume boundary definitions 0051 Volume(VolumePlacementBase& positioner, 0052 std::shared_ptr<VolumeBounds> volbounds) noexcept; 0053 0054 /// Copy Constructor 0055 /// @param vol is the source volume for the copy 0056 Volume(const Volume& vol) noexcept = default; 0057 0058 /// Copy Constructor with optional shift 0059 /// 0060 /// @param vol is the source volume for the copy 0061 /// @param shift is the optional shift applied as : shift * vol.transform() 0062 /// @deprecated: Constructor deprecated in favour of shifted(const Transform3& shift) const 0063 [[deprecated("Use Volume::shifted(const Transform3& shift) const instead.")]] 0064 Volume(const Volume& vol, const Transform3& shift); 0065 0066 /// Shift the volume by a transform 0067 /// 0068 /// @param shift is the transform to shift the volume by 0069 /// @param gctx The current geometry context object, e.g. alignment 0070 /// @return The shifted volume 0071 Volume shifted(const GeometryContext& gctx, const Transform3& shift) const; 0072 0073 ~Volume() noexcept override = default; 0074 0075 /// Assignment operator 0076 /// 0077 /// @param vol is the source volume to be copied 0078 /// @return Reference to this volume for assignment chaining 0079 Volume& operator=(const Volume& vol) noexcept = default; 0080 0081 /// Move assignment operator 0082 /// 0083 /// @param other is the other volume to be moved 0084 /// @return Reference to this volume for assignment chaining 0085 Volume& operator=(Volume&& other) noexcept = default; 0086 0087 /// Get the transformation matrix from the local volume frame to the global 0088 /// experiment's frame 0089 /// @param gctx The current geometry context object, e.g. alignment 0090 /// @return The local to global transformation matrix 0091 const Transform3& localToGlobalTransform(const GeometryContext& gctx) const; 0092 0093 /// Get the transformation matrix from the global experiment's frame to the 0094 /// local volume frame 0095 /// @param gctx The current geometry context object, e.g. alignment 0096 /// @return The global to local transformation matrix 0097 const Transform3& globalToLocalTransform(const GeometryContext& gctx) const; 0098 0099 /// Get the transform matrix that positions the volume in 3D space 0100 /// @deprecated: Function deprecated in favour of localToGlobalTransform 0101 /// @return Const reference to the transform matrix 0102 [[deprecated( 0103 "Use localToGlobalTransform(const GeometryContext& gctx) instead.")]] 0104 const Transform3& transform() const; 0105 0106 /// Get the inverse transform matrix of the volume 0107 /// @deprecated: Function deprecated in favour of globalToLocalTransform 0108 /// @return Const reference to the inverse transform matrix 0109 [[deprecated( 0110 "Use globalToLocalTransform(const GeometryContext& gctx) instead.")]] 0111 const Transform3& itransform() const; 0112 0113 /// Set the transform matrix for the volume and update internal state 0114 /// @param transform The new transform matrix to be applied 0115 void setTransform(const Transform3& transform); 0116 0117 /// Get the center position of the volume 0118 /// @param gctx The current geometry context object, e.g. alignment 0119 /// @return Const reference to the center position vector 0120 Vector3 center(const GeometryContext& gctx) const; 0121 0122 /// Get the center position of the volume 0123 /// @deprecated: Function deprecated in favour of 0124 /// center(const GeometryContext& gctx) 0125 /// @return Const reference to the center position vector 0126 [[deprecated("Use center(const GeometryContext& gctx) instead.")]] 0127 const Vector3& center() const; 0128 0129 /// Get the volume bounds that define the shape of the volume 0130 /// @return Const reference to the volume bounds object 0131 const VolumeBounds& volumeBounds() const; 0132 0133 /// Get mutable access to the volume bounds 0134 /// @return Reference to the volume bounds object 0135 VolumeBounds& volumeBounds(); 0136 0137 /// Get shared pointer to the const volume bounds 0138 /// @return Const shared pointer to the volume bounds object 0139 std::shared_ptr<const VolumeBounds> volumeBoundsPtr() const; 0140 0141 /// Get shared pointer to the mutable volume bounds 0142 /// @return Shared pointer to the volume bounds object 0143 std::shared_ptr<VolumeBounds> volumeBoundsPtr(); 0144 0145 /// Set volume bounds and update volume bounding boxes implicitly 0146 /// @param volbounds The volume bounds to be assigned 0147 void assignVolumeBounds(std::shared_ptr<VolumeBounds> volbounds); 0148 0149 /// Set the volume bounds and optionally also update the volume transform 0150 /// @param gctx The current geometry context object, e.g. alignment 0151 /// @param volbounds The volume bounds to be assigned 0152 /// @param transform The transform to be assigned, can be optional 0153 /// @param logger A logger object to log messages 0154 virtual void update(const GeometryContext& gctx, 0155 std::shared_ptr<VolumeBounds> volbounds, 0156 std::optional<Transform3> transform = std::nullopt, 0157 const Logger& logger = Acts::getDummyLogger()); 0158 0159 /// Construct bounding box for this shape 0160 /// @param envelope Optional envelope to add / subtract from min/max 0161 /// @return Constructed bounding box pointing to this volume 0162 BoundingBox boundingBox(const Vector3& envelope = {0, 0, 0}) const; 0163 0164 /// Construct oriented bounding box for this shape 0165 /// @note This will build an oriented bounding box with an 0166 /// envelope value of (0.05, 0.05, 0.05)mm 0167 /// @return Constructed oriented bounding box pointing to this volume 0168 BoundingBox orientedBoundingBox() const; 0169 0170 /// Inside() method for checks 0171 /// 0172 /// @param gctx The current geometry context object, e.g. alignment 0173 /// @param gpos is the position to be checked 0174 /// @param tol is the tolerance parameter 0175 /// 0176 /// @return boolean indicator if the position is inside 0177 bool inside(const GeometryContext& gctx, const Vector3& gpos, 0178 double tol = 0.) const; 0179 0180 /// Inside() method for checks 0181 /// 0182 /// @param gpos is the position to be checked 0183 /// @param tol is the tolerance parameter 0184 /// @deprecated: Function deprecated in favour of 0185 /// inside(const GeometryContext& gctx, const Vector3& gpos, 0186 /// double tol = 0.) 0187 /// 0188 /// @return boolean indicator if the position is inside 0189 [[deprecated( 0190 "Use inside(const GeometryContext& gctx, const Vector3& gpos, double tol " 0191 "= 0.) instead.")]] 0192 bool inside(const Vector3& gpos, double tol = 0.) const; 0193 /// The binning position method 0194 /// - as default the center is given, but may be overloaded 0195 /// 0196 /// @param gctx The current geometry context object, e.g. alignment 0197 /// @param aDir is the axis direction for the reference position 0198 /// @return vector 3D that can be used for the binning 0199 Vector3 referencePosition(const GeometryContext& gctx, 0200 AxisDirection aDir) const override; 0201 0202 /// Compare this volume with another for equality 0203 /// @param other The other volume to compare with 0204 /// @return True if the volumes are equal 0205 bool operator==(const Volume& other) const; 0206 0207 /// Produces a 3D visualization of this volume 0208 /// @param helper The visualization helper describing the output format 0209 /// @param gctx The geometry context 0210 /// @param viewConfig The view configuration 0211 void visualize(IVisualization3D& helper, const GeometryContext& gctx, 0212 const ViewConfig& viewConfig) const; 0213 0214 /// VolumePlacement object that dynamically aligns the volume 0215 /// @returns Pointer to the VolumePlacement (Might be nullptr) 0216 VolumePlacementBase* volumePlacement(); 0217 0218 /// VolumePlacement object that dynamically aligns the volume 0219 /// @returns Pointer to the VolumePlacement (Might be nullptr) 0220 const VolumePlacementBase* volumePlacement() const; 0221 0222 /// Is the volume connected to the experiment's alignment system 0223 /// (I.e. it's constructed with a volumePlacement) 0224 /// @returns Whether the volume can be externally aligned 0225 bool isAlignable() const; 0226 0227 private: 0228 /// Transform matrix that positions the volume in 3D space 0229 CloneablePtr<const Transform3> m_transform{}; 0230 0231 /// Inverse of the transform matrix for efficient calculations 0232 CloneablePtr<const Transform3> m_itransform{}; 0233 0234 /// Center position of the volume in global coordinates 0235 Vector3 m_center{Vector3::Zero()}; 0236 0237 /// Volume bounds that define the shape and extent of the volume 0238 std::shared_ptr<VolumeBounds> m_volumeBounds; 0239 /// Pointer to the external volume placement that's connected to the alignment 0240 VolumePlacementBase* m_placement{nullptr}; 0241 }; 0242 0243 /**Overload of << operator for std::ostream for debug output*/ 0244 /// @param sl Output stream 0245 /// @param vol Volume to output 0246 /// @return Reference to output stream 0247 std::ostream& operator<<(std::ostream& sl, const Volume& vol); 0248 0249 } // 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 |
|