ITK  6.0.0
Insight Toolkit
itkLevelSetBase.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 itkLevelSetBase_h
20#define itkLevelSetBase_h
21
22#include <utility>
23
24#include "itkIntTypes.h"
25#include "itkCovariantVector.h"
26#include "itkMatrix.h"
27#include "itkNumericTraits.h"
28#include "itkDataObject.h"
29
30namespace itk
31{
42template <typename TInput, unsigned int VDimension, typename TOutput, typename TDomain>
43class ITK_TEMPLATE_EXPORT LevelSetBase : public DataObject
44{
45public:
46 ITK_DISALLOW_COPY_AND_MOVE(LevelSetBase);
47
52
54 itkOverrideGetNameOfClassMacro(LevelSetBase);
55
56 static constexpr unsigned int Dimension = VDimension;
57
58 using InputType = TInput;
59 using OutputType = TOutput;
60 using DomainType = TDomain;
64
67
69 virtual OutputType
70 Evaluate(const InputType & iP) const = 0;
71
73 virtual GradientType
74 EvaluateGradient(const InputType & iP) const = 0;
75
77 virtual HessianType
78 EvaluateHessian(const InputType & iP) const = 0;
79
80 virtual OutputRealType
81 EvaluateLaplacian(const InputType & iP) const = 0;
82 virtual OutputRealType
84 virtual OutputRealType
85 EvaluateMeanCurvature(const InputType & iP) const = 0;
86
95 template <typename T>
96 class ITK_TEMPLATE_EXPORT DataType
97 {
98 public:
99 DataType() = delete;
100
101 DataType(std::string iName)
102 : m_Name(std::move(iName))
103 , m_Computed(false)
104 {}
105 DataType(const DataType & iData)
106 : m_Name(iData.m_Name)
107 , m_Value(iData.m_Value)
108 , m_Computed(iData.m_Computed)
109 {}
110
111 ~DataType() = default;
112
113 std::string m_Name;
116
117 void
118 operator=(const DataType & iData)
119 {
120 this->m_Name = iData.m_Name;
121 this->m_Value = iData.m_Value;
122 this->m_Computed = iData.m_Computed;
123 }
124 };
125
131 {
133 : Value("Value")
134 , Gradient("Gradient")
135 , Hessian("Hessian")
136 , Laplacian("Laplacian")
137 , GradientNorm("GradientNorm")
138 , MeanCurvature("MeanCurvature")
139 , ForwardGradient("ForwardGradient")
140 , BackwardGradient("BackwardGradient")
141 {
142 Value.m_Value = OutputType{};
143 Gradient.m_Value.Fill(OutputRealType{});
144 Hessian.m_Value.Fill(OutputRealType{});
145 Laplacian.m_Value = OutputRealType{};
146 GradientNorm.m_Value = OutputRealType{};
147 MeanCurvature.m_Value = OutputRealType{};
148 ForwardGradient.m_Value.Fill(OutputRealType{});
149 BackwardGradient.m_Value.Fill(OutputRealType{});
150 }
154 : Value(iData.Value)
155 , Gradient(iData.Gradient)
156 , Hessian(iData.Hessian)
157 , Laplacian(iData.Laplacian)
158 , GradientNorm(iData.GradientNorm)
159 , MeanCurvature(iData.MeanCurvature)
160 , ForwardGradient(iData.ForwardGradient)
161 , BackwardGradient(iData.BackwardGradient)
162 {}
163
164 ~LevelSetDataType() = default;
165
166 void
168 {
169 Value = iData.Value;
170 Gradient = iData.Gradient;
171 Hessian = iData.Hessian;
172 Laplacian = iData.Laplacian;
173 GradientNorm = iData.GradientNorm;
174 MeanCurvature = iData.MeanCurvature;
175 ForwardGradient = iData.ForwardGradient;
176 BackwardGradient = iData.BackwardGradient;
177 }
178
188 };
189
190 virtual void
191 Evaluate(const InputType & iP, LevelSetDataType & ioData) const = 0;
192 virtual void
193 EvaluateGradient(const InputType & iP, LevelSetDataType & ioData) const = 0;
194 virtual void
195 EvaluateHessian(const InputType & iP, LevelSetDataType & ioData) const = 0;
196 virtual void
197 EvaluateLaplacian(const InputType & iP, LevelSetDataType & ioData) const = 0;
198 virtual void
200 virtual void
202 virtual void
203 EvaluateForwardGradient(const InputType & iP, LevelSetDataType & ioData) const = 0;
204 virtual void
205 EvaluateBackwardGradient(const InputType & iP, LevelSetDataType & ioData) const = 0;
206
208 virtual bool
209 IsInside(const InputType & iP) const;
210
213 itkGetConstMacro(MaximumNumberOfRegions, RegionType);
214
216 void
217 Initialize() override;
218
220 void
222
223 void
225
226 void
227 CopyInformation(const DataObject * data) override;
228
229 void
230 Graft(const DataObject * data) override;
231
232 bool
234
235 bool
237
242 void
243 SetRequestedRegion(const DataObject * data) override;
244
246 virtual void
248
249 itkGetConstMacro(RequestedRegion, RegionType);
250
252 virtual void
254
255 itkGetConstMacro(BufferedRegion, RegionType);
256
257protected:
259 ~LevelSetBase() override = default;
260
261 // If the RegionType is ITK_UNSTRUCTURED_REGION, then the following
262 // variables represent the maximum number of region that the data
263 // object can be broken into, which region out of how many is
264 // currently in the buffered region, and the number of regions and
265 // the specific region requested for the update. Data objects that
266 // do not support any division of the data can simply leave the
267 // MaximumNumberOfRegions as 1. The RequestedNumberOfRegions and
268 // RequestedRegion are used to define the currently requested
269 // region. The LargestPossibleRegion is always requested region = 0
270 // and number of regions = 1;
271 RegionType m_MaximumNumberOfRegions{ 0 };
272 RegionType m_NumberOfRegions{ 0 };
273 RegionType m_RequestedNumberOfRegions{ 0 };
274 RegionType m_BufferedRegion{ 0 };
275 RegionType m_RequestedRegion{ 0 };
276};
277} // namespace itk
278
279#ifndef ITK_MANUAL_INSTANTIATION
280# include "itkLevelSetBase.hxx"
281#endif
282
283#endif // itkLevelSetBase_h
A templated class holding a n-Dimensional covariant vector.
Base class for all data objects in ITK.
Internal class used for one computed characteristic.
DataType(const DataType &iData)
DataType(std::string iName)
void operator=(const DataType &iData)
Abstract base class for the representation of a level-set function.
void UpdateOutputInformation() override
typename NumericTraits< OutputType >::RealType OutputRealType
void Initialize() override
virtual void EvaluateGradientNorm(const InputType &iP, LevelSetDataType &ioData) const
~LevelSetBase() override=default
virtual void SetRequestedRegion(const RegionType &region)
virtual HessianType EvaluateHessian(const InputType &iP) const =0
virtual void EvaluateMeanCurvature(const InputType &iP, LevelSetDataType &ioData) const
void Graft(const DataObject *data) override
virtual void SetBufferedRegion(const RegionType &region)
void SetRequestedRegion(const DataObject *data) override
virtual OutputRealType EvaluateLaplacian(const InputType &iP) const =0
virtual OutputRealType EvaluateGradientNorm(const InputType &iP) const
virtual void EvaluateGradient(const InputType &iP, LevelSetDataType &ioData) const =0
IdentifierType RegionType
void SetRequestedRegionToLargestPossibleRegion() override
virtual void EvaluateForwardGradient(const InputType &iP, LevelSetDataType &ioData) const =0
virtual void EvaluateLaplacian(const InputType &iP, LevelSetDataType &ioData) const =0
virtual void EvaluateHessian(const InputType &iP, LevelSetDataType &ioData) const =0
virtual OutputType Evaluate(const InputType &iP) const =0
void CopyInformation(const DataObject *data) override
virtual void EvaluateBackwardGradient(const InputType &iP, LevelSetDataType &ioData) const =0
virtual GradientType EvaluateGradient(const InputType &iP) const =0
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
virtual OutputRealType EvaluateMeanCurvature(const InputType &iP) const =0
bool VerifyRequestedRegion() override
virtual bool IsInside(const InputType &iP) const
virtual void Evaluate(const InputType &iP, LevelSetDataType &ioData) const =0
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:53
Base class for most ITK classes.
Definition: itkObject.h:62
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
STL namespace.
Convenient data structure to cache computed characteristics.
DataType< OutputRealType > Laplacian
LevelSetDataType(const LevelSetDataType &iData)
void operator=(const LevelSetDataType &iData)
DataType< OutputRealType > GradientNorm
DataType< OutputRealType > MeanCurvature
DataType< GradientType > ForwardGradient
DataType< GradientType > BackwardGradient
DataType< GradientType > Gradient