|
|
|||
File indexing completed on 2026-05-22 07:46:38
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 gctx The current geometry context object, e.g. alignment 0039 /// @param volumes is the vector of volumes 0040 /// @param direction is the axis direction 0041 /// @param strategy is the attachment strategy 0042 /// @param resizeStrategy is the resize strategy 0043 /// @note @p resizeStrategy only affects resizing along 0044 /// @p direction. Resizing in the other direction 0045 /// is always delegated to the child volumes, 0046 /// which might in turn be @c CuboidVolumeStack 0047 /// @param logger is the logger 0048 /// @pre The volumes need to have a common coordinate 0049 /// system relative to @p direction. I.e. they need 0050 /// to be aligned in @c z and cannot have a rotation 0051 /// in @c x or @c y. 0052 /// @pre The volumes all need to have @c CuboidVolumeBounds 0053 /// @note Preconditions are checked on construction 0054 CuboidVolumeStack( 0055 const GeometryContext& gctx, std::vector<Volume*>& volumes, 0056 AxisDirection direction, 0057 VolumeAttachmentStrategy strategy = VolumeAttachmentStrategy::Midpoint, 0058 VolumeResizeStrategy resizeStrategy = VolumeResizeStrategy::Expand, 0059 const Logger& logger = Acts::getDummyLogger()); 0060 0061 /// Update the volume bounds and transform. This 0062 /// will update the bounds of all volumes in the stack 0063 /// to accommodate the new bounds and optionally create 0064 /// gap volumes according to the resize strategy set during 0065 /// construction. 0066 /// @param gctx The current geometry context object, e.g. alignment 0067 /// @param volbounds is the new bounds 0068 /// @param transform is the new transform 0069 /// @param logger is the logger 0070 /// @pre The volume bounds need to be of type 0071 /// @c CuboidVolumeBounds. 0072 void update(const GeometryContext& gctx, 0073 std::shared_ptr<VolumeBounds> volbounds, 0074 std::optional<Transform3> transform = std::nullopt, 0075 const Logger& logger = getDummyLogger()) override; 0076 0077 /// Convert axis direction to an array index according to 0078 /// stack convention. For example, AxisX --> 0 0079 /// @param direction is the axis direction to convert 0080 /// @return Array index corresponding to the axis direction 0081 static std::size_t axisToIndex(AxisDirection direction); 0082 0083 /// Get axis directions orthogonal to the given one according 0084 /// to stack convention. For example AxisX --> <AxisY, AxisZ> 0085 /// @param direction is the axis direction to find the orthogonal for 0086 /// @return Pair of orthogonal axis directions 0087 static std::pair<AxisDirection, AxisDirection> getOrthogonalAxes( 0088 AxisDirection direction); 0089 0090 private: 0091 /// Helper function called during construction that performs the 0092 /// internal attachment and produces the overall outer volume bounds. 0093 /// @param gctx The current geometry context object, e.g. alignment 0094 /// @param strategy is the attachment strategy 0095 /// @param logger is the logger 0096 void initializeOuterVolume(const GeometryContext& gctx, 0097 VolumeAttachmentStrategy strategy, 0098 const Logger& logger); 0099 0100 struct VolumeTuple; 0101 0102 /// Helper function to pretty print the internal volume representation 0103 /// @param volumes is the vector of volumes 0104 /// @param logger is the logger 0105 /// @param lvl is the logging level 0106 static void printVolumeSequence(const std::vector<VolumeTuple>& volumes, 0107 const Logger& logger, 0108 Acts::Logging::Level lvl); 0109 0110 /// Helper function that prints output helping in debugging overlaps 0111 /// @param a is the first volume 0112 /// @param b is the second volume 0113 /// @param logger is the logger 0114 void overlapPrint(const VolumeTuple& a, const VolumeTuple& b, 0115 const Logger& logger); 0116 0117 /// Helper function that checks if volumes are properly aligned 0118 /// for attachment. 0119 /// @param volumes is the vector of volumes 0120 /// @param logger is the logger 0121 void checkVolumeAlignment(const std::vector<VolumeTuple>& volumes, 0122 const Logger& logger) const; 0123 0124 /// Helper function that checks overlaps and attaches along the stacking 0125 /// direction 0126 /// @param gctx The current geometry context object, e.g. alignment 0127 /// @param volumes is the vector of volumes 0128 /// @param strategy is the attachment strategy 0129 /// @param logger is the logger 0130 /// @return vector of gap volumes. Can be empty if none were created. 0131 std::vector<VolumeTuple> checkOverlapAndAttach( 0132 const GeometryContext& gctx, std::vector<VolumeTuple>& volumes, 0133 VolumeAttachmentStrategy strategy, const Logger& logger); 0134 0135 /// Helper function to synchronize the bounds of the volumes 0136 /// @param volumes is the vector of volumes 0137 /// @param logger is the logger 0138 /// @return tuple of the minimum and maximum radii 0139 std::pair<double, double> synchronizeBounds(std::vector<VolumeTuple>& volumes, 0140 const Logger& logger); 0141 0142 /// Directions orthogonal to the 0143 /// merging direction of the stack 0144 /// in local group coordinates 0145 AxisDirection m_dirOrth1{}; 0146 AxisDirection m_dirOrth2{}; 0147 0148 Transform3 m_groupTransform{}; 0149 }; 0150 0151 } // 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 |
|