ITK  5.2.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  * 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 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_ASSIGN(LevelSetContainerBase);
46 
50  using Superclass = Object;
51 
53  itkTypeMacro(LevelSetContainerBase, Object);
54 
56  using LevelSetType = TLevelSet;
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  {}
113 
114  ConstIterator & operator*() { return *this; }
115  ConstIterator * operator->() { return this; }
116  ConstIterator &
118  {
119  ++m_Iterator;
120  return *this;
121  }
124  {
125  ConstIterator tmp(*this);
126  ++(*this);
127  return tmp;
128  }
129  ConstIterator &
131  {
132  --m_Iterator;
133  return *this;
134  }
137  {
138  ConstIterator tmp(*this);
139  --(*this);
140  return tmp;
141  }
142  bool
143  operator==(const Iterator & it) const
144  {
145  return (m_Iterator == it.m_Iterator);
146  }
147  bool
148  operator!=(const Iterator & it) const
149  {
150  return (m_Iterator != it.m_Iterator);
151  }
152  bool
153  operator==(const ConstIterator & it) const
154  {
155  return (m_Iterator == it.m_Iterator);
156  }
157  bool
158  operator!=(const ConstIterator & it) const
159  {
160  return (m_Iterator != it.m_Iterator);
161  }
162 
165  {
166  return m_Iterator->first;
167  }
168 
169  LevelSetType *
170  GetLevelSet() const
171  {
172  return m_Iterator->second;
173  }
174 
175  private:
177  friend class Iterator;
178  };
179 
183  class Iterator
184  {
185  public:
186  Iterator() = default;
188  : m_Iterator(it)
189  {}
191  : m_Iterator(it.m_Iterator)
192  {}
193  ~Iterator() = default;
195 
196  Iterator & operator*() { return *this; }
197  Iterator * operator->() { return this; }
198  Iterator &
200  {
201  ++m_Iterator;
202  return *this;
203  }
204  Iterator
206  {
207  Iterator tmp(*this);
208  ++(*this);
209  return tmp;
210  }
211  Iterator &
213  {
214  --m_Iterator;
215  return *this;
216  }
217  Iterator
219  {
220  Iterator tmp(*this);
221  --(*this);
222  return tmp;
223  }
224  bool
225  operator==(const Iterator & it) const
226  {
227  return (m_Iterator == it.m_Iterator);
228  }
229  bool
230  operator!=(const Iterator & it) const
231  {
232  return (m_Iterator != it.m_Iterator);
233  }
234  bool
235  operator==(const ConstIterator & it) const
236  {
237  return (m_Iterator == it.m_Iterator);
238  }
239  bool
240  operator!=(const ConstIterator & it) const
241  {
242  return (m_Iterator != it.m_Iterator);
243  }
244 
247  {
248  return m_Iterator->first;
249  }
250 
251  LevelSetType *
252  GetLevelSet() const
253  {
254  return m_Iterator->second;
255  }
256 
257  private:
259  friend class ConstIterator;
260  };
261 
262  Iterator
263  Begin();
264  Iterator
265  End();
266 
268  Begin() const;
270  End() const;
271 
274  Size() const;
275 
281  GetLevelSet(const LevelSetIdentifierType & iId) const;
282 
292  bool
293  AddLevelSet(const LevelSetIdentifierType & iId, LevelSetType * iLevelSet, const bool iForce = true);
294 
300  bool
301  RemoveLevelSet(const LevelSetIdentifierType & iId);
302 
304  itkSetConstObjectMacro(Heaviside, HeavisideType);
305  itkGetConstObjectMacro(Heaviside, HeavisideType);
307 
309  itkSetObjectMacro(DomainMapFilter, DomainMapImageFilterType);
310  itkGetModifiableObjectMacro(DomainMapFilter, DomainMapImageFilterType);
312 
314  bool
315  HasDomainMap() const;
316 
317 protected:
319  LevelSetContainerBase() = default;
320 
322  ~LevelSetContainerBase() override = default;
323 
324  const LevelSetContainerType &
325  GetContainer() const;
326  void
327  SetContainer(const LevelSetContainerType & iContainer);
328 
329 private:
333 };
334 } // namespace itk
335 
336 #ifndef ITK_MANUAL_INSTANTIATION
337 # include "itkLevelSetContainerBase.hxx"
338 #endif
339 
340 #endif // itkLevelSetContainerBase_h
itk::LevelSetContainerBase::ConstIterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetContainerBase.h:153
itk::LevelSetContainerBase::Iterator::operator++
Iterator & operator++()
Definition: itkLevelSetContainerBase.h:199
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::HeavisideConstPointer
typename HeavisideType::ConstPointer HeavisideConstPointer
Definition: itkLevelSetContainerBase.h:73
itk::LevelSetContainerBase::m_Heaviside
HeavisideConstPointer m_Heaviside
Definition: itkLevelSetContainerBase.h:330
itk::LevelSetContainerBase::Iterator::operator->
Iterator * operator->()
Definition: itkLevelSetContainerBase.h:197
itkObjectFactory.h
itk::LevelSetContainerBase::ConstIterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetContainerBase.h:164
itk::LevelSetContainerBase::ConstIterator::ConstIterator
ConstIterator(const LevelSetContainerConstIteratorType &it)
Definition: itkLevelSetContainerBase.h:105
itk::LevelSetContainerBase::Iterator::operator!=
bool operator!=(const Iterator &it) const
Definition: itkLevelSetContainerBase.h:230
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetContainerType
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
Definition: itkLevelSetContainerBase.h:68
itk::LevelSetContainerBase::Iterator
Definition: itkLevelSetContainerBase.h:183
itk::LevelSetDenseImage::OutputType
typename Superclass::OutputType OutputType
Definition: itkLevelSetDenseImage.h:67
itk::LevelSetContainerBase::ConstIterator::operator++
ConstIterator operator++(int)
Definition: itkLevelSetContainerBase.h:123
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::ConstIterator::operator!=
bool operator!=(const Iterator &it) const
Definition: itkLevelSetContainerBase.h:148
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:170
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:252
itk::LevelSetContainerBase::ConstIterator
Definition: itkLevelSetContainerBase.h:101
itk::LevelSetContainerBase::m_DomainMapFilter
DomainMapImageFilterPointer m_DomainMapFilter
Definition: itkLevelSetContainerBase.h:331
itk::LevelSetContainerBase::Iterator::operator!=
bool operator!=(const ConstIterator &it) const
Definition: itkLevelSetContainerBase.h:240
itk::LevelSetContainerBase::ConstIterator::operator++
ConstIterator & operator++()
Definition: itkLevelSetContainerBase.h:117
itk::LevelSetContainerBase::ConstIterator::operator*
ConstIterator & operator*()
Definition: itkLevelSetContainerBase.h:114
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
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:54
itk::LevelSetDenseImage::GradientType
typename Superclass::GradientType GradientType
Definition: itkLevelSetDenseImage.h:69
itkLevelSetDomainMapImageFilter.h
itk::LevelSetContainerBase::ConstIterator::operator!=
bool operator!=(const ConstIterator &it) const
Definition: itkLevelSetContainerBase.h:158
itk::LevelSetContainerBase::Iterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetContainerBase.h:225
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:143
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::InputIndexType
typename LevelSetType::InputType InputIndexType
Definition: itkLevelSetContainerBase.h:58
itk::LevelSetDenseImage::LevelSetDataType
typename Superclass::LevelSetDataType LevelSetDataType
Definition: itkLevelSetDenseImage.h:71
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::LevelSetContainerBase::ConstIterator::operator--
ConstIterator & operator--()
Definition: itkLevelSetContainerBase.h:130
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:258
itk::LevelSetDenseImage::InputType
typename Superclass::InputType InputType
Definition: itkLevelSetDenseImage.h:66
itk::LevelSetContainerBase::m_Container
LevelSetContainerType m_Container
Definition: itkLevelSetContainerBase.h:332
itk::LevelSetContainerBase::Iterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetContainerBase.h:246
itk::LevelSetContainerBase::Iterator::operator--
Iterator operator--(int)
Definition: itkLevelSetContainerBase.h:218
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
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:136
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::IdListIterator
typename IdListType::iterator IdListIterator
Definition: itkLevelSetContainerBase.h:78
itk::LevelSetContainerBase::Iterator::operator++
Iterator operator++(int)
Definition: itkLevelSetContainerBase.h:205
itkHeavisideStepFunctionBase.h
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
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:86
itk::LevelSetContainerBase::Iterator::operator*
Iterator & operator*()
Definition: itkLevelSetContainerBase.h:196
itk::LevelSetContainerBase::Iterator::operator--
Iterator & operator--()
Definition: itkLevelSetContainerBase.h:212
itk::LevelSetContainerBase::Iterator::Iterator
Iterator(const LevelSetContainerIteratorType &it)
Definition: itkLevelSetContainerBase.h:187
itk::LevelSetContainerBase::ConstIterator::operator->
ConstIterator * operator->()
Definition: itkLevelSetContainerBase.h:115
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::LevelSetContainerBase::ConstIterator::m_Iterator
LevelSetContainerConstIteratorType m_Iterator
Definition: itkLevelSetContainerBase.h:176
itk::LevelSetDenseImage::HessianType
typename Superclass::HessianType HessianType
Definition: itkLevelSetDenseImage.h:70
itk::LevelSetContainerBase::Iterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetContainerBase.h:235
itk::LevelSetContainerBase::Iterator::Iterator
Iterator(const ConstIterator &it)
Definition: itkLevelSetContainerBase.h:190
itk::LevelSetDenseImage::OutputRealType
typename Superclass::OutputRealType OutputRealType
Definition: itkLevelSetDenseImage.h:68
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetDataType
typename LevelSetType::LevelSetDataType LevelSetDataType
Definition: itkLevelSetContainerBase.h:63