ITK  5.1.0
Insight Toolkit
itkLevelSetEquationTermContainer.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 itkLevelSetEquationTermContainer_h
20 #define itkLevelSetEquationTermContainer_h
21 
23 #include "itkObject.h"
24 
25 #include <unordered_map>
26 
27 #include <map>
28 #include <string>
29 
30 namespace itk
31 {
41 template <typename TInputImage, typename TLevelSetContainer>
42 class ITK_TEMPLATE_EXPORT LevelSetEquationTermContainer : public Object
43 {
44 public:
45  ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetEquationTermContainer);
46 
50  using Superclass = Object;
51 
53  itkNewMacro(Self);
54 
57 
58  using TermIdType = unsigned int;
59 
60  using InputImageType = TInputImage;
61  using InputImagePointer = typename InputImageType::Pointer;
62 
63  using LevelSetContainerType = TLevelSetContainer;
64  using LevelSetContainerPointer = typename LevelSetContainerType::Pointer;
65 
66  using LevelSetType = typename LevelSetContainerType::LevelSetType;
67  using LevelSetPointer = typename LevelSetContainerType::LevelSetPointer;
68 
69  using LevelSetIdentifierType = typename LevelSetContainerType::LevelSetIdentifierType;
70  using LevelSetOutputPixelType = typename LevelSetContainerType::OutputType;
71  using LevelSetOutputRealType = typename LevelSetContainerType::OutputRealType;
72  using LevelSetDataType = typename LevelSetContainerType::LevelSetDataType;
73  using LevelSetInputIndexType = typename LevelSetContainerType::InputIndexType;
74  using LevelSetGradientType = typename LevelSetContainerType::GradientType;
75  using LevelSetHessianType = typename LevelSetContainerType::HessianType;
76 
78  using TermPointer = typename TermType::Pointer;
79 
81  itkSetObjectMacro(Input, InputImageType);
82  itkGetModifiableObjectMacro(Input, InputImageType);
84 
85  itkSetMacro(CurrentLevelSetId, LevelSetIdentifierType);
86  itkGetMacro(CurrentLevelSetId, LevelSetIdentifierType);
87 
88  itkSetObjectMacro(LevelSetContainer, LevelSetContainerType);
89  itkGetModifiableObjectMacro(LevelSetContainer, LevelSetContainerType);
90 
92  void
93  PushTerm(TermType * iTerm);
94 
96  void
97  AddTerm(const TermIdType & iId, TermType * iTerm);
98 
100  TermType *
101  GetTerm(const TermIdType & iId);
102 
104  TermType *
105  GetTerm(const std::string & iName);
106 
108  void
109  Initialize(const LevelSetInputIndexType & iP);
110 
112  void
113  UpdatePixel(const LevelSetInputIndexType & iP,
114  const LevelSetOutputRealType & oldValue,
115  const LevelSetOutputRealType & newValue);
116 
118  void
119  InitializeParameters();
120 
123  Evaluate(const LevelSetInputIndexType & iP);
124 
126  Evaluate(const LevelSetInputIndexType & iP, const LevelSetDataType & iData);
127 
129  void
130  Update();
131 
134  ComputeCFLContribution() const;
135 
136  void
137  ComputeRequiredData(const LevelSetInputIndexType & iP, LevelSetDataType & ioData);
138 
139 protected:
140  using MapTermContainerType = std::map<TermIdType, TermPointer>;
141  using MapTermContainerIteratorType = typename MapTermContainerType::iterator;
142  using MapTermContainerConstIteratorType = typename MapTermContainerType::const_iterator;
143 
144 public:
145  class Iterator;
146  friend class Iterator;
147 
149  {
150  public:
151  ConstIterator() = default;
153  : m_Iterator(it)
154  {}
155  ~ConstIterator() = default;
157  : m_Iterator(it.m_Iterator)
158  {}
159  ConstIterator & operator*() { return *this; }
160  ConstIterator * operator->() { return this; }
161  ConstIterator &
163  {
164  ++m_Iterator;
165  return *this;
166  }
169  {
170  ConstIterator tmp(*this);
171  ++(*this);
172  return tmp;
173  }
174  ConstIterator &
176  {
177  --m_Iterator;
178  return *this;
179  }
182  {
183  ConstIterator tmp(*this);
184  --(*this);
185  return tmp;
186  }
187  bool
188  operator==(const Iterator & it) const
189  {
190  return (m_Iterator == it.m_Iterator);
191  }
192  bool
193  operator!=(const Iterator & it) const
194  {
195  return (m_Iterator != it.m_Iterator);
196  }
197  bool
198  operator==(const ConstIterator & it) const
199  {
200  return (m_Iterator == it.m_Iterator);
201  }
202  bool
203  operator!=(const ConstIterator & it) const
204  {
205  return (m_Iterator != it.m_Iterator);
206  }
207  TermIdType
209  {
210  return m_Iterator->first;
211  }
212 
213  TermType *
214  GetTerm() const
215  {
216  return m_Iterator->second;
217  }
218 
219  private:
221  friend class Iterator;
222  };
223 
224  class Iterator
225  {
226  public:
227  Iterator() = default;
229  : m_Iterator(it)
230  {}
232  : m_Iterator(it.m_Iterator)
233  {}
234  ~Iterator() = default;
235 
236  Iterator & operator*() { return *this; }
237  Iterator * operator->() { return this; }
238 
239  Iterator &
241  {
242  ++m_Iterator;
243  return *this;
244  }
245  Iterator
247  {
248  Iterator tmp(*this);
249  ++(*this);
250  return tmp;
251  }
252  Iterator &
254  {
255  --m_Iterator;
256  return *this;
257  }
258  Iterator
260  {
261  Iterator tmp(*this);
262  --(*this);
263  return tmp;
264  }
265 
266  bool
267  operator==(const Iterator & it) const
268  {
269  return (m_Iterator == it.m_Iterator);
270  }
271  bool
272  operator!=(const Iterator & it) const
273  {
274  return (m_Iterator != it.m_Iterator);
275  }
276  bool
277  operator==(const ConstIterator & it) const
278  {
279  return (m_Iterator == it.m_Iterator);
280  }
281  bool
282  operator!=(const ConstIterator & it) const
283  {
284  return (m_Iterator != it.m_Iterator);
285  }
286  TermIdType
288  {
289  return m_Iterator->first;
290  }
291 
292  TermType *
293  GetTerm() const
294  {
295  return m_Iterator->second;
296  }
297 
298  private:
300  friend class ConstIterator;
301  };
302 
303  Iterator
304  Begin();
305  Iterator
306  End();
307 
309  Begin() const;
311  End() const;
312 
313 protected:
315 
316  ~LevelSetEquationTermContainer() override = default;
317 
320 
322 
323  using HashMapStringTermContainerType = std::unordered_map<std::string, TermPointer>;
324 
326 
329 
331 
332  using MapCFLContainerType = std::map<TermIdType, LevelSetOutputRealType>;
333  using MapCFLContainerIterator = typename MapCFLContainerType::iterator;
334  using MapCFLContainerConstIterator = typename MapCFLContainerType::const_iterator;
335 
337 };
338 
339 } // namespace itk
340 #ifndef ITK_MANUAL_INSTANTIATION
341 # include "itkLevelSetEquationTermContainer.hxx"
342 #endif
343 
344 #endif // itkLevelSetEquationTermContainer_h
itk::LevelSetEquationTermBase::RequiredDataType
std::unordered_set< std::string > RequiredDataType
Definition: itkLevelSetEquationTermBase.h:140
itk::LevelSetEquationTermContainer::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkLevelSetEquationTermContainer.h:61
itk::LevelSetEquationTermContainer::Iterator::operator--
Iterator & operator--()
Definition: itkLevelSetEquationTermContainer.h:253
itk::LevelSetEquationTermContainer::ConstIterator::m_Iterator
MapTermContainerConstIteratorType m_Iterator
Definition: itkLevelSetEquationTermContainer.h:220
itk::LevelSetEquationTermContainer::ConstIterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetEquationTermContainer.h:188
itk::LevelSetEquationTermContainer::LevelSetPointer
typename LevelSetContainerType::LevelSetPointer LevelSetPointer
Definition: itkLevelSetEquationTermContainer.h:67
itk::LevelSetEquationTermContainer::Iterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetEquationTermContainer.h:277
itk::LevelSetEquationTermContainer::ConstIterator::operator!=
bool operator!=(const Iterator &it) const
Definition: itkLevelSetEquationTermContainer.h:193
itk::LevelSetEquationTermContainer::Iterator::operator!=
bool operator!=(const ConstIterator &it) const
Definition: itkLevelSetEquationTermContainer.h:282
itk::LevelSetEquationTermContainer::m_Input
InputImagePointer m_Input
Definition: itkLevelSetEquationTermContainer.h:321
itk::LevelSetEquationTermContainer::Iterator::operator++
Iterator & operator++()
Definition: itkLevelSetEquationTermContainer.h:240
itk::LevelSetEquationTermContainer::ConstIterator::ConstIterator
ConstIterator(const MapTermContainerConstIteratorType &it)
Definition: itkLevelSetEquationTermContainer.h:152
itk::LevelSetEquationTermContainer::ConstIterator::operator++
ConstIterator operator++(int)
Definition: itkLevelSetEquationTermContainer.h:168
itk::LevelSetEquationTermContainer::m_CurrentLevelSetId
LevelSetIdentifierType m_CurrentLevelSetId
Definition: itkLevelSetEquationTermContainer.h:318
itk::SmartPointer< Self >
itk::LevelSetEquationTermContainer::LevelSetDataType
typename LevelSetContainerType::LevelSetDataType LevelSetDataType
Definition: itkLevelSetEquationTermContainer.h:72
itk::LevelSetEquationTermContainer::Iterator::Iterator
Iterator(const ConstIterator &it)
Definition: itkLevelSetEquationTermContainer.h:231
itk::LevelSetEquationTermContainer::Iterator::operator->
Iterator * operator->()
Definition: itkLevelSetEquationTermContainer.h:237
itk::LevelSetEquationTermContainer::ConstIterator::operator*
ConstIterator & operator*()
Definition: itkLevelSetEquationTermContainer.h:159
itk::LevelSetEquationTermContainer::LevelSetInputIndexType
typename LevelSetContainerType::InputIndexType LevelSetInputIndexType
Definition: itkLevelSetEquationTermContainer.h:73
itk::LevelSetEquationTermContainer::LevelSetContainerPointer
typename LevelSetContainerType::Pointer LevelSetContainerPointer
Definition: itkLevelSetEquationTermContainer.h:64
itk::LevelSetEquationTermContainer::ConstIterator::operator--
ConstIterator operator--(int)
Definition: itkLevelSetEquationTermContainer.h:181
itk::LevelSetEquationTermContainer::ConstIterator::operator--
ConstIterator & operator--()
Definition: itkLevelSetEquationTermContainer.h:175
itk::LevelSetEquationTermContainer::m_NameContainer
HashMapStringTermContainerType m_NameContainer
Definition: itkLevelSetEquationTermContainer.h:325
itk::LevelSetEquationTermContainer::TermIdType
unsigned int TermIdType
Definition: itkLevelSetEquationTermContainer.h:58
itk::LevelSetEquationTermContainer::ConstIterator::ConstIterator
ConstIterator(const Iterator &it)
Definition: itkLevelSetEquationTermContainer.h:156
itk::LevelSetEquationTermContainer::LevelSetHessianType
typename LevelSetContainerType::HessianType LevelSetHessianType
Definition: itkLevelSetEquationTermContainer.h:75
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::LevelSetEquationTermContainer::LevelSetOutputRealType
typename LevelSetContainerType::OutputRealType LevelSetOutputRealType
Definition: itkLevelSetEquationTermContainer.h:71
itk::LevelSetEquationTermContainer::ConstIterator::operator->
ConstIterator * operator->()
Definition: itkLevelSetEquationTermContainer.h:160
itk::LevelSetEquationTermContainer::Iterator::GetIdentifier
TermIdType GetIdentifier() const
Definition: itkLevelSetEquationTermContainer.h:287
itk::LevelSetEquationTermContainer::m_LevelSetContainer
LevelSetContainerPointer m_LevelSetContainer
Definition: itkLevelSetEquationTermContainer.h:319
itk::LevelSetEquationTermContainer::MapCFLContainerIterator
typename MapCFLContainerType::iterator MapCFLContainerIterator
Definition: itkLevelSetEquationTermContainer.h:333
itk::LevelSetEquationTermContainer::Iterator::operator*
Iterator & operator*()
Definition: itkLevelSetEquationTermContainer.h:236
itk::LevelSetEquationTermContainer::HashMapStringTermContainerType
std::unordered_map< std::string, TermPointer > HashMapStringTermContainerType
Definition: itkLevelSetEquationTermContainer.h:323
itk::LevelSetEquationTermContainer::m_Container
MapTermContainerType m_Container
Definition: itkLevelSetEquationTermContainer.h:330
itk::LevelSetEquationTermContainer::ConstIterator::GetTerm
TermType * GetTerm() const
Definition: itkLevelSetEquationTermContainer.h:214
itk::LevelSetEquationTermContainer::ConstIterator::GetIdentifier
TermIdType GetIdentifier() const
Definition: itkLevelSetEquationTermContainer.h:208
itk::LevelSetEquationTermContainer::InputImageType
TInputImage InputImageType
Definition: itkLevelSetEquationTermContainer.h:60
itk::LevelSetEquationTermContainer::LevelSetGradientType
typename LevelSetContainerType::GradientType LevelSetGradientType
Definition: itkLevelSetEquationTermContainer.h:74
itk::LevelSetEquationTermContainer::Iterator
Definition: itkLevelSetEquationTermContainer.h:224
itk::LevelSetEquationTermContainer::ConstIterator::operator!=
bool operator!=(const ConstIterator &it) const
Definition: itkLevelSetEquationTermContainer.h:203
itk::LevelSetEquationTermContainer::LevelSetContainerType
TLevelSetContainer LevelSetContainerType
Definition: itkLevelSetEquationTermContainer.h:63
itk::LevelSetEquationTermContainer::Iterator::Iterator
Iterator(const MapTermContainerIteratorType &it)
Definition: itkLevelSetEquationTermContainer.h:228
itk::LevelSetEquationTermContainer::MapCFLContainerConstIterator
typename MapCFLContainerType::const_iterator MapCFLContainerConstIterator
Definition: itkLevelSetEquationTermContainer.h:334
itk::LevelSetEquationTermContainer::m_TermContribution
MapCFLContainerType m_TermContribution
Definition: itkLevelSetEquationTermContainer.h:336
itk::LevelSetEquationTermContainer::MapCFLContainerType
std::map< TermIdType, LevelSetOutputRealType > MapCFLContainerType
Definition: itkLevelSetEquationTermContainer.h:332
itk::LevelSetEquationTermContainer::MapTermContainerConstIteratorType
typename MapTermContainerType::const_iterator MapTermContainerConstIteratorType
Definition: itkLevelSetEquationTermContainer.h:142
itk::LevelSetContainer
Container of Level-Sets.
Definition: itkLevelSetContainer.h:39
itk::LevelSetEquationTermContainer::LevelSetOutputPixelType
typename LevelSetContainerType::OutputType LevelSetOutputPixelType
Definition: itkLevelSetEquationTermContainer.h:70
itk::LevelSetEquationTermContainer::ConstIterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkLevelSetEquationTermContainer.h:198
itk::LevelSetEquationTermContainer::m_RequiredData
RequiredDataType m_RequiredData
Definition: itkLevelSetEquationTermContainer.h:328
itk::LevelSetEquationTermContainer::Iterator::operator!=
bool operator!=(const Iterator &it) const
Definition: itkLevelSetEquationTermContainer.h:272
itkObject.h
itk::LevelSetEquationTermBase
Abstract class to represents a term in the level-set evolution PDE.
Definition: itkLevelSetEquationTermBase.h:49
itk::LevelSetEquationTermContainer::Iterator::operator--
Iterator operator--(int)
Definition: itkLevelSetEquationTermContainer.h:259
itk::LevelSetEquationTermContainer::LevelSetIdentifierType
typename LevelSetContainerType::LevelSetIdentifierType LevelSetIdentifierType
Definition: itkLevelSetEquationTermContainer.h:69
itk::LevelSetEquationTermContainer::Iterator::GetTerm
TermType * GetTerm() const
Definition: itkLevelSetEquationTermContainer.h:293
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::LevelSetEquationTermContainer::ConstIterator
Definition: itkLevelSetEquationTermContainer.h:148
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:60
itk::LevelSetEquationTermContainer::Iterator::operator++
Iterator operator++(int)
Definition: itkLevelSetEquationTermContainer.h:246
itk::LevelSetEquationTermContainer::TermPointer
typename TermType::Pointer TermPointer
Definition: itkLevelSetEquationTermContainer.h:78
itk::LevelSetEquationTermContainer::Iterator::m_Iterator
MapTermContainerIteratorType m_Iterator
Definition: itkLevelSetEquationTermContainer.h:299
itkLevelSetEquationTermBase.h
itk::LevelSetEquationTermContainer::RequiredDataType
typename TermType::RequiredDataType RequiredDataType
Definition: itkLevelSetEquationTermContainer.h:327
itk::LevelSetEquationTermContainer::MapTermContainerIteratorType
typename MapTermContainerType::iterator MapTermContainerIteratorType
Definition: itkLevelSetEquationTermContainer.h:141
itk::LevelSetEquationTermContainer::MapTermContainerType
std::map< TermIdType, TermPointer > MapTermContainerType
Definition: itkLevelSetEquationTermContainer.h:140
itk::LevelSetEquationTermContainer::Iterator::operator==
bool operator==(const Iterator &it) const
Definition: itkLevelSetEquationTermContainer.h:267
itk::LevelSetEquationTermContainer
Class for container holding the terms of a given level set update equation.
Definition: itkLevelSetEquationTermContainer.h:42
itk::LevelSetEquationTermContainer::LevelSetType
typename LevelSetContainerType::LevelSetType LevelSetType
Definition: itkLevelSetEquationTermContainer.h:66
itk::LevelSetEquationTermContainer::ConstIterator::operator++
ConstIterator & operator++()
Definition: itkLevelSetEquationTermContainer.h:162