ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkLevelSetEquationContainer.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 itkLevelSetEquationContainer_h
20 #define itkLevelSetEquationContainer_h
21 
22 #include "itkObject.h"
23 #include "itkObjectFactory.h"
24 
25 namespace itk
26 {
57 template< typename TTermContainer >
58 class ITK_TEMPLATE_EXPORT LevelSetEquationContainer : public Object
59 {
60 public:
64  typedef Object Superclass;
66 
68  itkNewMacro( Self );
69 
72 
73  typedef TTermContainer TermContainerType;
74  typedef typename TermContainerType::Pointer TermContainerPointer;
75 
76  typedef typename TermContainerType::InputImageType InputImageType;
77  typedef typename TermContainerType::InputImagePointer InputImagePointer;
78 
79  typedef typename TermContainerType::LevelSetOutputRealType LevelSetOutputRealType;
80  typedef typename TermContainerType::LevelSetInputIndexType LevelSetInputIndexType;
81 
82  typedef typename TermContainerType::LevelSetIdentifierType LevelSetIdentifierType;
83  typedef typename TermContainerType::LevelSetContainerType LevelSetContainerType;
84  typedef typename TermContainerType::LevelSetContainerPointer LevelSetContainerPointer;
85 
87  void AddEquation( const LevelSetIdentifierType& iId, TermContainerType * iEquation );
88 
90  TermContainerType * GetEquation( const LevelSetIdentifierType& iId ) const;
91 
93  void UpdateInternalEquationTerms();
94 
96  void UpdatePixel( const LevelSetInputIndexType & iP,
97  const LevelSetOutputRealType & oldValue,
98  const LevelSetOutputRealType & newValue );
99 
101  void InitializeParameters();
102 
105  LevelSetOutputRealType ComputeCFLContribution() const;
106 
108  itkSetObjectMacro( Input, InputImageType );
109  itkGetModifiableObjectMacro(Input, InputImageType );
111 
112  itkSetObjectMacro( LevelSetContainer, LevelSetContainerType );
113  itkGetModifiableObjectMacro(LevelSetContainer, LevelSetContainerType );
114 
115 protected:
116  typedef std::map< LevelSetIdentifierType, TermContainerPointer > MapContainerType;
117  typedef typename MapContainerType::iterator MapContainerIterator;
118  typedef typename MapContainerType::const_iterator MapContainerConstIterator;
119 
120 public:
121  class Iterator;
122  friend class Iterator;
123 
125  {
126  public:
128  ConstIterator( const MapContainerConstIterator& it ) : m_Iterator( it ) {}
130  ConstIterator( const Iterator& it ) : m_Iterator( it.m_Iterator ) {}
131  ConstIterator & operator * () { return *this; }
132  ConstIterator * operator->() { return this; }
134  {
135  ++m_Iterator;
136  return *this;
137  }
139  {
140  ConstIterator tmp( *this );
141  ++(*this);
142  return tmp;
143  }
145  {
146  --m_Iterator;
147  return *this;
148  }
150  {
151  ConstIterator tmp( *this );
152  --(*this);
153  return tmp;
154  }
155  bool operator == (const Iterator& it) const
156  {
157  return (m_Iterator == it.m_Iterator);
158  }
159  bool operator != (const Iterator& it) const
160  {
161  return (m_Iterator != it.m_Iterator);
162  }
163  bool operator == (const ConstIterator& it) const
164  {
165  return (m_Iterator == it.m_Iterator);
166  }
167  bool operator != (const ConstIterator& it) const
168  {
169  return (m_Iterator != it.m_Iterator);
170  }
172  {
173  return m_Iterator->first;
174  }
175 
177  {
178  return m_Iterator->second;
179  }
180  private:
182  friend class Iterator;
183  };
184 
185  class Iterator
186  {
187  public:
188  Iterator() {}
189  Iterator( const MapContainerIterator& it ) : m_Iterator( it ) {}
190  Iterator( const ConstIterator& it ) : m_Iterator( it.m_Iterator ) {}
192 
193  Iterator & operator * () { return *this; }
194  Iterator * operator ->() { return this; }
195 
197  {
198  ++m_Iterator;
199  return *this;
200  }
202  {
203  Iterator tmp( *this );
204  ++(*this);
205  return tmp;
206  }
208  {
209  --m_Iterator;
210  return *this;
211  }
213  {
214  Iterator tmp( *this );
215  --(*this);
216  return tmp;
217  }
218 
219  bool operator==(const Iterator& it) const
220  {
221  return (m_Iterator==it.m_Iterator);
222  }
223  bool operator!=(const Iterator& it) const
224  {
225  return (m_Iterator!=it.m_Iterator);
226  }
227  bool operator==(const ConstIterator& it)const
228  {
229  return (m_Iterator == it.m_Iterator);
230  }
231  bool operator!=(const ConstIterator& it)const
232  {
233  return (m_Iterator != it.m_Iterator);
234  }
236  {
237  return m_Iterator->first;
238  }
239 
241  {
242  return m_Iterator->second;
243  }
244  private:
246  friend class ConstIterator;
247  };
248 
249  Iterator Begin();
250  Iterator End();
251 
252  ConstIterator Begin() const;
253  ConstIterator End() const;
254 
255 protected:
256 
258  virtual ~LevelSetEquationContainer() ITK_OVERRIDE;
259 
260  LevelSetContainerPointer m_LevelSetContainer;
261  MapContainerType m_Container;
263 
264 private:
265  ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetEquationContainer);
266 
267 };
268 }
269 
270 #ifndef ITK_MANUAL_INSTANTIATION
271 #include "itkLevelSetEquationContainer.hxx"
272 #endif
273 
274 #endif // itkLevelSetEquationContainer_h
bool operator!=(const ImageRegionCopier< D1, D2 > &c1, const ImageRegionCopier< D1, D2 > &c2)
TermContainerType::LevelSetOutputRealType LevelSetOutputRealType
TermContainerType::LevelSetInputIndexType LevelSetInputIndexType
Light weight base class for most itk classes.
TermContainerType::Pointer TermContainerPointer
TermContainerType::InputImagePointer InputImagePointer
TermContainerType::InputImageType InputImageType
CovariantVector< T, NVectorDimension > operator*(const T &scalar, const CovariantVector< T, NVectorDimension > &v)
std::map< LevelSetIdentifierType, TermContainerPointer > MapContainerType
TermContainerType::LevelSetContainerPointer LevelSetContainerPointer
MapContainerType::const_iterator MapContainerConstIterator
MapContainerType::iterator MapContainerIterator
bool operator!=(const ConstIterator &it) const
bool operator==(const ConstIterator &it) const
Container of Level-Sets.
Class for holding a set of level set equations (PDEs).
TermContainerType::LevelSetContainerType LevelSetContainerType
TermContainerType::LevelSetIdentifierType LevelSetIdentifierType
Base class for most ITK classes.
Definition: itkObject.h:59
bool ITKIOXML_EXPORT operator==(itk::FancyString &s, const std::string &)