19#ifndef itkFastMarchingReachedTargetNodesStoppingCriterion_h
20#define itkFastMarchingReachedTargetNodesStoppingCriterion_h
24#include "ITKFastMarchingExport.h"
47extern ITKFastMarching_EXPORT std::ostream &
59template <
typename TInput,
typename TOutput>
61 :
public FastMarchingStoppingCriterionBase<TInput, TOutput>
67 using Superclass = FastMarchingStoppingCriterionBase<TInput, TOutput>;
70 using typename Superclass::Traits;
78 using typename Superclass::OutputPixelType;
79 using typename Superclass::NodeType;
82#if !defined(ITK_LEGACY_REMOVE)
94 m_TargetCondition = iCondition;
95 m_Initialized =
false;
103 itkSetMacro(TargetOffset, OutputPixelType);
104 itkGetMacro(TargetOffset, OutputPixelType);
111 m_NumberOfTargetsToBeReached = iN;
112 m_Initialized =
false;
120 m_TargetNodes = iNodes;
121 m_Initialized =
false;
138 if (!m_TargetNodes.empty())
140 typename std::vector<NodeType>::const_iterator pointsIter = m_TargetNodes.begin();
141 typename std::vector<NodeType>::const_iterator pointsEnd = m_TargetNodes.end();
143 while (pointsIter != pointsEnd)
145 if (*pointsIter == iNode)
147 this->m_ReachedTargetNodes.push_back(iNode);
148 m_Satisfied = (m_ReachedTargetNodes.size() == m_NumberOfTargetsToBeReached);
155 m_StoppingValue = this->m_CurrentValue + m_TargetOffset;
169 return m_Satisfied && (this->m_CurrentValue >= m_StoppingValue);
176 return "Target Nodes Reached with possible overshoot";
183 , m_TargetOffset(OutputPixelType{})
184 , m_StoppingValue(OutputPixelType{})
192 std::vector<NodeType> m_TargetNodes{};
193 std::vector<NodeType> m_ReachedTargetNodes{};
194 size_t m_NumberOfTargetsToBeReached{ 0 };
195 OutputPixelType m_TargetOffset{};
196 OutputPixelType m_StoppingValue{};
197 bool m_Satisfied{
false };
198 bool m_Initialized{
false };
209 if (m_TargetCondition == TargetConditionEnum::OneTarget)
211 m_NumberOfTargetsToBeReached = 1;
213 if (m_TargetCondition == TargetConditionEnum::AllTargets)
215 m_NumberOfTargetsToBeReached = m_TargetNodes.size();
217 if (m_NumberOfTargetsToBeReached < 1)
219 itkExceptionMacro(
"Number of target nodes to be reached is null");
221 if (m_NumberOfTargetsToBeReached > m_TargetNodes.size())
224 <<
"Number of target nodes to be reached is above the provided number of target nodes");
226 m_ReachedTargetNodes.clear();
229 m_Initialized =
true;
Contains all enum classes used by FastMarchingReachedTargetNodesStoppingCriterion class.
Stopping criterion for FastMarchingFilterBase.
void SetNumberOfTargetsToBeReached(const vcl_size_t &iN)
Set the number of target nodes to be reached.
bool IsSatisfied() const override
returns if the stopping condition is satisfied or not.
virtual void SetTargetNodes(const std::vector< NodeType > &iNodes)
Set Target Nodes.
void SetTargetCondition(const TargetConditionEnum &iCondition)
void SetCurrentNode(const NodeType &iNode) override
Set the current node.
std::string GetDescription() const override
Get a short description of the stopping criterion.
FastMarchingStoppingCriterionBase< TInput, TOutput > Superclass
~FastMarchingReachedTargetNodesStoppingCriterion() override=default
FastMarchingReachedTargetNodesStoppingCriterion()
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)