ITK  6.0.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  * https://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);
67  using Superclass = Object;
68 
70  itkNewMacro(Self);
71 
73  itkOverrideGetNameOfClassMacro(LevelSetEquationContainer);
74 
75  using TermContainerType = TTermContainer;
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);
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 &
145  {
146  return *this;
147  }
148  ConstIterator *
150  {
151  return this;
152  }
153  ConstIterator &
155  {
156  ++m_Iterator;
157  return *this;
158  }
161  {
162  ConstIterator tmp(*this);
163  ++(*this);
164  return tmp;
165  }
166  ConstIterator &
168  {
169  --m_Iterator;
170  return *this;
171  }
174  {
175  ConstIterator tmp(*this);
176  --(*this);
177  return tmp;
178  }
179  bool
180  operator==(const Iterator & it) const
181  {
182  return (m_Iterator == it.m_Iterator);
183  }
184 
185  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Iterator);
186 
187  bool
188  operator==(const ConstIterator & it) const
189  {
190  return (m_Iterator == it.m_Iterator);
191  }
192 
193  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
194 
197  {
198  return m_Iterator->first;
199  }
200 
202  GetEquation() const
203  {
204  return m_Iterator->second;
205  }
206 
207  private:
209  friend class Iterator;
210  };
211 
212  class Iterator
213  {
214  public:
215  Iterator() = default;
217  : m_Iterator(it)
218  {}
220  : m_Iterator(it.m_Iterator)
221  {}
222  ~Iterator() = default;
223 
224  Iterator &
226  {
227  return *this;
228  }
229  Iterator *
231  {
232  return this;
233  }
234 
235  Iterator &
237  {
238  ++m_Iterator;
239  return *this;
240  }
241  Iterator
243  {
244  Iterator tmp(*this);
245  ++(*this);
246  return tmp;
247  }
248  Iterator &
250  {
251  --m_Iterator;
252  return *this;
253  }
254  Iterator
256  {
257  Iterator tmp(*this);
258  --(*this);
259  return tmp;
260  }
261 
262  bool
263  operator==(const Iterator & it) const
264  {
265  return (m_Iterator == it.m_Iterator);
266  }
267 
268  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Iterator);
269 
270  bool
271  operator==(const ConstIterator & it) const
272  {
273  return (m_Iterator == it.m_Iterator);
274  }
275 
276  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
277 
280  {
281  return m_Iterator->first;
282  }
283 
285  GetEquation() const
286  {
287  return m_Iterator->second;
288  }
289 
290  private:
292  friend class ConstIterator;
293  };
294 
295  Iterator
296  Begin();
297  Iterator
298  End();
299 
301  Begin() const;
303  End() const;
304 
305 protected:
306  LevelSetEquationContainer() = default;
307  ~LevelSetEquationContainer() override = default;
308 
309  LevelSetContainerPointer m_LevelSetContainer{};
310  MapContainerType m_Container{};
311  InputImagePointer m_Input{};
312 };
313 } // namespace itk
314 
315 #ifndef ITK_MANUAL_INSTANTIATION
316 # include "itkLevelSetEquationContainer.hxx"
317 #endif
318 
319 #endif // itkLevelSetEquationContainer_h
itk::LevelSetEquationContainer::Iterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetEquationContainer.h:271
itk::LevelSetEquationContainer::ConstIterator
Definition: itkLevelSetEquationContainer.h:132
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::LevelSetEquationContainer::Iterator
Definition: itkLevelSetEquationContainer.h:212
itk::LevelSetEquationContainer::Iterator::operator*
Iterator & operator*()
Definition: itkLevelSetEquationContainer.h:225
itkObjectFactory.h
itk::LevelSetEquationContainer::ConstIterator::operator--
ConstIterator & operator--()
Definition: itkLevelSetEquationContainer.h:167
itk::LevelSetEquationContainer::InputImageType
typename TermContainerType::InputImageType InputImageType
Definition: itkLevelSetEquationContainer.h:78
itk::LevelSetEquationContainer::Iterator::Iterator
Iterator(const MapContainerIterator &it)
Definition: itkLevelSetEquationContainer.h:216
itk::LevelSetEquationContainer::ConstIterator::operator++
ConstIterator operator++(int)
Definition: itkLevelSetEquationContainer.h:160
itk::LevelSetEquationContainer::ConstIterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetEquationContainer.h:180
itk::LevelSetEquationContainer::LevelSetContainerType
typename TermContainerType::LevelSetContainerType LevelSetContainerType
Definition: itkLevelSetEquationContainer.h:85
itk::LevelSetEquationContainer::ConstIterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetEquationContainer.h:196
itk::LevelSetEquationContainer::MapContainerConstIterator
typename MapContainerType::const_iterator MapContainerConstIterator
Definition: itkLevelSetEquationContainer.h:126
itk::LevelSetEquationContainer::ConstIterator::operator*
ConstIterator & operator*()
Definition: itkLevelSetEquationContainer.h:144
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:291
itk::LevelSetEquationContainer::LevelSetOutputRealType
typename TermContainerType::LevelSetOutputRealType LevelSetOutputRealType
Definition: itkLevelSetEquationContainer.h:81
itk::LevelSetEquationContainer::Iterator::operator++
Iterator & operator++()
Definition: itkLevelSetEquationContainer.h:236
itk::LevelSetEquationContainer::ConstIterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetEquationContainer.h:188
itk::LevelSetEquationContainer::Iterator::GetEquation
TermContainerType * GetEquation() const
Definition: itkLevelSetEquationContainer.h:285
itk::LevelSetEquationContainer::Iterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetEquationContainer.h:279
itk::LevelSetEquationContainer::Iterator::operator->
Iterator * operator->()
Definition: itkLevelSetEquationContainer.h:230
itk::LevelSetEquationContainer::Iterator::operator++
Iterator operator++(int)
Definition: itkLevelSetEquationContainer.h:242
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:55
itk::LevelSetEquationContainer::ConstIterator::operator--
ConstIterator operator--(int)
Definition: itkLevelSetEquationContainer.h:173
itk::LevelSetEquationContainer::Iterator::operator--
Iterator & operator--()
Definition: itkLevelSetEquationContainer.h:249
itk::LevelSetEquationContainer::Iterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetEquationContainer.h:263
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: itkAnatomicalOrientation.h:29
itk::LevelSetEquationContainer::ConstIterator::operator++
ConstIterator & operator++()
Definition: itkLevelSetEquationContainer.h:154
itk::LevelSetEquationContainer::LevelSetIdentifierType
typename TermContainerType::LevelSetIdentifierType LevelSetIdentifierType
Definition: itkLevelSetEquationContainer.h:84
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::LevelSetEquationContainer::ConstIterator::GetEquation
TermContainerType * GetEquation() const
Definition: itkLevelSetEquationContainer.h:202
itk::LevelSetEquationContainer::ConstIterator::m_Iterator
MapContainerConstIterator m_Iterator
Definition: itkLevelSetEquationContainer.h:208
itk::LevelSetEquationContainer::ConstIterator::operator->
ConstIterator * operator->()
Definition: itkLevelSetEquationContainer.h:149
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:255
itk::LevelSetEquationContainer::Iterator::Iterator
Iterator(const ConstIterator &it)
Definition: itkLevelSetEquationContainer.h:219
itk::LevelSetEquationContainer::LevelSetContainerPointer
typename TermContainerType::LevelSetContainerPointer LevelSetContainerPointer
Definition: itkLevelSetEquationContainer.h:86