ITK  6.0.0
Insight Toolkit
itkLevelSetContainerBase.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 itkLevelSetContainerBase_h
20 #define itkLevelSetContainerBase_h
21 
22 #include <map>
23 #include "itkObject.h"
24 #include "itkObjectFactory.h"
27 
28 
29 namespace itk
30 {
41 template <typename TIdentifier, typename TLevelSet>
42 class ITK_TEMPLATE_EXPORT LevelSetContainerBase : public Object
43 {
44 public:
45  ITK_DISALLOW_COPY_AND_MOVE(LevelSetContainerBase);
46 
50  using Superclass = Object;
51 
53  itkOverrideGetNameOfClassMacro(LevelSetContainerBase);
54 
56  using LevelSetType = TLevelSet;
63  using LevelSetDataType = typename LevelSetType::LevelSetDataType;
64 
66  using LevelSetIdentifierType = TIdentifier;
67 
68  using LevelSetContainerType = std::map<LevelSetIdentifierType, LevelSetPointer>;
69  using LevelSetContainerConstIteratorType = typename LevelSetContainerType::const_iterator;
70  using LevelSetContainerIteratorType = typename LevelSetContainerType::iterator;
71 
74 
75  static constexpr unsigned int Dimension = LevelSetType::Dimension;
76 
77  using IdListType = std::list<LevelSetIdentifierType>;
78  using IdListIterator = typename IdListType::iterator;
79  using IdListConstIterator = typename IdListType::const_iterator;
82 
84 
85  using LevelSetPairType = std::pair<LevelSetIdentifierType, LevelSetPointer>;
86 
89 
90  using DomainContainerType = std::map<LevelSetIdentifierType, LevelSetDomainType>;
91  using DomainIteratorType = typename DomainContainerType::iterator;
92 
94  class Iterator;
95  friend class Iterator;
96 
102  {
103  public:
104  ConstIterator() = default;
106  : m_Iterator(it)
107  {}
108  ~ConstIterator() = default;
110  : m_Iterator(it.m_Iterator)
111  {}
114  ConstIterator &
116  {
117  return *this;
118  }
119  ConstIterator *
121  {
122  return this;
123  }
124  ConstIterator &
126  {
127  ++m_Iterator;
128  return *this;
129  }
132  {
133  ConstIterator tmp(*this);
134  ++(*this);
135  return tmp;
136  }
137  ConstIterator &
139  {
140  --m_Iterator;
141  return *this;
142  }
145  {
146  ConstIterator tmp(*this);
147  --(*this);
148  return tmp;
149  }
150  bool
151  operator==(const Iterator & it) const
152  {
153  return (m_Iterator == it.m_Iterator);
154  }
155 
156  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Iterator);
157 
158  bool
159  operator==(const ConstIterator & it) const
160  {
161  return (m_Iterator == it.m_Iterator);
162  }
163 
164  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
165 
168  {
169  return m_Iterator->first;
170  }
171 
172  LevelSetType *
173  GetLevelSet() const
174  {
175  return m_Iterator->second;
176  }
177 
178  private:
180  friend class Iterator;
181  };
182 
186  class Iterator
187  {
188  public:
189  Iterator() = default;
191  : m_Iterator(it)
192  {}
194  : m_Iterator(it.m_Iterator)
195  {}
196  ~Iterator() = default;
199  Iterator &
201  {
202  return *this;
203  }
204  Iterator *
206  {
207  return this;
208  }
209  Iterator &
211  {
212  ++m_Iterator;
213  return *this;
214  }
215  Iterator
217  {
218  Iterator tmp(*this);
219  ++(*this);
220  return tmp;
221  }
222  Iterator &
224  {
225  --m_Iterator;
226  return *this;
227  }
228  Iterator
230  {
231  Iterator tmp(*this);
232  --(*this);
233  return tmp;
234  }
235  bool
236  operator==(const Iterator & it) const
237  {
238  return (m_Iterator == it.m_Iterator);
239  }
240 
241  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Iterator);
242 
243  bool
244  operator==(const ConstIterator & it) const
245  {
246  return (m_Iterator == it.m_Iterator);
247  }
248 
249  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
250 
253  {
254  return m_Iterator->first;
255  }
256 
257  LevelSetType *
258  GetLevelSet() const
259  {
260  return m_Iterator->second;
261  }
262 
263  private:
265  friend class ConstIterator;
266  };
267 
268  Iterator
269  Begin();
270  Iterator
271  End();
272 
274  Begin() const;
276  End() const;
277 
280  Size() const;
281 
287  GetLevelSet(const LevelSetIdentifierType & iId) const;
288 
298  bool
299  AddLevelSet(const LevelSetIdentifierType & iId, LevelSetType * iLevelSet, const bool iForce = true);
300 
306  bool
307  RemoveLevelSet(const LevelSetIdentifierType & iId);
308 
310  itkSetConstObjectMacro(Heaviside, HeavisideType);
311  itkGetConstObjectMacro(Heaviside, HeavisideType);
315  itkSetObjectMacro(DomainMapFilter, DomainMapImageFilterType);
316  itkGetModifiableObjectMacro(DomainMapFilter, DomainMapImageFilterType);
320  bool
321  HasDomainMap() const;
322 
323 protected:
325  LevelSetContainerBase() = default;
326 
328  ~LevelSetContainerBase() override = default;
329 
330  const LevelSetContainerType &
331  GetContainer() const;
332  void
333  SetContainer(const LevelSetContainerType & iContainer);
334 
335 private:
336  HeavisideConstPointer m_Heaviside{};
337  DomainMapImageFilterPointer m_DomainMapFilter{};
338  LevelSetContainerType m_Container{};
339 };
340 } // namespace itk
341 
342 #ifndef ITK_MANUAL_INSTANTIATION
343 # include "itkLevelSetContainerBase.hxx"
344 #endif
345 
346 #endif // itkLevelSetContainerBase_h
itk::LevelSetContainerBase::ConstIterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetContainerBase.h:159
itk::LevelSetContainerBase::Iterator::operator++
Iterator & operator++()
Definition: itkLevelSetContainerBase.h:210
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::HeavisideConstPointer
typename HeavisideType::ConstPointer HeavisideConstPointer
Definition: itkLevelSetContainerBase.h:73
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::LevelSetContainerBase::Iterator::operator->
Iterator * operator->()
Definition: itkLevelSetContainerBase.h:205
itkObjectFactory.h
itk::LevelSetContainerBase::ConstIterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetContainerBase.h:167
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:68
itk::LevelSetContainerBase::ConstIterator::ConstIterator
ConstIterator(const LevelSetContainerConstIteratorType &it)
Definition: itkLevelSetContainerBase.h:105
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetContainerType
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
Definition: itkLevelSetContainerBase.h:68
itk::LevelSetContainerBase::Iterator
Definition: itkLevelSetContainerBase.h:186
itk::LevelSetBase< Index< VDimension >, VDimension, TImage::PixelType, ImageBase< VDimension > >::OutputRealType
typename NumericTraits< OutputType >::RealType OutputRealType
Definition: itkLevelSetBase.h:61
itk::LevelSetContainerBase::ConstIterator::operator++
ConstIterator operator++(int)
Definition: itkLevelSetContainerBase.h:131
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itk::LevelSetDenseImage
Base class for the "dense" representation of a level-set function on one image.
Definition: itkLevelSetDenseImage.h:41
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::DomainContainerType
std::map< LevelSetIdentifierType, LevelSetDomainType > DomainContainerType
Definition: itkLevelSetContainerBase.h:90
itk::LevelSetDomainMapImageFilter::LevelSetDomain
Specifies an image region where an unique std::list of level sets Id's are defined.
Definition: itkLevelSetDomainMapImageFilter.h:83
itk::LevelSetContainerBase::ConstIterator::GetLevelSet
LevelSetType * GetLevelSet() const
Definition: itkLevelSetContainerBase.h:173
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetDomainType
typename DomainMapImageFilterType::LevelSetDomain LevelSetDomainType
Definition: itkLevelSetContainerBase.h:88
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::DomainMapImageFilterPointer
typename DomainMapImageFilterType::Pointer DomainMapImageFilterPointer
Definition: itkLevelSetContainerBase.h:87
itk::SmartPointer< Self >
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::IdListType
std::list< LevelSetIdentifierType > IdListType
Definition: itkLevelSetContainerBase.h:77
itk::LevelSetContainerBase::ConstIterator::ConstIterator
ConstIterator(const Iterator &it)
Definition: itkLevelSetContainerBase.h:109
itk::LevelSetContainerBase::Iterator::GetLevelSet
LevelSetType * GetLevelSet() const
Definition: itkLevelSetContainerBase.h:258
itk::LevelSetContainerBase::ConstIterator
Definition: itkLevelSetContainerBase.h:101
itk::LevelSetContainerBase::ConstIterator::operator++
ConstIterator & operator++()
Definition: itkLevelSetContainerBase.h:125
itk::LevelSetContainerBase::ConstIterator::operator*
ConstIterator & operator*()
Definition: itkLevelSetContainerBase.h:115
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::OutputType
typename LevelSetType::OutputType OutputType
Definition: itkLevelSetContainerBase.h:59
itk::HeavisideStepFunctionBase
Base class of the Heaviside function.
Definition: itkHeavisideStepFunctionBase.h:51
itkLevelSetDomainMapImageFilter.h
itk::LevelSetContainerBase::Iterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetContainerBase.h:236
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetContainerConstIteratorType
typename LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType
Definition: itkLevelSetContainerBase.h:69
itk::LevelSetContainerBase::LevelSetType
TLevelSet LevelSetType
Definition: itkLevelSetContainerBase.h:56
itk::LevelSetContainerBase::ConstIterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetContainerBase.h:151
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::InputIndexType
typename LevelSetType::InputType InputIndexType
Definition: itkLevelSetContainerBase.h:58
itk::Matrix
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:52
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::GradientType
typename LevelSetType::GradientType GradientType
Definition: itkLevelSetContainerBase.h:61
itk::LevelSetContainerBase
Container of level set.
Definition: itkLevelSetContainerBase.h:42
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::DomainIteratorType
typename DomainContainerType::iterator DomainIteratorType
Definition: itkLevelSetContainerBase.h:91
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::LevelSetContainerBase::ConstIterator::operator--
ConstIterator & operator--()
Definition: itkLevelSetContainerBase.h:138
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetIdentifierType
TIdentifier LevelSetIdentifierType
Definition: itkLevelSetContainerBase.h:66
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::IdListConstIterator
typename IdListType::const_iterator IdListConstIterator
Definition: itkLevelSetContainerBase.h:79
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::HessianType
typename LevelSetType::HessianType HessianType
Definition: itkLevelSetContainerBase.h:62
itkObject.h
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::OutputRealType
typename LevelSetType::OutputRealType OutputRealType
Definition: itkLevelSetContainerBase.h:60
itk::LevelSetContainerBase::Iterator::m_Iterator
LevelSetContainerIteratorType m_Iterator
Definition: itkLevelSetContainerBase.h:264
itk::LevelSetContainerBase::Iterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetContainerBase.h:252
itk::LevelSetContainerBase::Iterator::operator--
Iterator operator--(int)
Definition: itkLevelSetContainerBase.h:229
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetPairType
std::pair< LevelSetIdentifierType, LevelSetPointer > LevelSetPairType
Definition: itkLevelSetContainerBase.h:85
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetContainerIteratorType
typename LevelSetContainerType::iterator LevelSetContainerIteratorType
Definition: itkLevelSetContainerBase.h:70
itk::LevelSetContainerBase::ConstIterator::operator--
ConstIterator operator--(int)
Definition: itkLevelSetContainerBase.h:144
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::IdListIterator
typename IdListType::iterator IdListIterator
Definition: itkLevelSetContainerBase.h:78
itk::LevelSetContainerBase::Iterator::operator++
Iterator operator++(int)
Definition: itkLevelSetContainerBase.h:216
itkHeavisideStepFunctionBase.h
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetPointer
typename LevelSetType::Pointer LevelSetPointer
Definition: itkLevelSetContainerBase.h:57
itk::LevelSetDomainMapImageFilter
Definition: itkLevelSetDomainMapImageFilter.h:40
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::LevelSetContainerBase::Iterator::operator*
Iterator & operator*()
Definition: itkLevelSetContainerBase.h:200
itk::LevelSetBase< Index< VDimension >, VDimension, TImage::PixelType, ImageBase< VDimension > >::OutputType
TImage::PixelType OutputType
Definition: itkLevelSetBase.h:59
itk::LevelSetContainerBase::Iterator::operator--
Iterator & operator--()
Definition: itkLevelSetContainerBase.h:223
itk::LevelSetContainerBase::Iterator::Iterator
Iterator(const LevelSetContainerIteratorType &it)
Definition: itkLevelSetContainerBase.h:190
itk::LevelSetContainerBase::ConstIterator::operator->
ConstIterator * operator->()
Definition: itkLevelSetContainerBase.h:120
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::LevelSetContainerBase::ConstIterator::m_Iterator
LevelSetContainerConstIteratorType m_Iterator
Definition: itkLevelSetContainerBase.h:179
itk::LevelSetContainerBase::Iterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetContainerBase.h:244
itk::LevelSetContainerBase::Iterator::Iterator
Iterator(const ConstIterator &it)
Definition: itkLevelSetContainerBase.h:193
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetDataType
typename LevelSetType::LevelSetDataType LevelSetDataType
Definition: itkLevelSetContainerBase.h:63