Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkFiniteDifferenceSparseImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFiniteDifferenceSparseImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-16 23:25:41 $
00007   Version:   $Revision: 1.7 $
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 __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   // the PixelType is from output image; therefore, it is a pointer
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     // this is the first element
00136     typename NodeListType::Iterator first;
00137     // this is one past the last element
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 &regionToProcess,
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 &regionToProcess, int threadId);
00165 
00169   virtual void PrecalculateChange();
00170 
00172   static ITK_THREAD_RETURN_TYPE PrecalculateChangeThreaderCallback( void *arg );
00173   virtual void ThreadedPrecalculateChange
00174   (const ThreadRegionType &regionToProcess, 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&); //purposely not implemented
00199   void operator=(const Self&); //purposely not implemented
00200 };
00201 
00202 } // end namespace itk
00203 
00204 #ifndef ITK_MANUAL_INSTANTIATION
00205 #include "itkFiniteDifferenceSparseImageFilter.txx"
00206 #endif
00207 
00208 #endif
00209 

Generated at Wed Nov 5 21:26:48 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000