Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 07:52:11

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 #include "Acts/Geometry/VolumeStack.hpp"
0010 
0011 namespace Acts {
0012 
0013 VolumeStack::VolumeStack(
0014     std::vector<Volume*>& volumes, AxisDirection direction,
0015     std::pair<VolumeResizeStrategy, VolumeResizeStrategy> resizeStrategies)
0016     : Volume(initialVolume(volumes)),
0017       m_direction(direction),
0018       m_resizeStrategies{resizeStrategies.first, resizeStrategies.second},
0019       m_volumes(volumes) {}
0020 
0021 Volume& VolumeStack::initialVolume(std::span<Volume*> volumes) {
0022   if (volumes.empty()) {
0023     throw std::invalid_argument("VolumeStack requires at least one volume");
0024   }
0025   return *volumes.front();
0026 }
0027 
0028 bool VolumeStack::isGapVolume(const Volume& volume) const {
0029   return std::ranges::any_of(
0030       gaps(), [&](const auto& gap) { return gap.get() == &volume; });
0031 }
0032 
0033 std::shared_ptr<Volume> VolumeStack::addGapVolume(
0034     const Transform3& transform, const std::shared_ptr<VolumeBounds>& bounds) {
0035   auto gapVolume = std::make_shared<Volume>(transform, bounds);
0036   m_gaps.push_back(gapVolume);
0037   return gapVolume;
0038 }
0039 
0040 const std::vector<std::shared_ptr<Volume>>& VolumeStack::gaps() const {
0041   return m_gaps;
0042 }
0043 
0044 }  // namespace Acts