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 
30 namespace itk
31 {
42 template <typename TInput, unsigned int VDimension, typename TOutput, typename TDomain>
43 class ITK_TEMPLATE_EXPORT LevelSetBase : public DataObject
44 {
45 public:
46  ITK_DISALLOW_COPY_AND_MOVE(LevelSetBase);
47 
48  using Self = LevelSetBase;
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
83  EvaluateGradientNorm(const InputType & iP) const;
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
199  EvaluateGradientNorm(const InputType & iP, LevelSetDataType & ioData) const;
200  virtual void
201  EvaluateMeanCurvature(const InputType & iP, LevelSetDataType & ioData) const;
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
221  UpdateOutputInformation() override;
222 
223  void
224  SetRequestedRegionToLargestPossibleRegion() override;
225 
226  void
227  CopyInformation(const DataObject * data) override;
228 
229  void
230  Graft(const DataObject * data) override;
231 
232  bool
233  RequestedRegionIsOutsideOfTheBufferedRegion() override;
234 
235  bool
236  VerifyRequestedRegion() override;
237 
242  void
243  SetRequestedRegion(const DataObject * data) override;
244 
246  virtual void
247  SetRequestedRegion(const RegionType & region);
248 
249  itkGetConstMacro(RequestedRegion, RegionType);
250 
252  virtual void
253  SetBufferedRegion(const RegionType & region);
254 
255  itkGetConstMacro(BufferedRegion, RegionType);
256 
257 protected:
258  LevelSetBase();
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
itk::LevelSetBase::DataType::m_Computed
bool m_Computed
Definition: itkLevelSetBase.h:115
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:68
itk::LevelSetBase::InputType
TInput InputType
Definition: itkLevelSetBase.h:58
itkCovariantVector.h
itk::LevelSetBase< Index< VDimension >, VDimension, int8_t, ImageBase< VDimension > >::OutputRealType
typename NumericTraits< OutputType >::RealType OutputRealType
Definition: itkLevelSetBase.h:61
itk::LevelSetBase::DataType
Internal class used for one computed characteristic.
Definition: itkLevelSetBase.h:96
itkMatrix.h
itk::LevelSetBase::LevelSetDataType::Gradient
DataType< GradientType > Gradient
Definition: itkLevelSetBase.h:181
itk::ImageBase
Base class for templated image classes.
Definition: itkImageBase.h:114
itk::LevelSetBase
Abstract base class for the representation of a level-set function.
Definition: itkLevelSetBase.h:43
itk::LevelSetBase::DataType::DataType
DataType(std::string iName)
Definition: itkLevelSetBase.h:101
itk::LevelSetBase::LevelSetDataType::GradientNorm
DataType< OutputRealType > GradientNorm
Definition: itkLevelSetBase.h:184
itk::LevelSetBase::LevelSetDataType::LevelSetDataType
LevelSetDataType()
Definition: itkLevelSetBase.h:132
itk::LevelSetBase::LevelSetDataType::ForwardGradient
DataType< GradientType > ForwardGradient
Definition: itkLevelSetBase.h:186
itk::LevelSetBase::DataType::m_Value
T m_Value
Definition: itkLevelSetBase.h:114
itk::SmartPointer< Self >
itk::LevelSetBase::LevelSetDataType::Hessian
DataType< HessianType > Hessian
Definition: itkLevelSetBase.h:182
itkDataObject.h
itk::LevelSetBase::DataType::DataType
DataType(const DataType &iData)
Definition: itkLevelSetBase.h:105
itk::LevelSetBase::LevelSetDataType::BackwardGradient
DataType< GradientType > BackwardGradient
Definition: itkLevelSetBase.h:187
itk::LevelSetBase< Index< VDimension >, VDimension, int8_t, ImageBase< VDimension > >::RegionType
IdentifierType RegionType
Definition: itkLevelSetBase.h:66
itk::DataObject
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42
itkIntTypes.h
itk::Matrix
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:52
itk::LevelSetBase::LevelSetDataType::Value
DataType< OutputType > Value
Definition: itkLevelSetBase.h:180
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::LevelSetBase::DataType::operator=
void operator=(const DataType &iData)
Definition: itkLevelSetBase.h:118
itk::LevelSetBase::LevelSetDataType::operator=
void operator=(const LevelSetDataType &iData)
Definition: itkLevelSetBase.h:167
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itkNumericTraits.h
itk::LevelSetBase::LevelSetDataType::MeanCurvature
DataType< OutputRealType > MeanCurvature
Definition: itkLevelSetBase.h:185
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:86
itk::LevelSetBase< Index< VDimension >, VDimension, int8_t, ImageBase< VDimension > >::OutputType
int8_t OutputType
Definition: itkLevelSetBase.h:59
itk::LevelSetBase::LevelSetDataType::LevelSetDataType
LevelSetDataType(const LevelSetDataType &iData)
Definition: itkLevelSetBase.h:153
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
itk::LevelSetBase::DataType::m_Name
std::string m_Name
Definition: itkLevelSetBase.h:113
itk::LevelSetBase::LevelSetDataType::Laplacian
DataType< OutputRealType > Laplacian
Definition: itkLevelSetBase.h:183
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itk::LevelSetBase::LevelSetDataType
Convenient data structure to cache computed characteristics.
Definition: itkLevelSetBase.h:130