File indexing completed on 2025-01-19 09:23:21
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Direction.hpp"
0013 #include "Acts/Geometry/BoundarySurfaceFace.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/Volume.hpp"
0016 #include "Acts/Surfaces/RegularSurface.hpp"
0017 #include "Acts/Surfaces/Surface.hpp"
0018 #include "Acts/Utilities/BinnedArray.hpp"
0019
0020 #include <memory>
0021
0022 namespace Acts {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 template <class volume_t>
0039 class BoundarySurfaceT {
0040 #ifndef DOXYGEN
0041 friend volume_t;
0042 #endif
0043
0044 using VolumePtr = std::shared_ptr<const volume_t>;
0045 using VolumeArray = BinnedArray<VolumePtr>;
0046
0047 public:
0048 BoundarySurfaceT()
0049 : m_surface(nullptr),
0050 m_oppositeVolume(nullptr),
0051 m_alongVolume(nullptr),
0052 m_oppositeVolumeArray(nullptr),
0053 m_alongVolumeArray(nullptr) {}
0054
0055
0056
0057
0058
0059
0060
0061 BoundarySurfaceT(std::shared_ptr<const RegularSurface> surface,
0062 const volume_t* inside, const volume_t* outside)
0063 : m_surface(std::move(surface)),
0064 m_oppositeVolume(inside),
0065 m_alongVolume(outside),
0066 m_oppositeVolumeArray(nullptr),
0067 m_alongVolumeArray(nullptr) {}
0068
0069
0070
0071
0072
0073
0074
0075 BoundarySurfaceT(std::shared_ptr<const RegularSurface> surface,
0076 VolumePtr inside, VolumePtr outside)
0077 : m_surface(std::move(surface)),
0078 m_oppositeVolume(inside.get()),
0079 m_alongVolume(outside.get()),
0080 m_oppositeVolumeArray(nullptr),
0081 m_alongVolumeArray(nullptr) {}
0082
0083
0084
0085
0086
0087
0088
0089
0090 BoundarySurfaceT(std::shared_ptr<const RegularSurface> surface,
0091 std::shared_ptr<const VolumeArray> insideArray,
0092 std::shared_ptr<const VolumeArray> outsideArray)
0093 : m_surface(std::move(surface)),
0094 m_oppositeVolume(nullptr),
0095 m_alongVolume(nullptr),
0096 m_oppositeVolumeArray(insideArray),
0097 m_alongVolumeArray(outsideArray) {}
0098
0099 virtual ~BoundarySurfaceT() = default;
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 virtual const volume_t* attachedVolume(const GeometryContext& gctx,
0110 const Vector3& pos,
0111 const Vector3& dir) const;
0112
0113
0114
0115
0116
0117
0118
0119 template <class parameters_t>
0120 bool onBoundary(const GeometryContext& gctx, const parameters_t& pars) const {
0121 return surfaceRepresentation().isOnSurface(gctx, pars);
0122 }
0123
0124
0125 virtual const RegularSurface& surfaceRepresentation() const;
0126
0127
0128
0129
0130
0131
0132 void attachVolume(const volume_t* volume, Direction dir);
0133
0134
0135
0136
0137
0138
0139 void attachVolumeArray(std::shared_ptr<const VolumeArray> volumes,
0140 Direction dir);
0141
0142 protected:
0143
0144 std::shared_ptr<const RegularSurface> m_surface;
0145
0146 const volume_t* m_oppositeVolume;
0147
0148 const volume_t* m_alongVolume;
0149
0150 std::shared_ptr<const VolumeArray> m_oppositeVolumeArray;
0151
0152 std::shared_ptr<const VolumeArray> m_alongVolumeArray;
0153 };
0154
0155 template <class volume_t>
0156 inline const RegularSurface& BoundarySurfaceT<volume_t>::surfaceRepresentation()
0157 const {
0158 return (*(m_surface.get()));
0159 }
0160
0161 template <class volume_t>
0162 void BoundarySurfaceT<volume_t>::attachVolume(const volume_t* volume,
0163 Direction dir) {
0164 if (dir == Direction::Backward) {
0165 m_oppositeVolume = volume;
0166 } else {
0167 m_alongVolume = volume;
0168 }
0169 }
0170
0171 template <class volume_t>
0172 void BoundarySurfaceT<volume_t>::attachVolumeArray(
0173 const std::shared_ptr<const VolumeArray> volumes, Direction dir) {
0174 if (dir == Direction::Backward) {
0175 m_oppositeVolumeArray = volumes;
0176 } else {
0177 m_alongVolumeArray = volumes;
0178 }
0179 }
0180
0181 template <class volume_t>
0182 const volume_t* BoundarySurfaceT<volume_t>::attachedVolume(
0183 const GeometryContext& gctx, const Vector3& pos, const Vector3& dir) const {
0184 const volume_t* attVolume = nullptr;
0185
0186 if ((surfaceRepresentation().normal(gctx, pos)).dot(dir) > 0.) {
0187 attVolume = m_alongVolumeArray ? m_alongVolumeArray->object(pos).get()
0188 : m_alongVolume;
0189 } else {
0190 attVolume = m_oppositeVolumeArray ? m_oppositeVolumeArray->object(pos).get()
0191 : m_oppositeVolume;
0192 }
0193 return attVolume;
0194 }
0195
0196 }