00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkFiniteDifferenceFunction.h,v $ 00005 Language: C++ 00006 Date: $Date: 2004/02/28 00:06:50 $ 00007 Version: $Revision: 1.15 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 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: 00069 typedef FiniteDifferenceFunction Self; 00070 typedef LightObject Superclass; 00071 00072 typedef SmartPointer<Self> Pointer; 00073 typedef SmartPointer<const Self> ConstPointer; 00074 00076 itkTypeMacro( FiniteDifferenceFunction, LightObject ); 00077 00079 typedef TImageType ImageType; 00080 typedef typename ImageType::PixelType PixelType; 00081 typedef double PixelRealType; 00082 00084 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension); 00085 00087 typedef double TimeStepType; 00088 00091 typedef ZeroFluxNeumannBoundaryCondition<ImageType> 00092 DefaultBoundaryConditionType; 00093 00095 typedef typename ConstNeighborhoodIterator<TImageType>::RadiusType RadiusType; 00096 00099 typedef ConstNeighborhoodIterator<TImageType, DefaultBoundaryConditionType> NeighborhoodType; 00100 00103 typedef Vector<float,itkGetStaticConstMacro(ImageDimension)> FloatOffsetType; 00104 00114 virtual void InitializeIteration() {}; 00115 00129 virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood, 00130 void *globalData, 00131 const FloatOffsetType &offset = FloatOffsetType(0.0)) = 0; 00132 00133 00136 void SetRadius(const RadiusType &r) 00137 { m_Radius = r; } 00138 00141 const RadiusType &GetRadius() const 00142 { return m_Radius; } 00143 00147 void SetScaleCoefficients (PixelRealType vals[ImageDimension]) 00148 { 00149 for (unsigned int i = 0; i < ImageDimension; i++) 00150 { 00151 m_ScaleCoefficients[i] = vals[i]; 00152 } 00153 } 00154 00161 virtual TimeStepType ComputeGlobalTimeStep(void *GlobalData) const =0; 00162 00170 virtual void *GetGlobalDataPointer() const =0; 00171 00177 virtual void ReleaseGlobalDataPointer(void *GlobalData) const =0; 00178 00179 protected: 00180 FiniteDifferenceFunction() 00181 { 00182 // initialize variables 00183 m_Radius.Fill( 0 ); 00184 for (unsigned int i = 0; i < ImageDimension; i++) 00185 { 00186 m_ScaleCoefficients[i] = 1.0; 00187 } 00188 } 00189 ~FiniteDifferenceFunction() {} 00190 void PrintSelf(std::ostream& os, Indent indent) const; 00191 00192 RadiusType m_Radius; 00193 PixelRealType m_ScaleCoefficients[ImageDimension]; 00194 00195 private: 00196 FiniteDifferenceFunction(const Self&); //purposely not implemented 00197 void operator=(const Self&); //purposely not implemented 00198 }; 00199 00200 } // end namespace itk 00201 00202 #ifndef ITK_MANUAL_INSTANTIATION 00203 #include "itkFiniteDifferenceFunction.txx" 00204 #endif 00205 00206 #endif