|
|
|||
File indexing completed on 2025-10-23 08:22:18
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/Volume.hpp" 0013 #include "Acts/Geometry/VolumeAttachmentStrategy.hpp" 0014 #include "Acts/Geometry/VolumeResizeStrategy.hpp" 0015 #include "Acts/Geometry/VolumeStack.hpp" 0016 #include "Acts/Utilities/AxisDefinitions.hpp" 0017 #include "Acts/Utilities/Logger.hpp" 0018 0019 #include <cstddef> 0020 #include <vector> 0021 0022 namespace Acts { 0023 0024 /// @class CuboidVolumeStack 0025 /// This class implements a x-. y-. z-aligned stack 0026 /// of cuboid volumes with synchronized bounds. 0027 /// Externally, it presents as a single volume. 0028 /// On construction, the input volumes are modified so that 0029 /// they are connected in x, y, z and have synchronized bounds. 0030 /// The way this is done can be configured using an *attachment* 0031 /// and a *resize* strategy. Depending on the configuration, 0032 /// the input volumes are either extended or gap volumes are created. 0033 /// 0034 /// @note The size adjustment convention is that volumes are never shrunk 0035 class CuboidVolumeStack : public VolumeStack { 0036 public: 0037 /// Constructor from a vector of volumes and direction 0038 /// @param volumes is the vector of volumes 0039 /// @param direction is the axis direction 0040 /// @param strategy is the attachment strategy 0041 /// @param resizeStrategy is the resize strategy 0042 /// @note @p resizeStrategy only affects resizing along 0043 /// @p direction. Resizing in the other direction 0044 /// is always delegated to the child volumes, 0045 /// which might in turn be @c CuboidVolumeStack 0046 /// @param logger is the logger 0047 /// @pre The volumes need to have a common coordinate 0048 /// system relative to @p direction. I.e. they need 0049 /// to be aligned in @c z and cannot have a rotation 0050 /// in @c x or @c y. 0051 /// @pre The volumes all need to have @c CuboidVolumeBounds 0052 /// @note Preconditions are checked on construction 0053 CuboidVolumeStack( 0054 std::vector<Volume*>& volumes, AxisDirection direction, 0055 VolumeAttachmentStrategy strategy = VolumeAttachmentStrategy::Midpoint, 0056 VolumeResizeStrategy resizeStrategy = VolumeResizeStrategy::Expand, 0057 const Logger& logger = Acts::getDummyLogger()); 0058 0059 /// Update the volume bounds and transform. This 0060 /// will update the bounds of all volumes in the stack 0061 /// to accommodate the new bounds and optionally create 0062 /// gap volumes according to the resize strategy set during 0063 /// construction. 0064 /// @param volbounds is the new bounds 0065 /// @param transform is the new transform 0066 /// @param logger is the logger 0067 /// @pre The volume bounds need to be of type 0068 /// @c CuboidVolumeBounds. 0069 void update(std::shared_ptr<VolumeBounds> volbounds, 0070 std::optional<Transform3> transform = std::nullopt, 0071 const Logger& logger = getDummyLogger()) override; 0072 0073 /// Convert axis direction to an array index according to 0074 /// stack convention. For example, AxisX --> 0 0075 /// @param direction is the axis direction to convert 0076 /// @return Array index corresponding to the axis direction 0077 static std::size_t axisToIndex(AxisDirection direction); 0078 0079 /// Get axis directions orthogonal to the given one according 0080 /// to stack convention. For example AxisX --> <AxisY, AxisZ> 0081 /// @param direction is the axis direction to find the orthogonal for 0082 /// @return Pair of orthogonal axis directions 0083 static std::pair<AxisDirection, AxisDirection> getOrthogonalAxes( 0084 AxisDirection direction); 0085 0086 private: 0087 /// Helper function called during construction that performs the 0088 /// internal attachment and produces the overall outer volume bounds. 0089 /// @param strategy is the attachment strategy 0090 /// @param logger is the logger 0091 void initializeOuterVolume(VolumeAttachmentStrategy strategy, 0092 const Logger& logger); 0093 0094 struct VolumeTuple; 0095 0096 /// Helper function to pretty print the internal volume representation 0097 /// @param volumes is the vector of volumes 0098 /// @param logger is the logger 0099 /// @param lvl is the logging level 0100 static void printVolumeSequence(const std::vector<VolumeTuple>& volumes, 0101 const Logger& logger, 0102 Acts::Logging::Level lvl); 0103 0104 /// Helper function that prints output helping in debugging overlaps 0105 /// @param a is the first volume 0106 /// @param b is the second volume 0107 /// @param logger is the logger 0108 void overlapPrint(const VolumeTuple& a, const VolumeTuple& b, 0109 const Logger& logger); 0110 0111 /// Helper function that checks if volumes are properly aligned 0112 /// for attachment. 0113 /// @param volumes is the vector of volumes 0114 /// @param logger is the logger 0115 void checkVolumeAlignment(const std::vector<VolumeTuple>& volumes, 0116 const Logger& logger) const; 0117 0118 /// Helper function that checks overlaps and attaches along the stacking 0119 /// direction 0120 /// @param volumes is the vector of volumes 0121 /// @param strategy is the attachment strategy 0122 /// @param logger is the logger 0123 /// @return vector of gap volumes. Can be empty if none were created. 0124 std::vector<VolumeTuple> checkOverlapAndAttach( 0125 std::vector<VolumeTuple>& volumes, VolumeAttachmentStrategy strategy, 0126 const Logger& logger); 0127 0128 /// Helper function to synchronize the bounds of the volumes 0129 /// @param volumes is the vector of volumes 0130 /// @param logger is the logger 0131 /// @return tuple of the minimum and maximum radii 0132 std::pair<double, double> synchronizeBounds(std::vector<VolumeTuple>& volumes, 0133 const Logger& logger); 0134 0135 /// Directions orthogonal to the 0136 /// merging direction of the stack 0137 /// in local group coordinates 0138 AxisDirection m_dirOrth1{}; 0139 AxisDirection m_dirOrth2{}; 0140 0141 Transform3 m_groupTransform{}; 0142 }; 0143 0144 } // 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 |
|