00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkFiniteDifferenceFunction_h_
00018 #define __itkFiniteDifferenceFunction_h_
00019
00020 #include "itkLightObject.h"
00021 #include "itkConstNeighborhoodIterator.h"
00022 #include "itkZeroFluxNeumannBoundaryCondition.h"
00023 #include "itkVector.h"
00024 #include "itkFixedArray.h"
00025
00026 namespace itk {
00027
00064 template<class TImageType>
00065 class ITK_EXPORT FiniteDifferenceFunction : public LightObject
00066 {
00067 public:
00068
00070 typedef FiniteDifferenceFunction Self;
00071 typedef LightObject Superclass;
00072
00073 typedef SmartPointer<Self> Pointer;
00074 typedef SmartPointer<const Self> ConstPointer;
00075
00077 itkTypeMacro( FiniteDifferenceFunction, LightObject );
00078
00080 typedef TImageType ImageType;
00081 typedef typename ImageType::PixelType PixelType;
00082 typedef double PixelRealType;
00083
00085 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
00086
00088 typedef double TimeStepType;
00089
00092 typedef ZeroFluxNeumannBoundaryCondition<ImageType>
00093 DefaultBoundaryConditionType;
00094
00096 typedef typename ConstNeighborhoodIterator<TImageType>::RadiusType RadiusType;
00097
00100 typedef ConstNeighborhoodIterator<TImageType, DefaultBoundaryConditionType> NeighborhoodType;
00101
00104 typedef Vector<float,itkGetStaticConstMacro(ImageDimension)> FloatOffsetType;
00105
00115 virtual void InitializeIteration() {};
00116
00130 #if !defined(CABLE_CONFIGURATION)
00131 virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood,
00132 void *globalData,
00133 const FloatOffsetType &offset = FloatOffsetType(0.0)) = 0;
00134 #endif
00135
00138 void SetRadius(const RadiusType &r)
00139 { m_Radius = r; }
00140
00143 const RadiusType &GetRadius() const
00144 { return m_Radius; }
00145
00149 void SetScaleCoefficients (PixelRealType vals[ImageDimension])
00150 {
00151 for (unsigned int i = 0; i < ImageDimension; i++)
00152 {
00153 m_ScaleCoefficients[i] = vals[i];
00154 }
00155 }
00157
00164 virtual TimeStepType ComputeGlobalTimeStep(void *GlobalData) const =0;
00165
00173 virtual void *GetGlobalDataPointer() const =0;
00174
00180 virtual void ReleaseGlobalDataPointer(void *GlobalData) const =0;
00181
00182 protected:
00183 FiniteDifferenceFunction()
00184 {
00185
00186 m_Radius.Fill( 0 );
00187 for (unsigned int i = 0; i < ImageDimension; i++)
00188 {
00189 m_ScaleCoefficients[i] = 1.0;
00190 }
00191 }
00192 ~FiniteDifferenceFunction() {}
00193 void PrintSelf(std::ostream& os, Indent indent) const;
00194
00195 RadiusType m_Radius;
00196 PixelRealType m_ScaleCoefficients[ImageDimension];
00197
00198 private:
00199 FiniteDifferenceFunction(const Self&);
00200 void operator=(const Self&);
00201 };
00202
00203 }
00204
00205
00206 #define ITK_TEMPLATE_FiniteDifferenceFunction(_, EXPORT, x, y) namespace itk { \
00207 _(1(class EXPORT FiniteDifferenceFunction< ITK_TEMPLATE_1 x >)) \
00208 namespace Templates { typedef FiniteDifferenceFunction< ITK_TEMPLATE_1 x > FiniteDifferenceFunction##y; } \
00209 }
00210
00211 #if ITK_TEMPLATE_EXPLICIT
00212 # include "Templates/itkFiniteDifferenceFunction+-.h"
00213 #endif
00214
00215 #if ITK_TEMPLATE_TXX
00216 # include "itkFiniteDifferenceFunction.txx"
00217 #endif
00218
00219 #endif
00220