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