Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-04 07:58:02

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