File indexing completed on 2025-07-11 07:49:48
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Geometry/Extent.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Surfaces/Surface.hpp"
0014 #include "Acts/Utilities/AxisDefinitions.hpp"
0015
0016 #include <iostream>
0017 #include <memory>
0018 #include <utility>
0019 #include <vector>
0020
0021 namespace Acts {
0022
0023 namespace detail {
0024
0025
0026
0027
0028
0029 struct ProtoLayerBase {
0030 public:
0031
0032 Extent extent;
0033
0034
0035 ExtentEnvelope envelope = ExtentEnvelope::Zero();
0036
0037
0038 Transform3 transform = Transform3::Identity();
0039
0040
0041
0042
0043 double min(AxisDirection aDir, bool addenv = true) const;
0044
0045
0046
0047
0048 double max(AxisDirection aDir, bool addenv = true) const;
0049
0050
0051
0052
0053 double medium(AxisDirection aDir, bool addenv = true) const;
0054
0055
0056
0057
0058 double range(AxisDirection aDir, bool addenv = true) const;
0059
0060
0061
0062 std::ostream& toStream(std::ostream& sl) const;
0063
0064 protected:
0065
0066
0067
0068
0069
0070
0071 static void measureImpl(const GeometryContext& gctx,
0072 const std::vector<const Surface*>& surfaces,
0073 Extent& extent, const Transform3& transform);
0074 };
0075
0076
0077
0078
0079
0080
0081 template <bool IsConst>
0082 struct ProtoLayerT : public ProtoLayerBase {
0083 using SurfacePtr = std::conditional_t<IsConst, const Surface*, Surface*>;
0084 using SurfaceType = std::conditional_t<IsConst, const Surface, Surface>;
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095 ProtoLayerT(const GeometryContext& gctx,
0096 const std::vector<SurfacePtr>& surfaces,
0097 const Transform3& transformIn = Transform3::Identity())
0098 : m_surfaces(surfaces) {
0099 transform = transformIn;
0100 std::vector<const Surface*> constSurfaces;
0101 if constexpr (!IsConst) {
0102 constSurfaces.reserve(surfaces.size());
0103 for (auto* sf : surfaces) {
0104 constSurfaces.push_back(sf);
0105 }
0106 measureImpl(gctx, constSurfaces, extent, transform);
0107 } else {
0108 measureImpl(gctx, surfaces, extent, transform);
0109 }
0110 }
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 ProtoLayerT(const GeometryContext& gctx,
0122 const std::vector<std::shared_ptr<SurfaceType>>& surfaces,
0123 const Transform3& transformIn = Transform3::Identity()) {
0124 transform = transformIn;
0125 m_surfaces.reserve(surfaces.size());
0126 for (const auto& sf : surfaces) {
0127 m_surfaces.push_back(sf.get());
0128 }
0129 std::vector<const Surface*> constSurfaces;
0130 if constexpr (!IsConst) {
0131 constSurfaces.reserve(surfaces.size());
0132 for (auto* sf : m_surfaces) {
0133 constSurfaces.push_back(sf);
0134 }
0135 measureImpl(gctx, constSurfaces, extent, transform);
0136 } else {
0137 measureImpl(gctx, m_surfaces, extent, transform);
0138 }
0139 }
0140
0141
0142
0143
0144
0145
0146
0147 ProtoLayerT(const GeometryContext& gctx,
0148 const std::vector<std::shared_ptr<Surface>>& surfaces,
0149 const Transform3& transformIn = Transform3::Identity())
0150 requires IsConst
0151 {
0152 transform = transformIn;
0153 m_surfaces.reserve(surfaces.size());
0154 for (const auto& sf : surfaces) {
0155 m_surfaces.push_back(sf.get());
0156 }
0157 measureImpl(gctx, m_surfaces, extent, transform);
0158 }
0159
0160 ProtoLayerT() = default;
0161
0162
0163
0164
0165
0166 friend std::ostream& operator<<(std::ostream& sl, const ProtoLayerT& pl) {
0167 return pl.toStream(sl);
0168 }
0169
0170
0171 const std::vector<SurfacePtr>& surfaces() const { return m_surfaces; }
0172
0173
0174
0175
0176 void add(const GeometryContext& gctx, SurfaceType& surface) {
0177 m_surfaces.push_back(&surface);
0178 std::vector<const Surface*> constSurfaces;
0179 if constexpr (!IsConst) {
0180 constSurfaces.reserve(m_surfaces.size());
0181 for (auto* sf : m_surfaces) {
0182 constSurfaces.push_back(sf);
0183 }
0184 measureImpl(gctx, constSurfaces, extent, transform);
0185 } else {
0186 measureImpl(gctx, m_surfaces, extent, transform);
0187 }
0188 }
0189
0190 protected:
0191
0192 std::vector<SurfacePtr> m_surfaces = {};
0193 };
0194
0195 }
0196
0197 struct MutableProtoLayer : public detail::ProtoLayerT<false> {
0198 using detail::ProtoLayerT<false>::ProtoLayerT;
0199 };
0200
0201
0202 struct ProtoLayer : public detail::ProtoLayerT<true> {
0203 using detail::ProtoLayerT<true>::ProtoLayerT;
0204
0205 explicit ProtoLayer(const MutableProtoLayer& other);
0206 };
0207
0208 }