ITK  4.4.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< class TInput, unsigned int VDimension, typename TOutput, class 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;
59 
60  typedef TDomain DomainType;
61 
64 
66  virtual OutputType Evaluate( const InputType& iP ) const = 0;
67 
69  virtual GradientType EvaluateGradient( const InputType& iP ) const = 0;
70 
72  virtual HessianType EvaluateHessian( const InputType& iP ) const = 0;
73 
74  virtual OutputRealType EvaluateLaplacian( const InputType& iP ) const = 0;
75  virtual OutputRealType EvaluateGradientNorm( const InputType& iP ) const;
76  virtual OutputRealType EvaluateMeanCurvature( const InputType& iP ) const = 0;
77 
85  template< class T >
86  class DataType
87  {
88  public:
89  DataType( const std::string& iName ) :
90  m_Name( iName ), m_Computed( false )
91  {}
92  DataType( const DataType& iData ) : m_Name( iData.m_Name ),
93  m_Value( iData.m_Value ), m_Computed( iData.m_Computed )
94  {}
95 
96  ~DataType() {}
97 
98  std::string m_Name;
101 
102  void operator =( const DataType& iData )
103  {
104  this->m_Name = iData.m_Name;
105  this->m_Value = iData.m_Value;
106  this->m_Computed = iData.m_Computed;
107  }
108 
109  private:
110  DataType();
111  };
112 
118  {
119  LevelSetDataType() : Value( "Value" ), Gradient( "Gradient" ),
120  Hessian( "Hessian" ), Laplacian( "Laplacian" ),
121  GradientNorm( "GradientNorm" ), MeanCurvature( "MeanCurvature" ),
122  ForwardGradient( "ForwardGradient" ), BackwardGradient( "BackwardGradient" )
123  {
132  }
134 
135  LevelSetDataType( const LevelSetDataType& iData ) : Value( iData.Value ),
136  Gradient( iData.Gradient ), Hessian( iData.Hessian ),
137  Laplacian( iData.Laplacian ), GradientNorm( iData.GradientNorm ),
140 
142 
143  void operator = ( const LevelSetDataType& iData )
144  {
145  Value = iData.Value;
146  Gradient = iData.Gradient;
147  Hessian = iData.Hessian;
148  Laplacian = iData.Laplacian;
149  GradientNorm = iData.GradientNorm;
153  }
154 
164  };
165 
166  virtual void Evaluate( const InputType& iP, LevelSetDataType& ioData ) const = 0;
167  virtual void EvaluateGradient( const InputType& iP, LevelSetDataType& ioData ) const = 0;
168  virtual void EvaluateHessian( const InputType& iP, LevelSetDataType& ioData ) const = 0;
169  virtual void EvaluateLaplacian( const InputType& iP, LevelSetDataType& ioData ) const = 0;
170  virtual void EvaluateGradientNorm( const InputType& iP, LevelSetDataType& ioData ) const;
171  virtual void EvaluateMeanCurvature( const InputType& iP, LevelSetDataType& ioData ) const;
172  virtual void EvaluateForwardGradient( const InputType& iP, LevelSetDataType& ioData ) const = 0;
173  virtual void EvaluateBackwardGradient( const InputType& iP, LevelSetDataType& ioData ) const = 0;
174 
176  virtual bool IsInside( const InputType& iP ) const;
177 
180  itkGetConstMacro(MaximumNumberOfRegions, RegionType);
181 
183  virtual void Initialize();
184 
186  virtual void UpdateOutputInformation();
187 
189 
190  virtual void CopyInformation(const DataObject *data);
191 
192  virtual void Graft(const DataObject *data);
193 
195 
196  virtual bool VerifyRequestedRegion();
197 
202  virtual void SetRequestedRegion( const DataObject *data);
203 
205  virtual void SetRequestedRegion(const RegionType & region);
206 
207  itkGetConstMacro(RequestedRegion, RegionType);
208 
210  virtual void SetBufferedRegion(const RegionType & region);
211 
212  itkGetConstMacro(BufferedRegion, RegionType);
213 
214 protected:
215  LevelSetBase();
216  virtual ~LevelSetBase() {}
217 
218  // If the RegionType is ITK_UNSTRUCTURED_REGION, then the following
219  // variables represent the maximum number of region that the data
220  // object can be broken into, which region out of how many is
221  // currently in the buffered region, and the number of regions and
222  // the specific region requested for the update. Data objects that
223  // do not support any division of the data can simply leave the
224  // MaximumNumberOfRegions as 1. The RequestedNumberOfRegions and
225  // RequestedRegion are used to define the currently requested
226  // region. The LargestPossibleRegion is always requested region = 0
227  // and number of regions = 1;
233 
234 private:
235  LevelSetBase( const Self& ); // purposely left unimplemented
236  void operator = ( const Self& ); // purposely left unimplemented
237 
238 };
239 }
240 
241 #ifndef ITK_MANUAL_INSTANTIATION
242 #include "itkLevelSetBase.hxx"
243 #endif
244 
245 #endif // __itkLevelSetBase_h
246