00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkFiniteDifferenceImageFilter_h_
00018 #define __itkFiniteDifferenceImageFilter_h_
00019
00020 #include "itkImageToImageFilter.h"
00021 #include "itkFiniteDifferenceFunction.h"
00022
00023 namespace itk {
00024
00121 template <class TInputImage, class TOutputImage>
00122 class ITK_EXPORT FiniteDifferenceImageFilter
00123 : public ImageToImageFilter<TInputImage, TOutputImage>
00124 {
00125 public:
00127 typedef FiniteDifferenceImageFilter Self;
00128 typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
00129 typedef SmartPointer<Self> Pointer;
00130 typedef SmartPointer<const Self> ConstPointer;
00131
00133 itkTypeMacro(FiniteDifferenceImageFilter, ImageToImageFilter );
00134
00136 typedef TInputImage InputImageType;
00137 typedef TOutputImage OutputImageType;
00138
00140 itkStaticConstMacro(ImageDimension, unsigned int,
00141 OutputImageType::ImageDimension);
00142
00144 typedef typename TOutputImage::PixelType PixelType;
00145
00149 typedef FiniteDifferenceFunction<TOutputImage> FiniteDifferenceFunctionType;
00150 typedef typename FiniteDifferenceFunctionType::TimeStepType TimeStepType;
00151
00152 typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
00153
00155 itkGetConstMacro(ElapsedIterations, unsigned int);
00156
00160 itkGetConstReferenceObjectMacro(DifferenceFunction,
00161 FiniteDifferenceFunctionType );
00162
00166 itkSetObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType );
00167
00168
00170 itkSetMacro(NumberOfIterations, unsigned int);
00171 itkGetMacro(NumberOfIterations, unsigned int);
00172
00175 itkSetMacro(MaximumRMSError, double);
00176 itkGetMacro(MaximumRMSError, double);
00177
00180 itkSetMacro(RMSChange, double);
00181 itkGetMacro(RMSChange, double);
00182
00184 void SetStateToInitialized()
00185 {
00186 this->SetState(INITIALIZED);
00187 }
00188
00190 void SetStateToUninitialized()
00191 {
00192 this->SetState(UNINITIALIZED);
00193 }
00194
00196 itkSetMacro(State, FilterStateType);
00197 itkGetMacro(State, FilterStateType);
00198
00201 itkSetMacro(ManualReinitialization, bool);
00202 itkGetMacro(ManualReinitialization, bool);
00203 itkBooleanMacro(ManualReinitialization);
00204
00205 protected:
00206 FiniteDifferenceImageFilter()
00207 {
00208 m_ElapsedIterations = 0;
00209 m_DifferenceFunction = 0;
00210 m_NumberOfIterations = NumericTraits<unsigned int>::max();
00211 m_MaximumRMSError = 0.0;
00212 m_RMSChange = 0.0;
00213 m_State = UNINITIALIZED;
00214 m_ManualReinitialization = false;
00215 }
00216 ~FiniteDifferenceImageFilter() {}
00217 void PrintSelf(std::ostream& os, Indent indent) const;
00218
00220 virtual void AllocateUpdateBuffer() = 0;
00221
00225 virtual void ApplyUpdate(TimeStepType dt) = 0;
00226
00232 virtual TimeStepType CalculateChange() = 0;
00233
00237 virtual void CopyInputToOutput() = 0;
00238
00242 virtual void GenerateData();
00243
00255 virtual void GenerateInputRequestedRegion();
00256
00259 virtual bool Halt();
00260
00270 virtual bool ThreadedHalt(void *itkNotUsed(threadInfo)) { return this->Halt(); }
00271
00277 virtual void Initialize() { };
00278
00285 virtual void InitializeIteration()
00286 { m_DifferenceFunction->InitializeIteration(); }
00287
00301 virtual TimeStepType ResolveTimeStep(const TimeStepType* timeStepList,
00302 const bool* valid,int size);
00303
00305 itkSetMacro(ElapsedIterations, unsigned int);
00306
00309 virtual void PostProcessOutput() {}
00310
00312 unsigned int m_NumberOfIterations;
00313
00314 double m_RMSChange;
00315 double m_MaximumRMSError;
00316
00317 private:
00318 FiniteDifferenceImageFilter(const Self&);
00319 void operator=(const Self&);
00320
00323 unsigned int m_ElapsedIterations;
00324
00327 bool m_ManualReinitialization;
00328
00330 typename FiniteDifferenceFunctionType::Pointer m_DifferenceFunction;
00331
00333 FilterStateType m_State;
00334 };
00335
00336 }
00337
00338 #ifndef ITK_MANUAL_INSTANTIATION
00339 #include "itkFiniteDifferenceImageFilter.txx"
00340 #endif
00341
00342 #endif
00343