File indexing completed on 2025-12-15 09:24:02
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 constexpr NavigationTarget& operator=(const NavigationTarget&) noexcept =
0115 default;
0116
0117
0118 constexpr NavigationTarget& operator=(NavigationTarget&&) noexcept = default;
0119
0120
0121
0122 constexpr const Intersection3D& intersection() const {
0123 return m_intersection;
0124 }
0125
0126
0127
0128 constexpr Intersection3D& intersection() { return m_intersection; }
0129
0130
0131
0132 constexpr IntersectionIndex intersectionIndex() const noexcept {
0133 return m_intersectionIndex;
0134 }
0135
0136
0137
0138 constexpr IntersectionIndex& intersectionIndex() noexcept {
0139 return m_intersectionIndex;
0140 }
0141
0142
0143
0144 constexpr const Surface& surface() const noexcept {
0145 return *m_surfaceRepresentation;
0146 }
0147
0148
0149
0150 constexpr const Layer& layer() const {
0151 return *std::get<const Layer*>(m_target);
0152 }
0153
0154
0155
0156 constexpr const BoundarySurface& boundarySurface() const {
0157 return *std::get<const BoundarySurface*>(m_target);
0158 }
0159
0160
0161
0162 constexpr const Portal& portal() const {
0163 return *std::get<const Portal*>(m_target);
0164 }
0165
0166
0167
0168 constexpr bool isSurfaceTarget() const noexcept {
0169 return std::holds_alternative<const Surface*>(m_target);
0170 }
0171
0172
0173
0174 constexpr bool isLayerTarget() const noexcept {
0175 return std::holds_alternative<const Layer*>(m_target);
0176 }
0177
0178
0179
0180 constexpr bool isPortalTarget() const noexcept {
0181 return std::holds_alternative<const BoundarySurface*>(m_target) ||
0182 std::holds_alternative<const Portal*>(m_target);
0183 }
0184
0185
0186
0187 constexpr const BoundaryTolerance& boundaryTolerance() const noexcept {
0188 return m_boundaryTolerance;
0189 }
0190
0191
0192
0193 constexpr bool isValid() const noexcept { return m_intersection.isValid(); }
0194
0195
0196
0197 Position position() const noexcept { return m_intersection.position(); }
0198
0199
0200
0201 constexpr double pathLength() const noexcept {
0202 return m_intersection.pathLength();
0203 }
0204
0205
0206
0207 constexpr IntersectionStatus status() const noexcept {
0208 return m_intersection.status();
0209 }
0210
0211
0212
0213 constexpr bool isNone() const noexcept {
0214 return std::holds_alternative<std::monostate>(m_target);
0215 }
0216
0217
0218
0219 constexpr static NavigationTarget None() noexcept {
0220 return NavigationTarget();
0221 }
0222
0223
0224
0225 constexpr static bool pathLengthOrder(
0226 const NavigationTarget& aIntersection,
0227 const NavigationTarget& bIntersection) noexcept {
0228 return Intersection3D::pathLengthOrder(aIntersection.intersection(),
0229 bIntersection.intersection());
0230 }
0231
0232
0233
0234 constexpr static bool closestOrder(
0235 const NavigationTarget& aIntersection,
0236 const NavigationTarget& bIntersection) noexcept {
0237 return Intersection3D::closestOrder(aIntersection.intersection(),
0238 bIntersection.intersection());
0239 }
0240
0241
0242
0243 constexpr static bool closestForwardOrder(
0244 const NavigationTarget& aIntersection,
0245 const NavigationTarget& bIntersection) noexcept {
0246 return Intersection3D::closestForwardOrder(aIntersection.intersection(),
0247 bIntersection.intersection());
0248 }
0249
0250 private:
0251
0252 using TargetVariant =
0253 std::variant<std::monostate, const Surface*, const Layer*,
0254 const BoundarySurface*, const Portal*>;
0255
0256
0257 Intersection3D m_intersection = Intersection3D::Invalid();
0258
0259 IntersectionIndex m_intersectionIndex = 0;
0260
0261 TargetVariant m_target;
0262
0263 const Surface* m_surfaceRepresentation = nullptr;
0264
0265 BoundaryTolerance m_boundaryTolerance = BoundaryTolerance::None();
0266
0267
0268 constexpr NavigationTarget() = default;
0269 };
0270
0271 static_assert(std::is_trivially_copy_constructible_v<NavigationTarget>);
0272 static_assert(std::is_trivially_move_constructible_v<NavigationTarget>);
0273 static_assert(std::is_trivially_move_assignable_v<NavigationTarget>);
0274
0275 }