diff --git a/Core/include/Acts/Geometry/Portal.hpp b/Core/include/Acts/Geometry/Portal.hpp index c6ec526a42d..ffaad3e2ccb 100644 --- a/Core/include/Acts/Geometry/Portal.hpp +++ b/Core/include/Acts/Geometry/Portal.hpp @@ -212,6 +212,10 @@ class Portal { /// @return The portal surface const RegularSurface& surface() const; + /// Access the portal surface that is shared between the two links + /// @return The portal surface + RegularSurface& surface(); + private: /// Helper to check surface equivalence without checking material status. This /// is needed because we allow fusing portals with surfaces that are diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index c5590e1168d..799f3802957 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -48,6 +48,7 @@ class IVolumeMaterial; class Surface; class TrackingVolume; struct GeometryIdentifierHook; +class Portal; /// Interface types of the Gen1 geometry model /// @note This interface is being replaced, and is subject to removal @@ -301,6 +302,26 @@ class TrackingVolume : public Volume { /// @return the range of volumes MutableVolumeRange volumes(); + using MutablePortalRange = + detail::TransformRange>>; + + using PortalRange = + detail::TransformRange>>; + + /// Return all portals registered under this tracking volume + /// @return the range of portals + PortalRange portals() const; + + /// Return mutable view of the registered portals under this tracking volume + /// @return the range of portals + MutablePortalRange portals(); + + /// Add a portal to this tracking volume + /// @param portal The portal to add + void addPortal(std::shared_ptr portal); + /// 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. @@ -494,6 +515,7 @@ class TrackingVolume : public Volume { std::string m_name; std::vector> m_volumes; + std::vector> m_portals; }; } // namespace Acts diff --git a/Core/src/Geometry/Portal.cpp b/Core/src/Geometry/Portal.cpp index fac9041b40f..dafe42f9e6c 100644 --- a/Core/src/Geometry/Portal.cpp +++ b/Core/src/Geometry/Portal.cpp @@ -172,6 +172,11 @@ const RegularSurface& Portal::surface() const { return *m_surface; } +RegularSurface& Portal::surface() { + assert(m_surface != nullptr); + return *m_surface; +} + Portal Portal::merge(const GeometryContext& gctx, Portal& aPortal, Portal& bPortal, BinningValue direction, const Logger& logger) { diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index 5e9bab8a742..4a91784ce6b 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Direction.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Geometry/GlueVolumesDescriptor.hpp" +#include "Acts/Geometry/Portal.hpp" #include "Acts/Geometry/VolumeBounds.hpp" #include "Acts/Material/IMaterialDecorator.hpp" #include "Acts/Material/IVolumeMaterial.hpp" @@ -424,6 +425,18 @@ void TrackingVolume::closeGeometry( logger); } } + + GeometryIdentifier::Value iportal = 0; + for (auto& portal : portals()) { + auto portalId = GeometryIdentifier(volumeID).setBoundary(++iportal); + assert(portal.isValid() && "Invalid portal encountered during closing"); + + portal.surface().assignGeometryId(portalId); + } + + for (auto& volume : volumes()) { + volume.closeGeometry(materialDecorator, volumeMap, vol, hook, logger); + } } // Returns the boundary surfaces ordered in probability to hit them based on @@ -641,4 +654,16 @@ TrackingVolume& TrackingVolume::addVolume( return *m_volumes.back(); } +TrackingVolume::PortalRange TrackingVolume::portals() const { + return PortalRange{m_portals}; +} + +TrackingVolume::MutablePortalRange TrackingVolume::portals() { + return MutablePortalRange{m_portals}; +} + +void TrackingVolume::addPortal(std::shared_ptr portal) { + m_portals.push_back(std::move(portal)); +} + } // namespace Acts