ITK  5.4.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 & 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 
148  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Iterator);
149 
150  bool
151  operator==(const ConstIterator & it) const
152  {
153  return (m_Iterator == it.m_Iterator);
154  }
155 
156  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
157 
160  {
161  return m_Iterator->first;
162  }
163 
164  LevelSetType *
165  GetLevelSet() const
166  {
167  return m_Iterator->second;
168  }
169 
170  private:
172  friend class Iterator;
173  };
174 
178  class Iterator
179  {
180  public:
181  Iterator() = default;
183  : m_Iterator(it)
184  {}
186  : m_Iterator(it.m_Iterator)
187  {}
188  ~Iterator() = default;
191  Iterator & operator*() { return *this; }
192  Iterator * operator->() { return this; }
193  Iterator &
195  {
196  ++m_Iterator;
197  return *this;
198  }
199  Iterator
201  {
202  Iterator tmp(*this);
203  ++(*this);
204  return tmp;
205  }
206  Iterator &
208  {
209  --m_Iterator;
210  return *this;
211  }
212  Iterator
214  {
215  Iterator tmp(*this);
216  --(*this);
217  return tmp;
218  }
219  bool
220  operator==(const Iterator & it) const
221  {
222  return (m_Iterator == it.m_Iterator);
223  }
224 
225  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Iterator);
226 
227  bool
228  operator==(const ConstIterator & it) const
229  {
230  return (m_Iterator == it.m_Iterator);
231  }
232 
233  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
234 
237  {
238  return m_Iterator->first;
239  }
240 
241  LevelSetType *
242  GetLevelSet() const
243  {
244  return m_Iterator->second;
245  }
246 
247  private:
249  friend class ConstIterator;
250  };
251 
252  Iterator
253  Begin();
254  Iterator
255  End();
256 
258  Begin() const;
260  End() const;
261 
264  Size() const;
265 
271  GetLevelSet(const LevelSetIdentifierType & iId) const;
272 
282  bool
283  AddLevelSet(const LevelSetIdentifierType & iId, LevelSetType * iLevelSet, const bool iForce = true);
284 
290  bool
291  RemoveLevelSet(const LevelSetIdentifierType & iId);
292 
294  itkSetConstObjectMacro(Heaviside, HeavisideType);
295  itkGetConstObjectMacro(Heaviside, HeavisideType);
299  itkSetObjectMacro(DomainMapFilter, DomainMapImageFilterType);
300  itkGetModifiableObjectMacro(DomainMapFilter, DomainMapImageFilterType);
304  bool
305  HasDomainMap() const;
306 
307 protected:
309  LevelSetContainerBase() = default;
310 
312  ~LevelSetContainerBase() override = default;
313 
314  const LevelSetContainerType &
315  GetContainer() const;
316  void
317  SetContainer(const LevelSetContainerType & iContainer);
318 
319 private:
320  HeavisideConstPointer m_Heaviside{};
321  DomainMapImageFilterPointer m_DomainMapFilter{};
322  LevelSetContainerType m_Container{};
323 };
324 } // namespace itk
325 
326 #ifndef ITK_MANUAL_INSTANTIATION
327 # include "itkLevelSetContainerBase.hxx"
328 #endif
329 
330 #endif // itkLevelSetContainerBase_h
itk::LevelSetContainerBase::ConstIterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetContainerBase.h:151
itk::LevelSetContainerBase::Iterator::operator++
Iterator & operator++()
Definition: itkLevelSetContainerBase.h:194
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:192
itkObjectFactory.h
itk::LevelSetContainerBase::ConstIterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetContainerBase.h:159
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:70
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:178
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:123
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:71
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:165
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:242
itk::LevelSetContainerBase::ConstIterator
Definition: itkLevelSetContainerBase.h:101
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: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:220
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::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: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:248
itk::LevelSetContainerBase::Iterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetContainerBase.h:236
itk::LevelSetContainerBase::Iterator::operator--
Iterator operator--(int)
Definition: itkLevelSetContainerBase.h:213
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:200
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:191
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:207
itk::LevelSetContainerBase::Iterator::Iterator
Iterator(const LevelSetContainerIteratorType &it)
Definition: itkLevelSetContainerBase.h:182
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:171
itk::LevelSetContainerBase::Iterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetContainerBase.h:228
itk::LevelSetContainerBase::Iterator::Iterator
Iterator(const ConstIterator &it)
Definition: itkLevelSetContainerBase.h:185
itk::LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetDataType
typename LevelSetType::LevelSetDataType LevelSetDataType
Definition: itkLevelSetContainerBase.h:63