ITK  4.9.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 >
43 {
44 public:
48  typedef Object Superclass;
49 
51  itkTypeMacro ( LevelSetContainerBase, Object );
52 
54  typedef TLevelSet LevelSetType;
62 
64  typedef TIdentifier LevelSetIdentifierType;
65 
66  typedef std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType;
67  typedef typename LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType;
68  typedef typename LevelSetContainerType::iterator LevelSetContainerIteratorType;
69 
72 
73  itkStaticConstMacro ( Dimension, unsigned int, LevelSetType::Dimension );
74 
75  typedef std::list< LevelSetIdentifierType > IdListType;
76  typedef typename IdListType::iterator IdListIterator;
77  typedef typename IdListType::const_iterator IdListConstIterator;
80 
82 
83  typedef std::pair< LevelSetIdentifierType, LevelSetPointer > LevelSetPairType;
84 
87 
88  typedef std::map< LevelSetIdentifierType, LevelSetDomainType > DomainContainerType;
89  typedef typename DomainContainerType::iterator DomainIteratorType;
90 
92  class Iterator;
93  friend class Iterator;
94 
99  {
100  public:
104  ConstIterator( const Iterator& it ) : m_Iterator( it.m_Iterator ) {}
105 
106  ConstIterator & operator * () { return *this; }
107  ConstIterator * operator->() { return this; }
109  {
110  ++m_Iterator;
111  return *this;
112  }
114  {
115  ConstIterator tmp( *this );
116  ++(*this);
117  return tmp;
118  }
120  {
121  --m_Iterator;
122  return *this;
123  }
125  {
126  ConstIterator tmp( *this );
127  --(*this);
128  return tmp;
129  }
130  bool operator==(const Iterator& it) const
131  {
132  return ( m_Iterator == it.m_Iterator );
133  }
134  bool operator!=(const Iterator& it) const
135  {
136  return (m_Iterator != it.m_Iterator );
137  }
138  bool operator==(const ConstIterator& it) const
139  {
140  return ( m_Iterator == it.m_Iterator );
141  }
142  bool operator!=(const ConstIterator& it) const
143  {
144  return (m_Iterator != it.m_Iterator );
145  }
146 
148  {
149  return m_Iterator->first;
150  }
151 
153  {
154  return m_Iterator->second;
155  }
156 
157  private:
159  friend class Iterator;
160  };
161 
164  class Iterator
165  {
166  public:
167  Iterator( ) {}
169  Iterator( const ConstIterator& it ) : m_Iterator( it.m_Iterator ) {}
171 
172  Iterator & operator * () { return *this; }
173  Iterator * operator->() { return this; }
175  {
176  ++m_Iterator;
177  return *this;
178  }
180  {
181  Iterator tmp( *this );
182  ++(*this);
183  return tmp;
184  }
186  {
187  --m_Iterator;
188  return *this;
189  }
191  {
192  Iterator tmp( *this );
193  --(*this);
194  return tmp;
195  }
196  bool operator==(const Iterator& it) const
197  {
198  return ( m_Iterator == it.m_Iterator );
199  }
200  bool operator!=(const Iterator& it) const
201  {
202  return (m_Iterator != it.m_Iterator );
203  }
204  bool operator==(const ConstIterator& it) const
205  {
206  return ( m_Iterator == it.m_Iterator );
207  }
208  bool operator!=(const ConstIterator& it) const
209  {
210  return (m_Iterator != it.m_Iterator );
211  }
212 
214  {
215  return m_Iterator->first;
216  }
217 
219  {
220  return m_Iterator->second;
221  }
222 
223  private:
225  friend class ConstIterator;
226  };
227 
228  Iterator Begin();
229  Iterator End();
230 
231  ConstIterator Begin() const;
232  ConstIterator End() const;
233 
236 
242 
252  bool AddLevelSet( const LevelSetIdentifierType& iId,
253  LevelSetType * iLevelSet,
254  const bool iForce = true );
255 
261  bool RemoveLevelSet( const LevelSetIdentifierType& iId );
262 
264  itkSetConstObjectMacro( Heaviside, HeavisideType );
265  itkGetConstObjectMacro(Heaviside, HeavisideType );
267 
269  itkSetObjectMacro( DomainMapFilter, DomainMapImageFilterType );
270  itkGetModifiableObjectMacro(DomainMapFilter, DomainMapImageFilterType );
272 
274  bool HasDomainMap() const;
275 
276 protected:
279 
282 
283  const LevelSetContainerType& GetContainer() const;
284  void SetContainer( const LevelSetContainerType& iContainer );
285 
286 private:
287  LevelSetContainerBase( const Self & ) ITK_DELETE_FUNCTION;
288  void operator = ( const Self & ) ITK_DELETE_FUNCTION;
289 
293 };
294 }
295 
296 #ifndef ITK_MANUAL_INSTANTIATION
297 #include "itkLevelSetContainerBase.hxx"
298 #endif
299 
300 #endif // itkLevelSetContainerBase_h
DomainMapImageFilterType::Pointer DomainMapImageFilterPointer
Light weight base class for most itk classes.
LevelSetContainerBase()
Default Constructor.
LevelSetType::GradientType GradientType
LevelSetIdentifierType GetIdentifier() const
Specifies an image region where an unique std::list of level sets Id&#39;s are defined.
LevelSetContainerType::iterator LevelSetContainerIteratorType
LevelSetType::HessianType HessianType
Superclass::OutputRealType OutputRealType
bool operator!=(const ConstIterator &it) const
bool operator!=(const Iterator &it) const
LevelSetIdentifierType Size() const
HeavisideStepFunctionBase< OutputRealType, OutputRealType > HeavisideType
LevelSetType::LevelSetDataType LevelSetDataType
LevelSetPointer GetLevelSet(const LevelSetIdentifierType &iId) const
Get the level set function given its id.
DomainMapImageFilterPointer m_DomainMapFilter
ConstIterator(const LevelSetContainerConstIteratorType &it)
bool RemoveLevelSet(const LevelSetIdentifierType &iId)
Remove one level set function given its id.
LevelSetContainerConstIteratorType m_Iterator
const LevelSetContainerType & GetContainer() const
bool operator==(const ConstIterator &it) const
Superclass::OutputType OutputType
Superclass::HessianType HessianType
bool AddLevelSet(const LevelSetIdentifierType &iId, LevelSetType *iLevelSet, const bool iForce=true)
Add one level set function given its id.
Superclass::InputType InputType
HeavisideType::ConstPointer HeavisideConstPointer
SmartPointer< const Self > ConstPointer
bool operator==(const Iterator &it) const
Superclass::LevelSetDataType LevelSetDataType
LevelSetType::OutputType OutputType
static const unsigned int Dimension
Iterator(const LevelSetContainerIteratorType &it)
LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType
IdListType::const_iterator IdListConstIterator
LevelSetType::Pointer LevelSetPointer
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
DomainMapImageFilterType::LevelSetDomain LevelSetDomainType
std::map< LevelSetIdentifierType, LevelSetDomainType > DomainContainerType
Image< short, Dimension > CacheImageType
DomainContainerType::iterator DomainIteratorType
~LevelSetContainerBase()
Default Destructor.
LevelSetDomainMapImageFilter< IdListImageType, CacheImageType > DomainMapImageFilterType
LevelSetType::InputType InputIndexType
Image< IdListType, Dimension > IdListImageType
bool operator!=(const ConstIterator &it) const
Superclass::GradientType GradientType
std::pair< LevelSetIdentifierType, LevelSetPointer > LevelSetPairType
Base class for most ITK classes.
Definition: itkObject.h:57
Templated n-dimensional image class.
Definition: itkImage.h:75
bool operator==(const ConstIterator &it) const
std::list< LevelSetIdentifierType > IdListType
void SetContainer(const LevelSetContainerType &iContainer)
LevelSetContainerIteratorType m_Iterator
Base class of the Heaviside function.
LevelSetType::OutputRealType OutputRealType