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 "itkInPlaceImageFilter.h"
00021 #include "itkFiniteDifferenceFunction.h"
00022
00023 namespace itk {
00024
00121 template <class TInputImage, class TOutputImage>
00122 class ITK_EXPORT FiniteDifferenceImageFilter
00123 : public InPlaceImageFilter<TInputImage, TOutputImage>
00124 {
00125 public:
00126
00128 typedef FiniteDifferenceImageFilter Self;
00129 typedef InPlaceImageFilter<TInputImage, TOutputImage> Superclass;
00130 typedef SmartPointer<Self> Pointer;
00131 typedef SmartPointer<const Self> ConstPointer;
00132
00134 itkTypeMacro(FiniteDifferenceImageFilter, InPlaceImageFilter );
00135
00137 typedef TInputImage InputImageType;
00138 typedef TOutputImage OutputImageType;
00139
00141 itkStaticConstMacro(ImageDimension, unsigned int,
00142 OutputImageType::ImageDimension);
00143
00145 typedef typename TOutputImage::PixelType PixelType;
00146
00150 typedef FiniteDifferenceFunction<TOutputImage> FiniteDifferenceFunctionType;
00151 typedef typename FiniteDifferenceFunctionType::TimeStepType TimeStepType;
00152
00153 typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
00154
00156 itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
00157
00161 itkGetConstReferenceObjectMacro(DifferenceFunction,
00162 FiniteDifferenceFunctionType );
00163
00167 itkSetObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType );
00168
00169
00171 itkSetMacro(NumberOfIterations, unsigned int);
00172 itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
00174
00177 itkSetMacro(UseImageSpacing,bool);
00178 itkBooleanMacro(UseImageSpacing);
00179 itkGetConstReferenceMacro(UseImageSpacing, bool);
00181
00184 itkSetMacro(MaximumRMSError, double);
00185 itkGetConstReferenceMacro(MaximumRMSError, double);
00187
00190 itkSetMacro(RMSChange, double);
00191 itkGetConstReferenceMacro(RMSChange, double);
00193
00195 void SetStateToInitialized()
00196 {
00197 this->SetState(INITIALIZED);
00198 }
00199
00201 void SetStateToUninitialized()
00202 {
00203 this->SetState(UNINITIALIZED);
00204 }
00205
00207 itkSetMacro(State, FilterStateType);
00208 itkGetConstReferenceMacro(State, FilterStateType);
00210
00213 itkSetMacro(ManualReinitialization, bool);
00214 itkGetConstReferenceMacro(ManualReinitialization, bool);
00215 itkBooleanMacro(ManualReinitialization);
00217
00218 protected:
00219 FiniteDifferenceImageFilter()
00220 {
00221 m_UseImageSpacing = false;
00222 m_ElapsedIterations = 0;
00223 m_DifferenceFunction = 0;
00224 m_NumberOfIterations = NumericTraits<unsigned int>::max();
00225 m_MaximumRMSError = 0.0;
00226 m_RMSChange = 0.0;
00227 m_State = UNINITIALIZED;
00228 m_ManualReinitialization = false;
00229 this->InPlaceOff();
00230 }
00231 ~FiniteDifferenceImageFilter() {}
00232 void PrintSelf(std::ostream& os, Indent indent) const;
00233
00235 virtual void AllocateUpdateBuffer() = 0;
00236
00240 virtual void ApplyUpdate(TimeStepType dt) = 0;
00241
00247 virtual TimeStepType CalculateChange() = 0;
00248
00252 virtual void CopyInputToOutput() = 0;
00253
00257 virtual void GenerateData();
00258
00270 virtual void GenerateInputRequestedRegion();
00271
00274 virtual bool Halt();
00275
00285 virtual bool ThreadedHalt(void *itkNotUsed(threadInfo)) { return this->Halt(); }
00286
00292 virtual void Initialize() { };
00293
00300 virtual void InitializeIteration()
00301 { m_DifferenceFunction->InitializeIteration(); }
00302
00316 virtual TimeStepType ResolveTimeStep(const TimeStepType* timeStepList,
00317 const bool* valid,int size);
00318
00320 itkSetMacro(ElapsedIterations, unsigned int);
00321
00324 virtual void PostProcessOutput() {}
00325
00327 unsigned int m_NumberOfIterations;
00328
00329 double m_RMSChange;
00330 double m_MaximumRMSError;
00331
00332 private:
00333 FiniteDifferenceImageFilter(const Self&);
00334 void operator=(const Self&);
00335
00338 unsigned int m_ElapsedIterations;
00339
00342 bool m_UseImageSpacing;
00343
00346 bool m_ManualReinitialization;
00347
00349 typename FiniteDifferenceFunctionType::Pointer m_DifferenceFunction;
00350
00352 FilterStateType m_State;
00353 };
00354
00355 }
00356
00357
00358 #define ITK_TEMPLATE_FiniteDifferenceImageFilter(_, EXPORT, x, y) namespace itk { \
00359 _(2(class EXPORT FiniteDifferenceImageFilter< ITK_TEMPLATE_2 x >)) \
00360 namespace Templates { typedef FiniteDifferenceImageFilter< ITK_TEMPLATE_2 x > \
00361 FiniteDifferenceImageFilter##y; } \
00362 }
00363
00364 #if ITK_TEMPLATE_EXPLICIT
00365 # include "Templates/itkFiniteDifferenceImageFilter+-.h"
00366 #endif
00367
00368 #if ITK_TEMPLATE_TXX
00369 # include "itkFiniteDifferenceImageFilter.txx"
00370 #endif
00371
00372 #endif
00373