ITK  4.4.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< class TIdentifier, class 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 & ); // purposely not implemented
288  void operator = ( const Self & ); // purposely not implemented
289 
293 };
294 }
295 
296 #ifndef ITK_MANUAL_INSTANTIATION
297 #include "itkLevelSetContainerBase.hxx"
298 #endif
299 
300 #endif // __itkLevelSetContainerBase_h
301