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 & 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 
177  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Iterator);
178 
179  bool
180  operator==(const ConstIterator & it) const
181  {
182  return (m_Iterator == it.m_Iterator);
183  }
184 
185  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
186 
189  {
190  return m_Iterator->first;
191  }
192 
194  GetEquation() const
195  {
196  return m_Iterator->second;
197  }
198 
199  private:
201  friend class Iterator;
202  };
203 
204  class Iterator
205  {
206  public:
207  Iterator() = default;
209  : m_Iterator(it)
210  {}
212  : m_Iterator(it.m_Iterator)
213  {}
214  ~Iterator() = default;
215 
216  Iterator & operator*() { return *this; }
217  Iterator * operator->() { return this; }
218 
219  Iterator &
221  {
222  ++m_Iterator;
223  return *this;
224  }
225  Iterator
227  {
228  Iterator tmp(*this);
229  ++(*this);
230  return tmp;
231  }
232  Iterator &
234  {
235  --m_Iterator;
236  return *this;
237  }
238  Iterator
240  {
241  Iterator tmp(*this);
242  --(*this);
243  return tmp;
244  }
245 
246  bool
247  operator==(const Iterator & it) const
248  {
249  return (m_Iterator == it.m_Iterator);
250  }
251 
252  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Iterator);
253 
254  bool
255  operator==(const ConstIterator & it) const
256  {
257  return (m_Iterator == it.m_Iterator);
258  }
259 
260  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
261 
264  {
265  return m_Iterator->first;
266  }
267 
269  GetEquation() const
270  {
271  return m_Iterator->second;
272  }
273 
274  private:
276  friend class ConstIterator;
277  };
278 
279  Iterator
280  Begin();
281  Iterator
282  End();
283 
285  Begin() const;
287  End() const;
288 
289 protected:
290  LevelSetEquationContainer() = default;
291  ~LevelSetEquationContainer() override = default;
292 
293  LevelSetContainerPointer m_LevelSetContainer{};
294  MapContainerType m_Container{};
295  InputImagePointer m_Input{};
296 };
297 } // namespace itk
298 
299 #ifndef ITK_MANUAL_INSTANTIATION
300 # include "itkLevelSetEquationContainer.hxx"
301 #endif
302 
303 #endif // itkLevelSetEquationContainer_h
itk::LevelSetEquationContainer::Iterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetEquationContainer.h:255
itk::LevelSetEquationContainer::ConstIterator
Definition: itkLevelSetEquationContainer.h:132
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::LevelSetEquationContainer::Iterator
Definition: itkLevelSetEquationContainer.h:204
itk::LevelSetEquationContainer::Iterator::operator*
Iterator & operator*()
Definition: itkLevelSetEquationContainer.h:216
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:208
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:188
itk::LevelSetEquationContainer::MapContainerConstIterator
typename MapContainerType::const_iterator MapContainerConstIterator
Definition: itkLevelSetEquationContainer.h:126
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:275
itk::LevelSetEquationContainer::LevelSetOutputRealType
typename TermContainerType::LevelSetOutputRealType LevelSetOutputRealType
Definition: itkLevelSetEquationContainer.h:81
itk::LevelSetEquationContainer::Iterator::operator++
Iterator & operator++()
Definition: itkLevelSetEquationContainer.h:220
itk::LevelSetEquationContainer::ConstIterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetEquationContainer.h:180
itk::LevelSetEquationContainer::Iterator::GetEquation
TermContainerType * GetEquation() const
Definition: itkLevelSetEquationContainer.h:269
itk::LevelSetEquationContainer::Iterator::GetIdentifier
LevelSetIdentifierType GetIdentifier() const
Definition: itkLevelSetEquationContainer.h:263
itk::LevelSetEquationContainer::Iterator::operator->
Iterator * operator->()
Definition: itkLevelSetEquationContainer.h:217
itk::LevelSetEquationContainer::Iterator::operator++
Iterator operator++(int)
Definition: itkLevelSetEquationContainer.h:226
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:165
itk::LevelSetEquationContainer::Iterator::operator--
Iterator & operator--()
Definition: itkLevelSetEquationContainer.h:233
itk::LevelSetEquationContainer::Iterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetEquationContainer.h:247
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:146
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:194
itk::LevelSetEquationContainer::ConstIterator::m_Iterator
MapContainerConstIterator m_Iterator
Definition: itkLevelSetEquationContainer.h:200
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:239
itk::LevelSetEquationContainer::Iterator::Iterator
Iterator(const ConstIterator &it)
Definition: itkLevelSetEquationContainer.h:211
itk::LevelSetEquationContainer::LevelSetContainerPointer
typename TermContainerType::LevelSetContainerPointer LevelSetContainerPointer
Definition: itkLevelSetEquationContainer.h:86