diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index 290e5c21425..b208eefa54b 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -322,6 +322,25 @@ class TrackingVolume : public Volume { /// @param portal The portal to add void addPortal(std::shared_ptr portal); + using MutableSurfaceRange = + detail::TransformRange>>; + using SurfaceRange = + detail::TransformRange>>; + + /// Return all surfaces registered under this tracking volume + /// @return the range of surfaces + SurfaceRange surfaces() const; + + /// Return mutable view of the registered surfaces under this tracking volume + /// @return the range of surfaces + MutableSurfaceRange surfaces(); + + /// Add a surface to this tracking volume + /// @param surface The surface to add + void addSurface(std::shared_ptr surface); + /// Add a child volume to this tracking volume /// @param volume The volume to add /// @note The @p volume will have its mother volume assigned to @p this. @@ -516,6 +535,7 @@ class TrackingVolume : public Volume { std::vector> m_volumes; std::vector> m_portals; + std::vector> m_surfaces; }; } // namespace Acts diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index d2c1124a1ae..79ffdc9d180 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -663,7 +663,25 @@ TrackingVolume::MutablePortalRange TrackingVolume::portals() { } void TrackingVolume::addPortal(std::shared_ptr portal) { + if (portal == nullptr) { + throw std::invalid_argument("Portal is nullptr"); + } m_portals.push_back(std::move(portal)); } +TrackingVolume::SurfaceRange TrackingVolume::surfaces() const { + return SurfaceRange{m_surfaces}; +} + +TrackingVolume::MutableSurfaceRange TrackingVolume::surfaces() { + return MutableSurfaceRange{m_surfaces}; +} + +void TrackingVolume::addSurface(std::shared_ptr surface) { + if (surface == nullptr) { + throw std::invalid_argument("Surface is nullptr"); + } + m_surfaces.push_back(std::move(surface)); +} + } // namespace Acts