ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLevelSetContainerBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
101  {
102  public:
103  ConstIterator( ) = default;
104  ConstIterator( const LevelSetContainerConstIteratorType& it ) : m_Iterator( it ) {}
105  ~ConstIterator() = default;
106  ConstIterator( const Iterator& it ) : m_Iterator( it.m_Iterator ) {}
107 
108  ConstIterator & operator * () { return *this; }
109  ConstIterator * operator->() { return this; }
111  {
112  ++m_Iterator;
113  return *this;
114  }
116  {
117  ConstIterator tmp( *this );
118  ++(*this);
119  return tmp;
120  }
122  {
123  --m_Iterator;
124  return *this;
125  }
127  {
128  ConstIterator tmp( *this );
129  --(*this);
130  return tmp;
131  }
132  bool operator==(const Iterator& it) const
133  {
134  return ( m_Iterator == it.m_Iterator );
135  }
136  bool operator!=(const Iterator& it) const
137  {
138  return (m_Iterator != it.m_Iterator );
139  }
140  bool operator==(const ConstIterator& it) const
141  {
142  return ( m_Iterator == it.m_Iterator );
143  }
144  bool operator!=(const ConstIterator& it) const
145  {
146  return (m_Iterator != it.m_Iterator );
147  }
148 
150  {
151  return m_Iterator->first;
152  }
153 
155  {
156  return m_Iterator->second;
157  }
158 
159  private:
161  friend class Iterator;
162  };
163 
166  class Iterator
167  {
168  public:
169  Iterator( ) = default;
170  Iterator( const LevelSetContainerIteratorType& it ) : m_Iterator( it ) {}
171  Iterator( const ConstIterator& it ) : m_Iterator( it.m_Iterator ) {}
172  ~Iterator() = default;
173 
174  Iterator & operator * () { return *this; }
175  Iterator * operator->() { return this; }
177  {
178  ++m_Iterator;
179  return *this;
180  }
182  {
183  Iterator tmp( *this );
184  ++(*this);
185  return tmp;
186  }
188  {
189  --m_Iterator;
190  return *this;
191  }
193  {
194  Iterator tmp( *this );
195  --(*this);
196  return tmp;
197  }
198  bool operator==(const Iterator& it) const
199  {
200  return ( m_Iterator == it.m_Iterator );
201  }
202  bool operator!=(const Iterator& it) const
203  {
204  return (m_Iterator != it.m_Iterator );
205  }
206  bool operator==(const ConstIterator& it) const
207  {
208  return ( m_Iterator == it.m_Iterator );
209  }
210  bool operator!=(const ConstIterator& it) const
211  {
212  return (m_Iterator != it.m_Iterator );
213  }
214 
216  {
217  return m_Iterator->first;
218  }
219 
221  {
222  return m_Iterator->second;
223  }
224 
225  private:
227  friend class ConstIterator;
228  };
229 
230  Iterator Begin();
231  Iterator End();
232 
233  ConstIterator Begin() const;
234  ConstIterator End() const;
235 
238 
243  LevelSetPointer GetLevelSet( const LevelSetIdentifierType& iId ) const;
244 
254  bool AddLevelSet( const LevelSetIdentifierType& iId,
255  LevelSetType * iLevelSet,
256  const bool iForce = true );
257 
263  bool RemoveLevelSet( const LevelSetIdentifierType& iId );
264 
266  itkSetConstObjectMacro( Heaviside, HeavisideType );
267  itkGetConstObjectMacro(Heaviside, HeavisideType );
269 
271  itkSetObjectMacro( DomainMapFilter, DomainMapImageFilterType );
272  itkGetModifiableObjectMacro(DomainMapFilter, DomainMapImageFilterType );
274 
276  bool HasDomainMap() const;
277 
278 protected:
280  LevelSetContainerBase() = default;
281 
283  ~LevelSetContainerBase() override = default;
284 
285  const LevelSetContainerType& GetContainer() const;
286  void SetContainer( const LevelSetContainerType& iContainer );
287 
288 private:
292 };
293 }
294 
295 #ifndef ITK_MANUAL_INSTANTIATION
296 #include "itkLevelSetContainerBase.hxx"
297 #endif
298 
299 #endif // itkLevelSetContainerBase_h
std::pair< LevelSetIdentifierType, LevelSetPointer > LevelSetPairType
Light weight base class for most itk classes.
LevelSetIdentifierType GetIdentifier() const
Specifies an image region where an unique std::list of level sets Id&#39;s are defined.
bool operator!=(const ConstIterator &it) const
bool operator!=(const Iterator &it) const
typename Superclass::HessianType HessianType
DomainMapImageFilterPointer m_DomainMapFilter
CovariantVector< T, NVectorDimension > operator*(const T &scalar, const CovariantVector< T, NVectorDimension > &v)
ConstIterator(const LevelSetContainerConstIteratorType &it)
LevelSetContainerConstIteratorType m_Iterator
std::map< LevelSetIdentifierType, LevelSetDomainType > DomainContainerType
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
typename Superclass::OutputType OutputType
bool operator==(const ConstIterator &it) const
typename Superclass::InputType InputType
typename LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType
bool operator==(const Iterator &it) const
typename Superclass::GradientType GradientType
typename Superclass::LevelSetDataType LevelSetDataType
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:68
Base class for the &quot;dense&quot; representation of a level-set function on one image.
Iterator(const LevelSetContainerIteratorType &it)
typename DomainMapImageFilterType::LevelSetDomain LevelSetDomainType
typename Superclass::OutputRealType OutputRealType
bool operator!=(const ConstIterator &it) const
Base class for most ITK classes.
Definition: itkObject.h:60
Templated n-dimensional image class.
Definition: itkImage.h:75
bool operator==(const ConstIterator &it) const
LevelSetContainerIteratorType m_Iterator
Base class of the Heaviside function.