Skip to content

Commit

Permalink
feat(geo): TrackingVolume gets surface storage (#3675)
Browse files Browse the repository at this point in the history
Part of #3502 

This PR adds storage for surfaces (with shared ownership) inside tracking volumes.

Blocked by:
- #3673
  • Loading branch information
paulgessinger authored Oct 2, 2024
1 parent 661ab12 commit af00555
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,25 @@ class TrackingVolume : public Volume {
/// @param portal The portal to add
void addPortal(std::shared_ptr<Portal> portal);

using MutableSurfaceRange =
detail::TransformRange<detail::Dereference,
std::vector<std::shared_ptr<Surface>>>;
using SurfaceRange =
detail::TransformRange<detail::ConstDereference,
const std::vector<std::shared_ptr<Surface>>>;

/// 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> 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.
Expand Down Expand Up @@ -516,6 +535,7 @@ class TrackingVolume : public Volume {

std::vector<std::unique_ptr<TrackingVolume>> m_volumes;
std::vector<std::shared_ptr<Portal>> m_portals;
std::vector<std::shared_ptr<Surface>> m_surfaces;
};

} // namespace Acts
18 changes: 18 additions & 0 deletions Core/src/Geometry/TrackingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,25 @@ TrackingVolume::MutablePortalRange TrackingVolume::portals() {
}

void TrackingVolume::addPortal(std::shared_ptr<Portal> 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> surface) {
if (surface == nullptr) {
throw std::invalid_argument("Surface is nullptr");
}
m_surfaces.push_back(std::move(surface));
}

} // namespace Acts

0 comments on commit af00555

Please sign in to comment.