![]() |
|
|||
File indexing completed on 2025-06-30 07:51:43
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 static std::size_t axisToIndex(AxisDirection direction); 0077 0078 /// Get axis directions orthogonal to the given one according 0079 /// to stack convention. For example AxisX --> <AxisY, AxisZ> 0080 /// @param direction is the axis direction to find the orthogonal for 0081 static std::pair<AxisDirection, AxisDirection> getOrthogonalAxes( 0082 AxisDirection direction); 0083 0084 private: 0085 /// Helper function called during construction that performs the 0086 /// internal attachment and produces the overall outer volume bounds. 0087 /// @param strategy is the attachment strategy 0088 /// @param logger is the logger 0089 void initializeOuterVolume(VolumeAttachmentStrategy strategy, 0090 const Logger& logger); 0091 0092 struct VolumeTuple; 0093 0094 /// Helper function to pretty print the internal volume representation 0095 /// @param volumes is the vector of volumes 0096 /// @param logger is the logger 0097 /// @param lvl is the logging level 0098 static void printVolumeSequence(const std::vector<VolumeTuple>& volumes, 0099 const Logger& logger, 0100 Acts::Logging::Level lvl); 0101 0102 /// Helper function that prints output helping in debugging overlaps 0103 /// @param a is the first volume 0104 /// @param b is the second volume 0105 /// @param logger is the logger 0106 void overlapPrint(const VolumeTuple& a, const VolumeTuple& b, 0107 const Logger& logger); 0108 0109 /// Helper function that checks if volumes are properly aligned 0110 /// for attachment. 0111 /// @param volumes is the vector of volumes 0112 /// @param logger is the logger 0113 void checkVolumeAlignment(const std::vector<VolumeTuple>& volumes, 0114 const Logger& logger) const; 0115 0116 /// Helper function that checks overlaps and attaches along the stacking 0117 /// direction 0118 /// @param volumes is the vector of volumes 0119 /// @param strategy is the attachment strategy 0120 /// @param logger is the logger 0121 /// @return vector of gap volumes. Can be empty if none were created. 0122 std::vector<VolumeTuple> checkOverlapAndAttach( 0123 std::vector<VolumeTuple>& volumes, VolumeAttachmentStrategy strategy, 0124 const Logger& logger); 0125 0126 /// Helper function to synchronize the bounds of the volumes 0127 /// @param volumes is the vector of volumes 0128 /// @param logger is the logger 0129 /// @return tuple of the minimum and maximum radii 0130 std::pair<double, double> synchronizeBounds(std::vector<VolumeTuple>& volumes, 0131 const Logger& logger); 0132 0133 /// Directions orthogonal to the 0134 /// merging direction of the stack 0135 /// in local group coordinates 0136 AxisDirection m_dirOrth1{}; 0137 AxisDirection m_dirOrth2{}; 0138 0139 Transform3 m_groupTransform{}; 0140 }; 0141 0142 } // 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 |
![]() ![]() |