00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkFiniteDifferenceSparseImageFilter_h_
00018 #define __itkFiniteDifferenceSparseImageFilter_h_
00019
00020 #include "itkFiniteDifferenceSparseImageFunction.h"
00021 #include "itkFiniteDifferenceImageFilter.h"
00022 #include "itkMultiThreader.h"
00023 #include "itkSparseImage.h"
00024
00025 namespace itk {
00026
00060 template <class TInputImageType, class TSparseOutputImageType>
00061 class FiniteDifferenceSparseImageFilter
00062 : public FiniteDifferenceImageFilter <TInputImageType,
00063 TSparseOutputImageType>
00064 {
00065 public:
00067 typedef FiniteDifferenceSparseImageFilter Self;
00068 typedef FiniteDifferenceImageFilter<TInputImageType,
00069 TSparseOutputImageType> Superclass;
00070 typedef SmartPointer<Self> Pointer;
00071 typedef SmartPointer<const Self> ConstPointer;
00072
00074 itkTypeMacro(FiniteDifferenceSparseImageFilter, FiniteDifferenceImageFilter);
00075
00077 typedef typename Superclass::InputImageType InputImageType;
00078 typedef typename Superclass::OutputImageType SparseOutputImageType;
00079 typedef typename Superclass::PixelType PixelType;
00080 typedef typename Superclass::TimeStepType TimeStepType;
00081 typedef typename Superclass::FiniteDifferenceFunctionType
00082 FiniteDifferenceFunctionType;
00083
00084
00087 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00088
00090 typedef typename SparseOutputImageType::IndexType IndexType;
00091 typedef typename SparseOutputImageType::SizeType SizeType;
00092 typedef typename SparseOutputImageType::NodeType OutputNodeType;
00093 typedef typename SparseOutputImageType::NodeListType NodeListType;
00094
00096 typedef typename OutputNodeType::NodeDataType NodeDataType;
00097
00101 typedef typename OutputNodeType::NodeValueType NodeValueType;
00102
00104 typedef FiniteDifferenceSparseImageFunction <SparseOutputImageType>
00105 SparseFunctionType;
00106
00108 void SetSparseFunction( SparseFunctionType *sf );
00109
00110 itkSetMacro(PrecomputeFlag, bool);
00111 itkGetMacro(PrecomputeFlag, bool);
00112
00113 protected:
00114 FiniteDifferenceSparseImageFilter();
00115 ~FiniteDifferenceSparseImageFilter() {}
00116 void PrintSelf(std::ostream& os, Indent indent) const;
00117
00121 virtual void Initialize();
00122
00125 virtual void AllocateUpdateBuffer() {};
00126
00129 virtual NodeDataType DataConstraint( const NodeDataType &data ) const
00130 { return data; }
00131
00132 private:
00134 struct ThreadRegionType
00135 {
00136
00137 typename NodeListType::Iterator first;
00138
00139 typename NodeListType::Iterator last;
00140 };
00141
00142 protected:
00144 int GetSplitRegion( int i, int num, ThreadRegionType &splitRegion );
00145
00148 virtual void ApplyUpdate( TimeStepType dt );
00149
00151 static ITK_THREAD_RETURN_TYPE ApplyUpdateThreaderCallback( void *arg );
00152 virtual void ThreadedApplyUpdate(TimeStepType dt,
00153 const ThreadRegionType ®ionToProcess,
00154 int threadId);
00156
00159 virtual TimeStepType CalculateChange();
00160
00162 static ITK_THREAD_RETURN_TYPE CalculateChangeThreaderCallback( void *arg );
00163 virtual TimeStepType ThreadedCalculateChange
00164 (const ThreadRegionType ®ionToProcess, int threadId);
00166
00170 virtual void PrecalculateChange();
00171
00173 static ITK_THREAD_RETURN_TYPE PrecalculateChangeThreaderCallback( void *arg );
00174 virtual void ThreadedPrecalculateChange
00175 (const ThreadRegionType ®ionToProcess, int threadId);
00177
00180 struct FDThreadStruct
00181 {
00182 FiniteDifferenceSparseImageFilter *Filter;
00183 TimeStepType TimeStep;
00184 TimeStepType *TimeStepList;
00185 bool *ValidTimeStepList;
00186 };
00187
00188 private:
00190 bool m_PrecomputeFlag;
00191
00193 SparseFunctionType *m_SparseFunction;
00194
00197 typename NodeListType::RegionListType m_RegionList;
00198
00199 FiniteDifferenceSparseImageFilter(const Self&);
00200 void operator=(const Self&);
00201 };
00202
00203 }
00204
00205 #ifndef ITK_MANUAL_INSTANTIATION
00206 #include "itkFiniteDifferenceSparseImageFilter.txx"
00207 #endif
00208
00209 #endif
00210