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<
00069 TInputImageType, 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 FiniteDifferenceFunctionType;
00082
00083
00086 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00087
00089 typedef typename SparseOutputImageType::IndexType IndexType;
00090 typedef typename SparseOutputImageType::SizeType SizeType;
00091 typedef typename SparseOutputImageType::NodeType OutputNodeType;
00092 typedef typename SparseOutputImageType::NodeListType NodeListType;
00093
00095 typedef typename OutputNodeType::NodeDataType NodeDataType;
00096
00100 typedef typename OutputNodeType::NodeValueType NodeValueType;
00101
00103 typedef FiniteDifferenceSparseImageFunction <SparseOutputImageType>
00104 SparseFunctionType;
00105
00107 void SetSparseFunction( SparseFunctionType *sf );
00108
00109 itkSetMacro(PrecomputeFlag, bool);
00110 itkGetMacro(PrecomputeFlag, bool);
00111
00112 protected:
00113 FiniteDifferenceSparseImageFilter();
00114 ~FiniteDifferenceSparseImageFilter() {}
00115 void PrintSelf(std::ostream& os, Indent indent) const;
00116
00120 virtual void Initialize();
00121
00124 virtual void AllocateUpdateBuffer() {};
00125
00128 virtual NodeDataType DataConstraint( const NodeDataType &data ) const
00129 { return data; }
00130
00131 private:
00133 struct ThreadRegionType
00134 {
00135
00136 typename NodeListType::Iterator first;
00137
00138 typename NodeListType::Iterator last;
00139 };
00140
00141 protected:
00143 int GetSplitRegion( int i, int num, ThreadRegionType &splitRegion );
00144
00147 virtual void ApplyUpdate( TimeStepType dt );
00148
00150 static ITK_THREAD_RETURN_TYPE ApplyUpdateThreaderCallback( void *arg );
00151 virtual void ThreadedApplyUpdate(TimeStepType dt,
00152 const ThreadRegionType ®ionToProcess,
00153 int threadId);
00155
00158 virtual TimeStepType CalculateChange();
00159
00161 static ITK_THREAD_RETURN_TYPE CalculateChangeThreaderCallback( void *arg );
00162 virtual TimeStepType ThreadedCalculateChange
00163 (const ThreadRegionType ®ionToProcess, int threadId);
00165
00169 virtual void PrecalculateChange();
00170
00172 static ITK_THREAD_RETURN_TYPE PrecalculateChangeThreaderCallback( void *arg );
00173 virtual void ThreadedPrecalculateChange
00174 (const ThreadRegionType ®ionToProcess, int threadId);
00176
00179 struct FDThreadStruct
00180 {
00181 FiniteDifferenceSparseImageFilter *Filter;
00182 TimeStepType TimeStep;
00183 TimeStepType *TimeStepList;
00184 bool *ValidTimeStepList;
00185 };
00186
00187 private:
00189 bool m_PrecomputeFlag;
00190
00192 SparseFunctionType *m_SparseFunction;
00193
00196 typename NodeListType::RegionListType m_RegionList;
00197
00198 FiniteDifferenceSparseImageFilter(const Self&);
00199 void operator=(const Self&);
00200 };
00201
00202 }
00203
00204 #ifndef ITK_MANUAL_INSTANTIATION
00205 #include "itkFiniteDifferenceSparseImageFilter.txx"
00206 #endif
00207
00208 #endif
00209