ITK  5.3.0
Insight Toolkit
itkLevelSetEquationContainer.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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_MOVE(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
90  AddEquation(const LevelSetIdentifierType & iId, TermContainerType * iEquation);
91 
94  GetEquation(const LevelSetIdentifierType & iId) const;
95 
97  void
98  UpdateInternalEquationTerms();
99 
101  void
102  UpdatePixel(const LevelSetInputIndexType & iP,
103  const LevelSetOutputRealType & oldValue,
104  const LevelSetOutputRealType & newValue);
105 
107  void
108  InitializeParameters();
109 
113  ComputeCFLContribution() const;
114 
116  itkSetObjectMacro(Input, InputImageType);
117  itkGetModifiableObjectMacro(Input, InputImageType);
119 
120  itkSetObjectMacro(LevelSetContainer, LevelSetContainerType);
121  itkGetModifiableObjectMacro(LevelSetContainer, LevelSetContainerType);
122 
123 protected:
124  using MapContainerType = std::map<LevelSetIdentifierType, TermContainerPointer>;
125  using MapContainerIterator = typename MapContainerType::iterator;
126  using MapContainerConstIterator = typename MapContainerType::const_iterator;
127 
128 public:
129  class Iterator;
130  friend class Iterator;
131 
133  {
134  public:
135  ConstIterator() = default;
137  : m_Iterator(it)
138  {}
139  ~ConstIterator() = default;
141  : m_Iterator(it.m_Iterator)
142  {}
143  ConstIterator & operator*() { return *this; }
144  ConstIterator * operator->() { return this; }
145  ConstIterator &
147  {
148  ++m_Iterator;
149  return *this;
150  }
153  {
154  ConstIterator tmp(*this);
155  ++(*this);
156  return tmp;
157  }
158  ConstIterator &
160  {
161  --m_Iterator;
162  return *this;
163  }
166  {
167  ConstIterator tmp(*this);
168  --(*this);
169  return tmp;
170  }
171  bool
172  operator==(const Iterator & it) const
173  {
174  return (m_Iterator == it.m_Iterator);
175  }
176  bool
177  operator!=(const Iterator & it) const
178  {
179  return (m_Iterator != it.m_Iterator);
180  }
181  bool
182  operator==(const ConstIterator & it) const
183  {
184  return (m_Iterator == it.m_Iterator);
185  }
186  bool
187  operator!=(const ConstIterator & it) const
188  {
189  return (m_Iterator != it.m_Iterator);
190  }
193  {
194  return m_Iterator->first;
195  }
196 
198  GetEquation() const
199  {
200  return m_Iterator->second;
201  }
202 
203  private:
205  friend class Iterator;
206  };
207 
208  class Iterator
209  {
210  public:
211  Iterator() = default;
213  : m_Iterator(it)
214  {}
216  : m_Iterator(it.m_Iterator)
217  {}
218  ~Iterator() = default;
219 
220  Iterator & operator*() { return *this; }
221  Iterator * operator->() { return this; }
222 
223  Iterator &
225  {
226  ++m_Iterator;
227  return *this;
228  }
229  Iterator
231  {
232  Iterator tmp(*this);
233  ++(*this);
234  return tmp;
235  }
236  Iterator &
238  {
239  --m_Iterator;
240  return *this;
241  }
242  Iterator
244  {
245  Iterator tmp(*this);
246  --(*this);
247  return tmp;
248  }
249 
250  bool
251  operator==(const Iterator & it) const
252  {
253  return (m_Iterator == it.m_Iterator);
254  }
255  bool
256  operator!=(const Iterator & it) const
257  {
258  return (m_Iterator != it.m_Iterator);
259  }
260  bool
261  operator==(const ConstIterator & it) const
262  {
263  return (m_Iterator == it.m_Iterator);
264  }
265  bool
266  operator!=(const ConstIterator & it) const
267  {
268  return (m_Iterator != it.m_Iterator);
269  }
272  {
273  return m_Iterator->first;
274  }
275 
277  GetEquation() const
278  {
279  return m_Iterator->second;
280  }
281 
282  private:
284  friend class ConstIterator;
285  };
286 
287  Iterator
288  Begin();
289  Iterator
290  End();
291 
293  Begin() const;
295  End() const;
296 
297 protected:
298  LevelSetEquationContainer() = default;
299  ~LevelSetEquationContainer() override = default;
300 
304 };
305 } // namespace itk
306 
307 #ifndef ITK_MANUAL_INSTANTIATION
308 # include "itkLevelSetEquationContainer.hxx"
309 #endif
310 
311 #endif // itkLevelSetEquationContainer_h
itk::LevelSetEquationContainer::Iterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetEquationContainer.h:261
itk::LevelSetEquationContainer::ConstIterator
Definition: itkLevelSetEquationContainer.h:132
itk::LevelSetEquationContainer::ConstIterator::operator!=
bool operator!=(const Iterator &it) const
Definition: itkLevelSetEquationContainer.h:177
itk::LevelSetEquationContainer::Iterator
Definition: itkLevelSetEquationContainer.h:208
itk::LevelSetEquationContainer::Iterator::operator*
Iterator & operator*()
Definition: itkLevelSetEquationContainer.h:220
itkObjectFactory.h
itk::LevelSetEquationContainer::ConstIterator::operator--
ConstIterator & operator--()
Definition: itkLevelSetEquationContainer.h:159
itk::LevelSetEquationContainer::InputImageType
typename TermContainerType::InputImageType InputImageType
Definition: itkLevelSetEquationContainer.h:78
itk::LevelSetEquationContainer::Iterator::Iterator
Iterator(const MapContainerIterator &it)
Definition: itkLevelSetEquationContainer.h:212
itk::LevelSetEquationContainer::ConstIterator::operator++
ConstIterator operator++(int)
Definition: itkLevelSetEquationContainer.h:152
itk::LevelSetEquationContainer::ConstIterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetEquationContainer.h:172
itk::LevelSetEquationContainer::LevelSetContainerType
typename TermContainerType::LevelSetContainerType LevelSetContainerType
Definition: itkLevelSetEquationContainer.h:85
itk::LevelSetEquationContainer::ConstIterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetEquationContainer.h:192
itk::LevelSetEquationContainer::MapContainerConstIterator
typename MapContainerType::const_iterator MapContainerConstIterator
Definition: itkLevelSetEquationContainer.h:126
itk::LevelSetEquationContainer::m_LevelSetContainer
LevelSetContainerPointer m_LevelSetContainer
Definition: itkLevelSetEquationContainer.h:301
itk::LevelSetEquationContainer::Iterator::operator!=
bool operator!=(const Iterator &it) const
Definition: itkLevelSetEquationContainer.h:256
itk::LevelSetEquationContainer::ConstIterator::operator*
ConstIterator & operator*()
Definition: itkLevelSetEquationContainer.h:143
itk::LevelSetEquationContainer::MapContainerType
std::map< LevelSetIdentifierType, TermContainerPointer > MapContainerType
Definition: itkLevelSetEquationContainer.h:124
itk::SmartPointer< Self >
itk::LevelSetEquationContainer::Iterator::m_Iterator
MapContainerIterator m_Iterator
Definition: itkLevelSetEquationContainer.h:283
itk::LevelSetEquationContainer::LevelSetOutputRealType
typename TermContainerType::LevelSetOutputRealType LevelSetOutputRealType
Definition: itkLevelSetEquationContainer.h:81
itk::LevelSetEquationContainer::Iterator::operator++
Iterator & operator++()
Definition: itkLevelSetEquationContainer.h:224
itk::LevelSetEquationContainer::ConstIterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetEquationContainer.h:182
itk::LevelSetEquationContainer::Iterator::GetEquation
TermContainerType * GetEquation() const
Definition: itkLevelSetEquationContainer.h:277
itk::LevelSetEquationContainer::Iterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetEquationContainer.h:271
itk::LevelSetEquationContainer::Iterator::operator->
Iterator * operator->()
Definition: itkLevelSetEquationContainer.h:221
itk::LevelSetEquationContainer::Iterator::operator!=
bool operator!=(const ConstIterator &it) const
Definition: itkLevelSetEquationContainer.h:266
itk::LevelSetEquationContainer::Iterator::operator++
Iterator operator++(int)
Definition: itkLevelSetEquationContainer.h:230
itk::LevelSetEquationContainer::ConstIterator::operator!=
bool operator!=(const ConstIterator &it) const
Definition: itkLevelSetEquationContainer.h:187
itk::LevelSetEquationContainer::MapContainerIterator
typename MapContainerType::iterator MapContainerIterator
Definition: itkLevelSetEquationContainer.h:125
itk::LevelSetEquationContainer::LevelSetInputIndexType
typename TermContainerType::LevelSetInputIndexType LevelSetInputIndexType
Definition: itkLevelSetEquationContainer.h:82
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::LevelSetEquationContainer::ConstIterator::operator--
ConstIterator operator--(int)
Definition: itkLevelSetEquationContainer.h:165
itk::LevelSetEquationContainer::Iterator::operator--
Iterator & operator--()
Definition: itkLevelSetEquationContainer.h:237
itk::LevelSetEquationContainer::Iterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetEquationContainer.h:251
itk::LevelSetEquationContainer::m_Container
MapContainerType m_Container
Definition: itkLevelSetEquationContainer.h:302
itk::LevelSetEquationContainer::m_Input
InputImagePointer m_Input
Definition: itkLevelSetEquationContainer.h:303
itk::LevelSetEquationContainer::InputImagePointer
typename TermContainerType::InputImagePointer InputImagePointer
Definition: itkLevelSetEquationContainer.h:79
itk::LevelSetEquationContainer::TermContainerPointer
typename TermContainerType::Pointer TermContainerPointer
Definition: itkLevelSetEquationContainer.h:76
itk::LevelSetEquationContainer::ConstIterator::ConstIterator
ConstIterator(const MapContainerConstIterator &it)
Definition: itkLevelSetEquationContainer.h:136
itk::LevelSetContainer
Container of Level-Sets.
Definition: itkLevelSetContainer.h:39
itk::LevelSetEquationContainer::TermContainerType
TTermContainer TermContainerType
Definition: itkLevelSetEquationContainer.h:75
itkObject.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::LevelSetEquationContainer::ConstIterator::operator++
ConstIterator & operator++()
Definition: itkLevelSetEquationContainer.h:146
itk::LevelSetEquationContainer::LevelSetIdentifierType
typename TermContainerType::LevelSetIdentifierType LevelSetIdentifierType
Definition: itkLevelSetEquationContainer.h:84
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::LevelSetEquationContainer::ConstIterator::GetEquation
TermContainerType * GetEquation() const
Definition: itkLevelSetEquationContainer.h:198
itk::LevelSetEquationContainer::ConstIterator::m_Iterator
MapContainerConstIterator m_Iterator
Definition: itkLevelSetEquationContainer.h:204
itk::LevelSetEquationContainer::ConstIterator::operator->
ConstIterator * operator->()
Definition: itkLevelSetEquationContainer.h:144
itk::LevelSetEquationContainer
Class for holding a set of level set equations (PDEs).
Definition: itkLevelSetEquationContainer.h:58
itk::LevelSetEquationContainer::ConstIterator::ConstIterator
ConstIterator(const Iterator &it)
Definition: itkLevelSetEquationContainer.h:140
itk::LevelSetEquationContainer::Iterator::operator--
Iterator operator--(int)
Definition: itkLevelSetEquationContainer.h:243
itk::LevelSetEquationContainer::Iterator::Iterator
Iterator(const ConstIterator &it)
Definition: itkLevelSetEquationContainer.h:215
itk::LevelSetEquationContainer::LevelSetContainerPointer
typename TermContainerType::LevelSetContainerPointer LevelSetContainerPointer
Definition: itkLevelSetEquationContainer.h:86