File indexing completed on 2025-10-16 08:02:15
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Detector/Portal.hpp"
0012 #include "Acts/Geometry/BoundarySurfaceT.hpp"
0013 #include "Acts/Geometry/Portal.hpp"
0014 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0015 #include "Acts/Utilities/Intersection.hpp"
0016
0017 #include <cstddef>
0018 #include <variant>
0019
0020 namespace Acts {
0021
0022
0023
0024
0025
0026
0027
0028
0029 class NavigationTarget {
0030 public:
0031
0032 using Intersection = Intersection3D;
0033
0034 using Position = Intersection::Position;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 constexpr NavigationTarget(
0045 const Intersection3D& intersection, IntersectionIndex intersectionIndex,
0046 const Surface& target,
0047 const BoundaryTolerance& boundaryTolerance) noexcept
0048 : m_intersection(intersection),
0049 m_intersectionIndex(intersectionIndex),
0050 m_target(&target),
0051 m_surfaceRepresentation(&target),
0052 m_boundaryTolerance(boundaryTolerance) {}
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 constexpr NavigationTarget(
0064 const Intersection3D& intersection, IntersectionIndex intersectionIndex,
0065 const Layer& target, const Surface& surfaceRepresentation,
0066 const BoundaryTolerance& boundaryTolerance) noexcept
0067 : m_intersection(intersection),
0068 m_intersectionIndex(intersectionIndex),
0069 m_target(&target),
0070 m_surfaceRepresentation(&surfaceRepresentation),
0071 m_boundaryTolerance(boundaryTolerance) {}
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 constexpr NavigationTarget(
0082 const Intersection3D& intersection, IntersectionIndex intersectionIndex,
0083 const BoundarySurface& target,
0084 const BoundaryTolerance& boundaryTolerance) noexcept
0085 : m_intersection(intersection),
0086 m_intersectionIndex(intersectionIndex),
0087 m_target(&target),
0088 m_surfaceRepresentation(&target.surfaceRepresentation()),
0089 m_boundaryTolerance(boundaryTolerance) {}
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 NavigationTarget(const Intersection3D& intersection,
0100 IntersectionIndex intersectionIndex, const Portal& target,
0101 const BoundaryTolerance& boundaryTolerance) noexcept
0102 : m_intersection(intersection),
0103 m_intersectionIndex(intersectionIndex),
0104 m_target(&target),
0105 m_surfaceRepresentation(&target.surface()),
0106 m_boundaryTolerance(boundaryTolerance) {}
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 NavigationTarget(const Intersection3D& intersection,
0117 IntersectionIndex intersectionIndex,
0118 const Experimental::Portal& target,
0119 const BoundaryTolerance& boundaryTolerance) noexcept
0120 : m_intersection(intersection),
0121 m_intersectionIndex(intersectionIndex),
0122 m_target(&target),
0123 m_surfaceRepresentation(&target.surface()),
0124 m_boundaryTolerance(boundaryTolerance) {}
0125
0126
0127 constexpr NavigationTarget(const NavigationTarget&) noexcept = default;
0128
0129
0130 constexpr NavigationTarget(NavigationTarget&&) noexcept = default;
0131
0132
0133 constexpr NavigationTarget& operator=(const NavigationTarget&) noexcept =
0134 default;
0135
0136
0137 constexpr NavigationTarget& operator=(NavigationTarget&&) noexcept = default;
0138
0139
0140
0141 constexpr const Intersection3D& intersection() const {
0142 return m_intersection;
0143 }
0144
0145
0146
0147 constexpr Intersection3D& intersection() { return m_intersection; }
0148
0149
0150
0151 constexpr IntersectionIndex intersectionIndex() const noexcept {
0152 return m_intersectionIndex;
0153 }
0154
0155
0156
0157 constexpr IntersectionIndex& intersectionIndex() noexcept {
0158 return m_intersectionIndex;
0159 }
0160
0161
0162
0163 constexpr const Surface& surface() const noexcept {
0164 return *m_surfaceRepresentation;
0165 }
0166
0167
0168
0169 constexpr const Layer& layer() const {
0170 return *std::get<const Layer*>(m_target);
0171 }
0172
0173
0174
0175 constexpr const BoundarySurface& boundarySurface() const {
0176 return *std::get<const BoundarySurface*>(m_target);
0177 }
0178
0179
0180
0181 constexpr const Portal& portal() const {
0182 return *std::get<const Portal*>(m_target);
0183 }
0184
0185
0186
0187 constexpr const Experimental::Portal& gen2Portal() const {
0188 return *std::get<const Experimental::Portal*>(m_target);
0189 }
0190
0191
0192
0193 constexpr bool isSurfaceTarget() const noexcept {
0194 return std::holds_alternative<const Surface*>(m_target);
0195 }
0196
0197
0198
0199 constexpr bool isLayerTarget() const noexcept {
0200 return std::holds_alternative<const Layer*>(m_target);
0201 }
0202
0203
0204
0205 constexpr bool isPortalTarget() const noexcept {
0206 return std::holds_alternative<const BoundarySurface*>(m_target) ||
0207 std::holds_alternative<const Portal*>(m_target) ||
0208 std::holds_alternative<const Experimental::Portal*>(m_target);
0209 }
0210
0211
0212
0213 constexpr const BoundaryTolerance& boundaryTolerance() const noexcept {
0214 return m_boundaryTolerance;
0215 }
0216
0217
0218
0219 constexpr bool isValid() const noexcept { return m_intersection.isValid(); }
0220
0221
0222
0223 Position position() const noexcept { return m_intersection.position(); }
0224
0225
0226
0227 constexpr double pathLength() const noexcept {
0228 return m_intersection.pathLength();
0229 }
0230
0231
0232
0233 constexpr IntersectionStatus status() const noexcept {
0234 return m_intersection.status();
0235 }
0236
0237
0238
0239 constexpr bool isNone() const noexcept {
0240 return std::holds_alternative<std::monostate>(m_target);
0241 }
0242
0243
0244
0245 constexpr static NavigationTarget None() noexcept {
0246 return NavigationTarget();
0247 }
0248
0249
0250
0251 constexpr static bool pathLengthOrder(
0252 const NavigationTarget& aIntersection,
0253 const NavigationTarget& bIntersection) noexcept {
0254 return Intersection3D::pathLengthOrder(aIntersection.intersection(),
0255 bIntersection.intersection());
0256 }
0257
0258
0259
0260 constexpr static bool closestOrder(
0261 const NavigationTarget& aIntersection,
0262 const NavigationTarget& bIntersection) noexcept {
0263 return Intersection3D::closestOrder(aIntersection.intersection(),
0264 bIntersection.intersection());
0265 }
0266
0267
0268
0269 constexpr static bool closestForwardOrder(
0270 const NavigationTarget& aIntersection,
0271 const NavigationTarget& bIntersection) noexcept {
0272 return Intersection3D::closestForwardOrder(aIntersection.intersection(),
0273 bIntersection.intersection());
0274 }
0275
0276 private:
0277
0278 using TargetVariant =
0279 std::variant<std::monostate, const Surface*, const Layer*,
0280 const BoundarySurface*, const Portal*,
0281 const Experimental::Portal*>;
0282
0283
0284 Intersection3D m_intersection = Intersection3D::Invalid();
0285
0286 IntersectionIndex m_intersectionIndex = 0;
0287
0288 TargetVariant m_target;
0289
0290 const Surface* m_surfaceRepresentation = nullptr;
0291
0292 BoundaryTolerance m_boundaryTolerance = BoundaryTolerance::None();
0293
0294
0295 constexpr NavigationTarget() = default;
0296 };
0297
0298 static_assert(std::is_trivially_copy_constructible_v<NavigationTarget>);
0299 static_assert(std::is_trivially_move_constructible_v<NavigationTarget>);
0300 static_assert(std::is_trivially_move_assignable_v<NavigationTarget>);
0301
0302 }