19 #ifndef itkFastMarchingReachedTargetNodesStoppingCriterion_h
20 #define itkFastMarchingReachedTargetNodesStoppingCriterion_h
24 #include "ITKFastMarchingExport.h"
47 extern ITKFastMarching_EXPORT std::ostream &
59 template <
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 auto pointsIter = m_TargetNodes.begin();
141 const auto 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{})
189 ~FastMarchingReachedTargetNodesStoppingCriterion()
override =
default;
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;
233 #endif // itkFastMarchingThresholdStoppingCriterion_h