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-01-07 13:33:59 $
00007   Version:   $Revision: 1.6 $
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<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   // the PixelType is from output image; therefore, it is a pointer
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     // this is the first element
00137     typename NodeListType::Iterator first;
00138     // this is one past the last element
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 &regionToProcess,
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 &regionToProcess, int threadId);
00166 
00170   virtual void PrecalculateChange();
00171 
00173   static ITK_THREAD_RETURN_TYPE PrecalculateChangeThreaderCallback( void *arg );
00174   virtual void ThreadedPrecalculateChange
00175   (const ThreadRegionType &regionToProcess, 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&); //purposely not implemented
00200   void operator=(const Self&); //purposely not implemented
00201 };
00202 
00203 } // end namespace itk
00204 
00205 #ifndef ITK_MANUAL_INSTANTIATION
00206 #include "itkFiniteDifferenceSparseImageFilter.txx"
00207 #endif
00208 
00209 #endif
00210 

Generated at Mon Apr 14 12:25:24 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000