ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkLevelSetBase.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 itkLevelSetBase_h
20 #define itkLevelSetBase_h
21 
22 #include "itkIntTypes.h"
23 #include "itkCovariantVector.h"
24 #include "itkMatrix.h"
25 #include "itkNumericTraits.h"
26 #include "itkDataObject.h"
27 
28 namespace itk
29 {
40 template< typename TInput, unsigned int VDimension, typename TOutput, typename TDomain >
41 class LevelSetBase : public DataObject
42 {
43 public:
44  typedef LevelSetBase Self;
48 
50  itkTypeMacro ( LevelSetBase, DataObject );
51 
52  itkStaticConstMacro ( Dimension, unsigned int, VDimension );
53 
54  typedef TInput InputType;
55  typedef TOutput OutputType;
56  typedef TDomain DomainType;
60 
63 
65  virtual OutputType Evaluate( const InputType& iP ) const = 0;
66 
68  virtual GradientType EvaluateGradient( const InputType& iP ) const = 0;
69 
71  virtual HessianType EvaluateHessian( const InputType& iP ) const = 0;
72 
73  virtual OutputRealType EvaluateLaplacian( const InputType& iP ) const = 0;
74  virtual OutputRealType EvaluateGradientNorm( const InputType& iP ) const;
75  virtual OutputRealType EvaluateMeanCurvature( const InputType& iP ) const = 0;
76 
84  template< typename T >
85  class DataType
86  {
87  public:
88  DataType( const std::string& iName ) :
89  m_Name( iName ), m_Computed( false )
90  {}
91  DataType( const DataType& iData ) : m_Name( iData.m_Name ),
92  m_Value( iData.m_Value ), m_Computed( iData.m_Computed )
93  {}
94 
95  ~DataType() {}
96 
97  std::string m_Name;
99  bool m_Computed;
100 
101  void operator =( const DataType& iData )
102  {
103  this->m_Name = iData.m_Name;
104  this->m_Value = iData.m_Value;
105  this->m_Computed = iData.m_Computed;
106  }
107 
108  private:
109  DataType();
110  };
111 
117  {
118  LevelSetDataType() : Value( "Value" ), Gradient( "Gradient" ),
119  Hessian( "Hessian" ), Laplacian( "Laplacian" ),
120  GradientNorm( "GradientNorm" ), MeanCurvature( "MeanCurvature" ),
121  ForwardGradient( "ForwardGradient" ), BackwardGradient( "BackwardGradient" )
122  {
131  }
133 
134  LevelSetDataType( const LevelSetDataType& iData ) : Value( iData.Value ),
135  Gradient( iData.Gradient ), Hessian( iData.Hessian ),
136  Laplacian( iData.Laplacian ), GradientNorm( iData.GradientNorm ),
139 
141 
142  void operator = ( const LevelSetDataType& iData )
143  {
144  Value = iData.Value;
145  Gradient = iData.Gradient;
146  Hessian = iData.Hessian;
147  Laplacian = iData.Laplacian;
148  GradientNorm = iData.GradientNorm;
152  }
153 
163  };
164 
165  virtual void Evaluate( const InputType& iP, LevelSetDataType& ioData ) const = 0;
166  virtual void EvaluateGradient( const InputType& iP, LevelSetDataType& ioData ) const = 0;
167  virtual void EvaluateHessian( const InputType& iP, LevelSetDataType& ioData ) const = 0;
168  virtual void EvaluateLaplacian( const InputType& iP, LevelSetDataType& ioData ) const = 0;
169  virtual void EvaluateGradientNorm( const InputType& iP, LevelSetDataType& ioData ) const;
170  virtual void EvaluateMeanCurvature( const InputType& iP, LevelSetDataType& ioData ) const;
171  virtual void EvaluateForwardGradient( const InputType& iP, LevelSetDataType& ioData ) const = 0;
172  virtual void EvaluateBackwardGradient( const InputType& iP, LevelSetDataType& ioData ) const = 0;
173 
175  virtual bool IsInside( const InputType& iP ) const;
176 
179  itkGetConstMacro(MaximumNumberOfRegions, RegionType);
180 
182  virtual void Initialize() ITK_OVERRIDE;
183 
185  virtual void UpdateOutputInformation() ITK_OVERRIDE;
186 
187  virtual void SetRequestedRegionToLargestPossibleRegion() ITK_OVERRIDE;
188 
189  virtual void CopyInformation(const DataObject *data) ITK_OVERRIDE;
190 
191  virtual void Graft(const DataObject *data) ITK_OVERRIDE;
192 
193  virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() ITK_OVERRIDE;
194 
195  virtual bool VerifyRequestedRegion() ITK_OVERRIDE;
196 
201  virtual void SetRequestedRegion( const DataObject *data) ITK_OVERRIDE;
202 
204  virtual void SetRequestedRegion(const RegionType & region);
205 
206  itkGetConstMacro(RequestedRegion, RegionType);
207 
209  virtual void SetBufferedRegion(const RegionType & region);
210 
211  itkGetConstMacro(BufferedRegion, RegionType);
212 
213 protected:
214  LevelSetBase();
215  virtual ~LevelSetBase() {}
216 
217  // If the RegionType is ITK_UNSTRUCTURED_REGION, then the following
218  // variables represent the maximum number of region that the data
219  // object can be broken into, which region out of how many is
220  // currently in the buffered region, and the number of regions and
221  // the specific region requested for the update. Data objects that
222  // do not support any division of the data can simply leave the
223  // MaximumNumberOfRegions as 1. The RequestedNumberOfRegions and
224  // RequestedRegion are used to define the currently requested
225  // region. The LargestPossibleRegion is always requested region = 0
226  // and number of regions = 1;
232 
233 private:
234  LevelSetBase( const Self& ); // purposely left unimplemented
235  void operator = ( const Self& ); // purposely left unimplemented
236 
237 };
238 }
239 
240 #ifndef ITK_MANUAL_INSTANTIATION
241 #include "itkLevelSetBase.hxx"
242 #endif
243 
244 #endif // itkLevelSetBase_h
IdentifierType RegionType
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:46
SmartPointer< const Self > ConstPointer
virtual void Initialize() override
virtual void SetRequestedRegionToLargestPossibleRegion() override
DataType< OutputRealType > Laplacian
RegionType m_NumberOfRegions
Abstract base class for the representation of a level-set function.
virtual void EvaluateBackwardGradient(const InputType &iP, LevelSetDataType &ioData) const =0
DataObject Superclass
virtual bool VerifyRequestedRegion() override
virtual OutputType Evaluate(const InputType &iP) const =0
CovariantVector< OutputRealType, VDimension > GradientType
DataType< OutputRealType > GradientNorm
virtual void EvaluateForwardGradient(const InputType &iP, LevelSetDataType &ioData) const =0
void operator=(const LevelSetDataType &iData)
static const unsigned int Dimension
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override
virtual void SetBufferedRegion(const RegionType &region)
SmartPointer< Self > Pointer
DataType< OutputRealType > MeanCurvature
virtual HessianType EvaluateHessian(const InputType &iP) const =0
DataType< GradientType > Gradient
SizeValueType IdentifierType
Definition: itkIntTypes.h:147
RegionType m_RequestedNumberOfRegions
virtual void CopyInformation(const DataObject *data) override
RegionType m_MaximumNumberOfRegions
NumericTraits< OutputType >::RealType OutputRealType
Convenient data structure to cache computed characteristics.
virtual void UpdateOutputInformation() override
virtual OutputRealType EvaluateGradientNorm(const InputType &iP) const
LevelSetDataType(const LevelSetDataType &iData)
void operator=(const DataType &iData)
DataType(const std::string &iName)
DataType(const DataType &iData)
virtual void Graft(const DataObject *data) override
virtual GradientType EvaluateGradient(const InputType &iP) const =0
virtual bool IsInside(const InputType &iP) const
virtual OutputRealType EvaluateLaplacian(const InputType &iP) const =0
Matrix< OutputRealType, VDimension, VDimension > HessianType
virtual OutputRealType EvaluateMeanCurvature(const InputType &iP) const =0
DataType< GradientType > ForwardGradient
virtual void SetRequestedRegion(const DataObject *data) override
Define additional traits for native types such as int or float.
void operator=(const Self &)
Internal class used for one computed characteritic.
A templated class holding a n-Dimensional covariant vector.
RegionType m_RequestedRegion
RegionType m_BufferedRegion
DataType< GradientType > BackwardGradient
Base class for all data objects in ITK.
LevelSetBase Self