ITK  6.0.0
Insight Toolkit
itkLevelSetContainerBase.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 itkLevelSetContainerBase_h
20#define itkLevelSetContainerBase_h
21
22#include <map>
23#include "itkObject.h"
24#include "itkObjectFactory.h"
27
28
29namespace itk
30{
41template <typename TIdentifier, typename TLevelSet>
42class ITK_TEMPLATE_EXPORT LevelSetContainerBase : public Object
43{
44public:
45 ITK_DISALLOW_COPY_AND_MOVE(LevelSetContainerBase);
46
51
53 itkOverrideGetNameOfClassMacro(LevelSetContainerBase);
54
56 using LevelSetType = TLevelSet;
58 using InputIndexType = typename LevelSetType::InputType;
59 using OutputType = typename LevelSetType::OutputType;
60 using OutputRealType = typename LevelSetType::OutputRealType;
61 using GradientType = typename LevelSetType::GradientType;
62 using HessianType = typename LevelSetType::HessianType;
63 using LevelSetDataType = typename LevelSetType::LevelSetDataType;
64
66 using LevelSetIdentifierType = TIdentifier;
67
68 using LevelSetContainerType = std::map<LevelSetIdentifierType, LevelSetPointer>;
69 using LevelSetContainerConstIteratorType = typename LevelSetContainerType::const_iterator;
70 using LevelSetContainerIteratorType = typename LevelSetContainerType::iterator;
71
74
75 static constexpr unsigned int Dimension = LevelSetType::Dimension;
76
77 using IdListType = std::list<LevelSetIdentifierType>;
78 using IdListIterator = typename IdListType::iterator;
79 using IdListConstIterator = typename IdListType::const_iterator;
82
84
85 using LevelSetPairType = std::pair<LevelSetIdentifierType, LevelSetPointer>;
86
89
90 using DomainContainerType = std::map<LevelSetIdentifierType, LevelSetDomainType>;
91 using DomainIteratorType = typename DomainContainerType::iterator;
92
94 class Iterator;
95 friend class Iterator;
96
102 {
103 public:
104 ConstIterator() = default;
106 : m_Iterator(it)
107 {}
108 ~ConstIterator() = default;
110 : m_Iterator(it.m_Iterator)
111 {}
114 ConstIterator & operator*() { return *this; }
115 ConstIterator * operator->() { return this; }
118 {
119 ++m_Iterator;
120 return *this;
121 }
124 {
125 ConstIterator tmp(*this);
126 ++(*this);
127 return tmp;
128 }
131 {
132 --m_Iterator;
133 return *this;
134 }
137 {
138 ConstIterator tmp(*this);
139 --(*this);
140 return tmp;
141 }
142 bool
143 operator==(const Iterator & it) const
144 {
145 return (m_Iterator == it.m_Iterator);
146 }
147
149
150 bool
151 operator==(const ConstIterator & it) const
152 {
153 return (m_Iterator == it.m_Iterator);
154 }
155
157
160 {
161 return m_Iterator->first;
162 }
163
166 {
167 return m_Iterator->second;
168 }
169
170 private:
172 friend class Iterator;
173 };
174
179 {
180 public:
181 Iterator() = default;
183 : m_Iterator(it)
184 {}
186 : m_Iterator(it.m_Iterator)
187 {}
188 ~Iterator() = default;
191 Iterator & operator*() { return *this; }
192 Iterator * operator->() { return this; }
193 Iterator &
195 {
196 ++m_Iterator;
197 return *this;
198 }
201 {
202 Iterator tmp(*this);
203 ++(*this);
204 return tmp;
205 }
206 Iterator &
208 {
209 --m_Iterator;
210 return *this;
211 }
214 {
215 Iterator tmp(*this);
216 --(*this);
217 return tmp;
218 }
219 bool
220 operator==(const Iterator & it) const
221 {
222 return (m_Iterator == it.m_Iterator);
223 }
224
226
227 bool
228 operator==(const ConstIterator & it) const
229 {
230 return (m_Iterator == it.m_Iterator);
231 }
232
234
237 {
238 return m_Iterator->first;
239 }
240
243 {
244 return m_Iterator->second;
245 }
246
247 private:
249 friend class ConstIterator;
250 };
251
256
258 Begin() const;
260 End() const;
261
264 Size() const;
265
272
282 bool
283 AddLevelSet(const LevelSetIdentifierType & iId, LevelSetType * iLevelSet, const bool iForce = true);
284
290 bool
292
294 itkSetConstObjectMacro(Heaviside, HeavisideType);
295 itkGetConstObjectMacro(Heaviside, HeavisideType);
299 itkSetObjectMacro(DomainMapFilter, DomainMapImageFilterType);
300 itkGetModifiableObjectMacro(DomainMapFilter, DomainMapImageFilterType);
304 bool
306
307protected:
310
312 ~LevelSetContainerBase() override = default;
313
316 void
318
319private:
321 DomainMapImageFilterPointer m_DomainMapFilter{};
323};
324} // namespace itk
325
326#ifndef ITK_MANUAL_INSTANTIATION
327# include "itkLevelSetContainerBase.hxx"
328#endif
329
330#endif // itkLevelSetContainerBase_h
Base class of the Heaviside function.
Templated n-dimensional image class.
Definition: itkImage.h:89
ConstIterator(const LevelSetContainerConstIteratorType &it)
bool operator==(const ConstIterator &it) const
LevelSetContainerConstIteratorType m_Iterator
bool operator==(const Iterator &it) const
Iterator(const LevelSetContainerIteratorType &it)
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator)
bool operator==(const ConstIterator &it) const
LevelSetContainerIteratorType m_Iterator
LevelSetIdentifierType GetIdentifier() const
typename LevelSetType::OutputType OutputType
LevelSetPointer GetLevelSet(const LevelSetIdentifierType &iId) const
Get the level set function given its id.
typename LevelSetType::InputType InputIndexType
typename DomainMapImageFilterType::LevelSetDomain LevelSetDomainType
typename LevelSetType::OutputRealType OutputRealType
void SetContainer(const LevelSetContainerType &iContainer)
typename LevelSetType::HessianType HessianType
typename IdListType::iterator IdListIterator
LevelSetContainerBase()=default
Default Constructor.
typename LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
typename LevelSetType::LevelSetDataType LevelSetDataType
LevelSetIdentifierType Size() const
bool AddLevelSet(const LevelSetIdentifierType &iId, LevelSetType *iLevelSet, const bool iForce=true)
Add one level set function given its id.
bool RemoveLevelSet(const LevelSetIdentifierType &iId)
Remove one level set function given its id.
std::map< LevelSetIdentifierType, LevelSetDomainType > DomainContainerType
typename IdListType::const_iterator IdListConstIterator
std::list< LevelSetIdentifierType > IdListType
typename DomainContainerType::iterator DomainIteratorType
typename LevelSetType::Pointer LevelSetPointer
const LevelSetContainerType & GetContainer() const
std::pair< LevelSetIdentifierType, LevelSetPointer > LevelSetPairType
typename DomainMapImageFilterType::Pointer DomainMapImageFilterPointer
typename LevelSetContainerType::iterator LevelSetContainerIteratorType
typename HeavisideType::ConstPointer HeavisideConstPointer
ConstIterator Begin() const
~LevelSetContainerBase() override=default
Default Destructor.
typename LevelSetType::GradientType GradientType
ConstIterator End() const
Specifies an image region where an unique std::list of level sets Id's are defined.
Light weight base class for most itk classes.
Base class for most ITK classes.
Definition: itkObject.h:62
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....