ITK  5.0.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:
61  ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetEquationContainer);
63 
67  using Superclass = Object;
68 
70  itkNewMacro( Self );
71 
73  itkTypeMacro( LevelSetEquationContainer, Object );
74 
75  using TermContainerType = TTermContainer;
76  using TermContainerPointer = typename TermContainerType::Pointer;
77 
78  using InputImageType = typename TermContainerType::InputImageType;
79  using InputImagePointer = typename TermContainerType::InputImagePointer;
80 
81  using LevelSetOutputRealType = typename TermContainerType::LevelSetOutputRealType;
82  using LevelSetInputIndexType = typename TermContainerType::LevelSetInputIndexType;
83 
84  using LevelSetIdentifierType = typename TermContainerType::LevelSetIdentifierType;
85  using LevelSetContainerType = typename TermContainerType::LevelSetContainerType;
86  using LevelSetContainerPointer = typename TermContainerType::LevelSetContainerPointer;
87 
89  void AddEquation( const LevelSetIdentifierType& iId, TermContainerType * iEquation );
90 
92  TermContainerType * GetEquation( const LevelSetIdentifierType& iId ) const;
93 
95  void UpdateInternalEquationTerms();
96 
98  void UpdatePixel( const LevelSetInputIndexType & iP,
99  const LevelSetOutputRealType & oldValue,
100  const LevelSetOutputRealType & newValue );
101 
103  void InitializeParameters();
104 
107  LevelSetOutputRealType ComputeCFLContribution() const;
108 
110  itkSetObjectMacro( Input, InputImageType );
111  itkGetModifiableObjectMacro(Input, InputImageType );
113 
114  itkSetObjectMacro( LevelSetContainer, LevelSetContainerType );
115  itkGetModifiableObjectMacro(LevelSetContainer, LevelSetContainerType );
116 
117 protected:
118  using MapContainerType = std::map< LevelSetIdentifierType, TermContainerPointer >;
119  using MapContainerIterator = typename MapContainerType::iterator;
120  using MapContainerConstIterator = typename MapContainerType::const_iterator;
121 
122 public:
123  class Iterator;
124  friend class Iterator;
125 
127  {
128  public:
129  ConstIterator() = default;
130  ConstIterator( const MapContainerConstIterator& it ) : m_Iterator( it ) {}
131  ~ConstIterator() = default;
132  ConstIterator( const Iterator& it ) : m_Iterator( it.m_Iterator ) {}
133  ConstIterator & operator * () { return *this; }
134  ConstIterator * operator->() { return this; }
136  {
137  ++m_Iterator;
138  return *this;
139  }
141  {
142  ConstIterator tmp( *this );
143  ++(*this);
144  return tmp;
145  }
147  {
148  --m_Iterator;
149  return *this;
150  }
152  {
153  ConstIterator tmp( *this );
154  --(*this);
155  return tmp;
156  }
157  bool operator == (const Iterator& it) const
158  {
159  return (m_Iterator == it.m_Iterator);
160  }
161  bool operator != (const Iterator& it) const
162  {
163  return (m_Iterator != it.m_Iterator);
164  }
165  bool operator == (const ConstIterator& it) const
166  {
167  return (m_Iterator == it.m_Iterator);
168  }
169  bool operator != (const ConstIterator& it) const
170  {
171  return (m_Iterator != it.m_Iterator);
172  }
174  {
175  return m_Iterator->first;
176  }
177 
179  {
180  return m_Iterator->second;
181  }
182  private:
184  friend class Iterator;
185  };
186 
187  class Iterator
188  {
189  public:
190  Iterator() = default;
191  Iterator( const MapContainerIterator& it ) : m_Iterator( it ) {}
192  Iterator( const ConstIterator& it ) : m_Iterator( it.m_Iterator ) {}
193  ~Iterator() = default;
194 
195  Iterator & operator * () { return *this; }
196  Iterator * operator ->() { return this; }
197 
199  {
200  ++m_Iterator;
201  return *this;
202  }
204  {
205  Iterator tmp( *this );
206  ++(*this);
207  return tmp;
208  }
210  {
211  --m_Iterator;
212  return *this;
213  }
215  {
216  Iterator tmp( *this );
217  --(*this);
218  return tmp;
219  }
220 
221  bool operator==(const Iterator& it) const
222  {
223  return (m_Iterator==it.m_Iterator);
224  }
225  bool operator!=(const Iterator& it) const
226  {
227  return (m_Iterator!=it.m_Iterator);
228  }
229  bool operator==(const ConstIterator& it)const
230  {
231  return (m_Iterator == it.m_Iterator);
232  }
233  bool operator!=(const ConstIterator& it)const
234  {
235  return (m_Iterator != it.m_Iterator);
236  }
238  {
239  return m_Iterator->first;
240  }
241 
243  {
244  return m_Iterator->second;
245  }
246  private:
248  friend class ConstIterator;
249  };
250 
251  Iterator Begin();
252  Iterator End();
253 
254  ConstIterator Begin() const;
255  ConstIterator End() const;
256 
257 protected:
258 
259  LevelSetEquationContainer() = default;
260  ~LevelSetEquationContainer() override = default;
261 
265 };
266 }
267 
268 #ifndef ITK_MANUAL_INSTANTIATION
269 #include "itkLevelSetEquationContainer.hxx"
270 #endif
271 
272 #endif // itkLevelSetEquationContainer_h
bool operator==(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:485
typename MapContainerType::const_iterator MapContainerConstIterator
Light weight base class for most itk classes.
typename TermContainerType::LevelSetInputIndexType LevelSetInputIndexType
CovariantVector< T, NVectorDimension > operator*(const T &scalar, const CovariantVector< T, NVectorDimension > &v)
typename TermContainerType::LevelSetOutputRealType LevelSetOutputRealType
typename TermContainerType::InputImageType InputImageType
typename TermContainerType::InputImagePointer InputImagePointer
bool operator!=(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:492
bool operator!=(const ConstIterator &it) const
typename TermContainerType::Pointer TermContainerPointer
typename MapContainerType::iterator MapContainerIterator
typename TermContainerType::LevelSetIdentifierType LevelSetIdentifierType
bool operator==(const ConstIterator &it) const
Container of Level-Sets.
Class for holding a set of level set equations (PDEs).
std::map< LevelSetIdentifierType, TermContainerPointer > MapContainerType
typename TermContainerType::LevelSetContainerPointer LevelSetContainerPointer
typename TermContainerType::LevelSetContainerType LevelSetContainerType
Base class for most ITK classes.
Definition: itkObject.h:60