ITK  6.0.0
Insight Toolkit
itkFastMarchingBase.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19#ifndef itkFastMarchingBase_h
20#define itkFastMarchingBase_h
21
22#include "itkIntTypes.h"
25#include "ITKFastMarchingExport.h"
26
27#include <queue>
28#include <functional>
29
30namespace itk
31{
37{
38public:
39
44 enum class TopologyCheck : uint8_t
45 {
46 Nothing = 0,
47 NoHandles,
48 Strict
49 };
50};
51// Define how to print enumeration
52extern ITKFastMarching_EXPORT std::ostream &
53 operator<<(std::ostream & out, const FastMarchingTraitsEnums::TopologyCheck value);
54
125template <typename TInput, typename TOutput>
126class ITK_TEMPLATE_EXPORT FastMarchingBase : public FastMarchingTraits<TInput, TOutput>::SuperclassType
127{
128public:
129 ITK_DISALLOW_COPY_AND_MOVE(FastMarchingBase);
130
132 using SuperclassType = typename Traits::SuperclassType;
133
138
140 itkOverrideGetNameOfClassMacro(FastMarchingBase);
141
143 using InputDomainType = typename Traits::InputDomainType;
144 using InputDomainPointer = typename Traits::InputDomainPointer;
145 using InputPixelType = typename Traits::InputPixelType;
146
148 using OutputDomainType = typename Traits::OutputDomainType;
149 using OutputDomainPointer = typename Traits::OutputDomainPointer;
150 using OutputPixelType = typename Traits::OutputPixelType;
151
153 using NodeType = typename Traits::NodeType;
154
156 using NodePairType = typename Traits::NodePairType;
157 using NodePairContainerType = typename Traits::NodePairContainerType;
158 using NodePairContainerPointer = typename Traits::NodePairContainerPointer;
159 using NodePairContainerConstIterator = typename Traits::NodePairContainerConstIterator;
160
161 using LabelType = typename Traits::LabelType;
162
164 using StoppingCriterionType = FastMarchingStoppingCriterionBase<TInput, TOutput>;
166
167 /*
168 using ElementIdentifier = long;
169
170 using PriorityQueueElementType = MinPriorityQueueElementWrapper< NodeType,
171 OutputPixelType,
172 ElementIdentifier >;
173
174 using PriorityQueueType = PriorityQueueContainer< PriorityQueueElementType,
175 PriorityQueueElementType, OutputPixelType, ElementIdentifier >;
176 using PriorityQueuePointer = typename PriorityQueueType::Pointer;
177 */
178
180#if !defined(ITK_LEGACY_REMOVE)
181 using TopologyCheckType = FastMarchingTraitsEnums::TopologyCheck;
183 static constexpr TopologyCheckEnum Nothing = TopologyCheckEnum::Nothing;
184 static constexpr TopologyCheckEnum NoHandles = TopologyCheckEnum::NoHandles;
185 static constexpr TopologyCheckEnum Strict = TopologyCheckEnum::Strict;
186#endif
187
191 itkGetConstReferenceMacro(TopologyCheck, TopologyCheckEnum);
195 itkSetObjectMacro(TrialPoints, NodePairContainerType);
196 itkGetModifiableObjectMacro(TrialPoints, NodePairContainerType);
200 itkSetObjectMacro(AlivePoints, NodePairContainerType);
201 itkGetModifiableObjectMacro(AlivePoints, NodePairContainerType);
205 itkSetObjectMacro(ProcessedPoints, NodePairContainerType);
206 itkGetModifiableObjectMacro(ProcessedPoints, NodePairContainerType);
210 itkSetObjectMacro(ForbiddenPoints, NodePairContainerType);
211 itkGetModifiableObjectMacro(ForbiddenPoints, NodePairContainerType);
215 itkSetObjectMacro(StoppingCriterion, StoppingCriterionType);
216 itkGetModifiableObjectMacro(StoppingCriterion, StoppingCriterionType);
217
219 itkGetMacro(SpeedConstant, double);
220 itkSetMacro(SpeedConstant, double);
221
223 itkGetMacro(NormalizationFactor, double);
224 itkSetMacro(NormalizationFactor, double);
225
227 itkGetMacro(TargetReachedValue, OutputPixelType);
228
233 itkSetMacro(CollectPoints, bool);
234
236 itkGetConstReferenceMacro(CollectPoints, bool);
237 itkBooleanMacro(CollectPoints);
240protected:
243
245 ~FastMarchingBase() override = default;
246
247 StoppingCriterionPointer m_StoppingCriterion{};
248
249 double m_SpeedConstant{};
250 double m_InverseSpeed{};
251 double m_NormalizationFactor{};
252
253 OutputPixelType m_TargetReachedValue{};
254 OutputPixelType m_LargeValue{};
255 OutputPixelType m_TopologyValue{};
256
259 NodePairContainerPointer m_ProcessedPoints{};
260 NodePairContainerPointer m_ForbiddenPoints{};
261
262 bool m_CollectPoints{};
263
264 // PriorityQueuePointer m_Heap;
265 using HeapContainerType = std::vector<NodePairType>;
266 using NodeComparerType = std::greater<NodePairType>;
267
268 using PriorityQueueType = std::priority_queue<NodePairType, HeapContainerType, NodeComparerType>;
269
271
272 TopologyCheckEnum m_TopologyCheck{};
273
275 virtual IdentifierType
277
279 virtual const OutputPixelType
280 GetOutputValue(OutputDomainType * oDomain, const NodeType & iNode) const = 0;
281
283 virtual void
284 SetOutputValue(OutputDomainType * oDomain, const NodeType & iNode, const OutputPixelType & iValue) = 0;
285
289 virtual unsigned char
290 GetLabelValueForGivenNode(const NodeType & iNode) const = 0;
291
295 virtual void
296 SetLabelValueForGivenNode(const NodeType & iNode, const LabelType & iLabel) = 0;
297
302 virtual void
303 UpdateNeighbors(OutputDomainType * oDomain, const NodeType & iNode) = 0;
304
309 virtual void
310 UpdateValue(OutputDomainType * oDomain, const NodeType & iNode) = 0;
311
316 virtual bool
317 CheckTopology(OutputDomainType * oDomain, const NodeType & iNode) = 0;
318
320 void
322
324 virtual void
326
328 void
329 GenerateData() override;
330
332 void
333 PrintSelf(std::ostream & os, Indent indent) const override;
334};
335} // namespace itk
336
337#ifndef ITK_MANUAL_INSTANTIATION
338# include "itkFastMarchingBase.hxx"
339#endif
340
341#endif
Abstract class to solve an Eikonal based-equation using Fast Marching Method.
void Initialize(OutputDomainType *oDomain)
virtual void SetLabelValueForGivenNode(const NodeType &iNode, const LabelType &iLabel)=0
Set the Label Value for a given node.
typename StoppingCriterionType::Pointer StoppingCriterionPointer
virtual const OutputPixelType GetOutputValue(OutputDomainType *oDomain, const NodeType &iNode) const =0
Get the output value (front value) for a given node.
virtual unsigned char GetLabelValueForGivenNode(const NodeType &iNode) const =0
Get the LabelEnum Value for a given node.
typename Traits::SuperclassType SuperclassType
virtual IdentifierType GetTotalNumberOfNodes() const =0
Get the total number of nodes in the domain.
typename Traits::InputPixelType InputPixelType
typename Traits::OutputDomainPointer OutputDomainPointer
typename FastMarchingTraits< TInput, TOutput >::SuperclassType Superclass
typename Traits::NodePairContainerType NodePairContainerType
typename Traits::InputDomainType InputDomainType
void GenerateData() override
std::vector< NodePairType > HeapContainerType
void PrintSelf(std::ostream &os, Indent indent) const override
PrintSelf method
virtual bool CheckTopology(OutputDomainType *oDomain, const NodeType &iNode)=0
Check if the current node violate topological criterion.
typename Traits::OutputDomainType OutputDomainType
virtual void UpdateValue(OutputDomainType *oDomain, const NodeType &iNode)=0
Update value for a given node.
typename Traits::NodePairContainerPointer NodePairContainerPointer
typename Traits::NodeType NodeType
virtual void InitializeOutput(OutputDomainType *oDomain)=0
typename Traits::InputDomainPointer InputDomainPointer
typename Traits::NodePairType NodePairType
~FastMarchingBase() override=default
Destructor.
virtual void SetOutputValue(OutputDomainType *oDomain, const NodeType &iNode, const OutputPixelType &iValue)=0
Set the output value (front value) for a given node.
std::priority_queue< NodePairType, HeapContainerType, NodeComparerType > PriorityQueueType
std::greater< NodePairType > NodeComparerType
virtual void UpdateNeighbors(OutputDomainType *oDomain, const NodeType &iNode)=0
Update neighbors to a given node.
FastMarchingStoppingCriterionBase< TInput, TOutput > StoppingCriterionType
FastMarchingBase()
Constructor.
typename Traits::OutputPixelType OutputPixelType
typename Traits::LabelType LabelType
typename Traits::NodePairContainerConstIterator NodePairContainerConstIterator
Base class traits to be used by the FastMarchingBase.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
SizeValueType IdentifierType
Definition: itkIntTypes.h:90