ITK  5.2.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  * http://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"
24 #include "itkFastMarchingTraits.h"
25 #include "ITKFastMarchingExport.h"
26 
27 #include <queue>
28 #include <functional>
29 
30 namespace itk
31 {
37 {
38 public:
39 
44  enum class TopologyCheck : uint8_t
45  {
46  Nothing = 0,
47  NoHandles,
48  Strict
49  };
50 };
51 // Define how to print enumeration
52 extern ITKFastMarching_EXPORT std::ostream &
53  operator<<(std::ostream & out, const FastMarchingTraitsEnums::TopologyCheck value);
54 
125 template <typename TInput, typename TOutput>
126 class ITK_TEMPLATE_EXPORT FastMarchingBase : public FastMarchingTraits<TInput, TOutput>::SuperclassType
127 {
128 public:
129  ITK_DISALLOW_COPY_AND_MOVE(FastMarchingBase);
130 
132  using SuperclassType = typename Traits::SuperclassType;
133 
138 
140  itkTypeMacro(FastMarchingBase, FastMarchingTraits);
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>;
165  using StoppingCriterionPointer = typename StoppingCriterionType::Pointer;
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 
190  itkSetEnumMacro(TopologyCheck, TopologyCheckEnum);
191  itkGetConstReferenceMacro(TopologyCheck, TopologyCheckEnum);
193 
195  itkSetObjectMacro(TrialPoints, NodePairContainerType);
196  itkGetModifiableObjectMacro(TrialPoints, NodePairContainerType);
198 
200  itkSetObjectMacro(AlivePoints, NodePairContainerType);
201  itkGetModifiableObjectMacro(AlivePoints, NodePairContainerType);
203 
205  itkSetObjectMacro(ProcessedPoints, NodePairContainerType);
206  itkGetModifiableObjectMacro(ProcessedPoints, NodePairContainerType);
208 
210  itkSetObjectMacro(ForbiddenPoints, NodePairContainerType);
211  itkGetModifiableObjectMacro(ForbiddenPoints, NodePairContainerType);
213 
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);
239 
240 protected:
243 
245  ~FastMarchingBase() override = default;
246 
248 
252 
256 
261 
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 
273 
275  virtual IdentifierType
276  GetTotalNumberOfNodes() const = 0;
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
321  Initialize(OutputDomainType * oDomain);
322 
324  virtual void
325  InitializeOutput(OutputDomainType * oDomain) = 0;
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
itk::FastMarchingBase::OutputDomainType
typename Traits::OutputDomainType OutputDomainType
Definition: itkFastMarchingBase.h:148
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::FastMarchingBase::PriorityQueueType
std::priority_queue< NodePairType, HeapContainerType, NodeComparerType > PriorityQueueType
Definition: itkFastMarchingBase.h:268
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:218
TopologyCheck
itk::FastMarchingBase::NodePairContainerPointer
typename Traits::NodePairContainerPointer NodePairContainerPointer
Definition: itkFastMarchingBase.h:158
itk::FastMarchingBase::NodeComparerType
std::greater< NodePairType > NodeComparerType
Definition: itkFastMarchingBase.h:266
itk::FastMarchingTraitsEnums::TopologyCheck
TopologyCheck
Definition: itkFastMarchingBase.h:44
itk::FastMarchingBase::NodePairType
typename Traits::NodePairType NodePairType
Definition: itkFastMarchingBase.h:156
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkFastMarchingTraits.h
itk::FastMarchingBase::StoppingCriterionType
FastMarchingStoppingCriterionBase< TInput, TOutput > StoppingCriterionType
Definition: itkFastMarchingBase.h:164
itk::FastMarchingBase::m_NormalizationFactor
double m_NormalizationFactor
Definition: itkFastMarchingBase.h:251
itk::FastMarchingBase::SuperclassType
typename Traits::SuperclassType SuperclassType
Definition: itkFastMarchingBase.h:132
itk::FastMarchingBase::m_TopologyValue
OutputPixelType m_TopologyValue
Definition: itkFastMarchingBase.h:255
itk::FastMarchingTraitsEnums::TopologyCheck::NoHandles
itk::FastMarchingTraitsEnums::TopologyCheck::Nothing
itk::FastMarchingBase::m_LargeValue
OutputPixelType m_LargeValue
Definition: itkFastMarchingBase.h:254
itk::FastMarchingTraitsEnums::TopologyCheck::Strict
itk::FastMarchingBase::StoppingCriterionPointer
typename StoppingCriterionType::Pointer StoppingCriterionPointer
Definition: itkFastMarchingBase.h:165
itk::FastMarchingBase::InputDomainPointer
typename Traits::InputDomainPointer InputDomainPointer
Definition: itkFastMarchingBase.h:144
itk::FastMarchingBase::m_AlivePoints
NodePairContainerPointer m_AlivePoints
Definition: itkFastMarchingBase.h:258
itk::FastMarchingBase::m_SpeedConstant
double m_SpeedConstant
Definition: itkFastMarchingBase.h:249
itk::FastMarchingTraits
Base class traits to be used by the FastMarchingBase.
Definition: itkFastMarchingTraits.h:110
itk::FastMarchingBase::m_ProcessedPoints
NodePairContainerPointer m_ProcessedPoints
Definition: itkFastMarchingBase.h:259
itk::FastMarchingBase::NodePairContainerType
typename Traits::NodePairContainerType NodePairContainerType
Definition: itkFastMarchingBase.h:157
itk::FastMarchingBase::Superclass
typename FastMarchingTraits< TInput, TOutput >::SuperclassType Superclass
Definition: itkFastMarchingBase.h:135
itk::FastMarchingBase::NodePairContainerConstIterator
typename Traits::NodePairContainerConstIterator NodePairContainerConstIterator
Definition: itkFastMarchingBase.h:159
itkIntTypes.h
itk::FastMarchingTraitsEnums
Definition: itkFastMarchingBase.h:36
itk::FastMarchingBase::OutputDomainPointer
typename Traits::OutputDomainPointer OutputDomainPointer
Definition: itkFastMarchingBase.h:149
itk::FastMarchingBase::NodeType
typename Traits::NodeType NodeType
Definition: itkFastMarchingBase.h:153
itk::FastMarchingBase::OutputPixelType
typename Traits::OutputPixelType OutputPixelType
Definition: itkFastMarchingBase.h:150
itk::FastMarchingBase::InputDomainType
typename Traits::InputDomainType InputDomainType
Definition: itkFastMarchingBase.h:143
itk::FastMarchingBase::m_ForbiddenPoints
NodePairContainerPointer m_ForbiddenPoints
Definition: itkFastMarchingBase.h:260
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::FastMarchingBase::LabelType
typename Traits::LabelType LabelType
Definition: itkFastMarchingBase.h:161
itk::FastMarchingBase::m_StoppingCriterion
StoppingCriterionPointer m_StoppingCriterion
Definition: itkFastMarchingBase.h:247
itk::FastMarchingBase::InputPixelType
typename Traits::InputPixelType InputPixelType
Definition: itkFastMarchingBase.h:145
itk::FastMarchingBase::m_TopologyCheck
TopologyCheckEnum m_TopologyCheck
Definition: itkFastMarchingBase.h:272
itk::FastMarchingBase::m_TrialPoints
NodePairContainerPointer m_TrialPoints
Definition: itkFastMarchingBase.h:257
itk::FastMarchingBase::m_Heap
PriorityQueueType m_Heap
Definition: itkFastMarchingBase.h:270
itkFastMarchingStoppingCriterionBase.h
itk::FastMarchingBase::m_InverseSpeed
double m_InverseSpeed
Definition: itkFastMarchingBase.h:250
itk::FastMarchingBase::m_TargetReachedValue
OutputPixelType m_TargetReachedValue
Definition: itkFastMarchingBase.h:253
itk::FastMarchingBase::m_CollectPoints
bool m_CollectPoints
Definition: itkFastMarchingBase.h:262
itk::FastMarchingBase
Abstract class to solve an Eikonal based-equation using Fast Marching Method.
Definition: itkFastMarchingBase.h:126
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
itk::FastMarchingBase::HeapContainerType
std::vector< NodePairType > HeapContainerType
Definition: itkFastMarchingBase.h:265