Skip to content

Commit

Permalink
addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger committed Aug 29, 2024
1 parent d0037f0 commit 643cd98
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 198 deletions.
106 changes: 88 additions & 18 deletions Core/include/Acts/Navigation/NavigationStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Utilities/Intersection.hpp"

Expand All @@ -24,14 +26,14 @@ using namespace Experimental;

class Surface;

/// @brief The NavigationStream is a container for the navigation candidates
/// The NavigationStream is a container for the navigation candidates that
/// are currentlu processed in a given context. The context could be local to a
/// volume, or global to an entire track following.
///
/// The current candidates are stored in a vector of candidates, where an index
/// is used to indicate the current active candidate.
///
/// @todo the NavigationStream should hold also the current volume it is in
/// if it represents the geometry stream.
struct NavigationStream {
class NavigationStream {
public:
/// The query point for the navigation stream
///
/// This holds the position and direction from which the navigation stream
Expand All @@ -56,8 +58,6 @@ struct NavigationStream {
const Portal* portal = nullptr;
/// The boundary tolerance
BoundaryTolerance bTolerance = BoundaryTolerance::None();
/// Target flag: true if this Candidate represents an abortTarget
bool abortTarget = false;
/// Convenience access to surface
const Surface& surface() const { return *intersection.object(); }
/// Cinvencience access to the path length
Expand All @@ -76,35 +76,105 @@ struct NavigationStream {
}
};

/// The candidates of this navigation stream
std::vector<Candidate> candidates;

/// The currently active candidate
std::size_t currentIndex = 0u;

/// Switch to next next candidate
///
/// @return true if a next candidate is available
bool switchToNextCandidate() {
if (currentIndex < candidates.size()) {
++currentIndex;
if (m_currentIndex < m_candidates.size()) {
++m_currentIndex;
return true;
}
return false;
}

/// Const access the current candidate
const Candidate& currentCandidate() const {
return candidates.at(currentIndex);
return m_candidates.at(m_currentIndex);
}

/// Current Index
std::size_t currentIndex() const { return m_currentIndex; }

/// Non-cost access the candidate vector
std::vector<Candidate>& candidates() { return m_candidates; }

/// Const access the candidate vector
const std::vector<Candidate>& candidates() const { return m_candidates; }

/// Non-cost access the current candidate
Candidate& currentCandidate() { return candidates.at(currentIndex); }
///
/// This will throw and out of bounds exception if the stream is not
/// valid anymore.
Candidate& currentCandidate() { return m_candidates.at(m_currentIndex); }

/// The number of active candidates
std::size_t remainingCandidates() const {
return (candidates.size() - currentIndex);
return (m_candidates.size() - m_currentIndex);
}

/// Fill one surface into the candidate vector
///
/// @param surface the surface to be filled
/// @param bTolerance the boundary tolerance used for the intersection
void addSurfaceCandidate(const Surface* surface,
BoundaryTolerance bTolerance);

/// Fill n surfaces into the candidate vector
///
/// @param surfaces the surfaces that are filled in
/// @param bTolerance the boundary tolerance used for the intersection
void addSurfaceCandidates(const std::vector<const Surface*>& surfaces,
BoundaryTolerance bTolerance);

/// Fill one portal into the candidate vector
///
/// @param nStream the navigation stream that is being filled
/// @param portal the portals that are filled in
void addPortalCandidate(const Portal* portal);

/// Fill n portals into the candidate vector
///
/// @param nStream the navigation stream that is being filled
/// @param portals the portals that are filled in
void addPortalCandidates(const std::vector<const Portal*>& portals);

/// Initialize the stream from a query point
///
/// @param gctx is the geometry context
/// @param queryPoint holds current position, direction, etc.
/// @param cTolerance is the candidate search tolerance
/// @param onSurfaceTolerance is the tolerance for on-surface intersections
///
/// This method will first de-duplicate the candidates on basis of the surface
/// pointer to make sure that the multi-intersections are handled correctly.
/// This will allow intializeStream() to be called even as a re-initialization
/// and still work correctly with at one time valid candidates.
///
/// @return true if the stream is active, false indicates that there are no valid candidates
bool initialize(const GeometryContext& gctx,
const NavigationStream::QueryPoint& queryPoint,
BoundaryTolerance cTolerance,
ActsScalar onSurfaceTolerance = s_onSurfaceTolerance);

/// Convenience method to update a stream from a new query point,
/// this could be called from navigation delegates that do not require
/// a local state or from the navigator on the target stream
///
/// @param gctx is the geometry context
/// @param queryPoint holds current position, direction, etc.
/// @param onSurfaceTolerance is the tolerance for on-surface intersections
///
/// @return true if the stream is active, false indicate no valid candidates left
bool update(const GeometryContext& gctx,
const NavigationStream::QueryPoint& queryPoint,
ActsScalar onSurfaceTolerance = s_onSurfaceTolerance);

private:
/// The candidates of this navigation stream
std::vector<Candidate> m_candidates;

/// The currently active candidate
std::size_t m_currentIndex = 0u;
};

} // namespace Acts
108 changes: 0 additions & 108 deletions Core/include/Acts/Navigation/NavigationStreamHelper.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion Core/src/Navigation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
target_sources(ActsCore PRIVATE NavigationStreamHelper.cpp)
target_sources(ActsCore PRIVATE NavigationStream.cpp)
Loading

0 comments on commit 643cd98

Please sign in to comment.