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

itkDeformableMeshFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDeformableMeshFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/09/23 18:12:28 $
00007   Version:   $Revision: 1.12 $
00008 
00009   Copyright (c) 2002 Insight 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 __itkDeformableMeshFilter_h
00018 #define __itkDeformableMeshFilter_h
00019 
00020 #include "itkMeshToMeshFilter.h"
00021 #include "vnl/vnl_matrix_fixed.h"
00022 #include "vnl/vnl_math.h"
00023 #include "itkMesh.h"
00024 #include "itkVector.h"
00025 #include "itkTriangleCell.h"
00026 #include "itkImage.h"
00027 #include "itkImageRegionIterator.h"
00028 #include <itkCovariantVector.h>
00029 
00030 namespace itk
00031 {
00032 
00054 template <class TInputMesh, class TOutputMesh>
00055 class DeformableMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
00056 {
00057 public:
00059   typedef DeformableMeshFilter  Self;
00060   typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;
00061   typedef SmartPointer<Self>  Pointer;
00062   typedef SmartPointer<const Self>  ConstPointer;
00063 
00065   itkNewMacro(Self);
00066   
00068   itkTypeMacro(DeformableMeshFilter,MeshToMeshFilter);
00069 
00071   typedef TInputMesh InputMeshType;
00072   typedef TOutputMesh OutputMeshType;
00073   typedef typename InputMeshType::PointsContainerPointer
00074       InputPointsContainerPointer;
00075   typedef typename InputMeshType::PointsContainer::Iterator
00076       InputPointsContainerIterator;
00077   typedef typename InputMeshType::PointDataContainerPointer
00078       InputPointDataContainerPointer;
00079   typedef typename InputMeshType::PointDataContainer::Iterator
00080       InputPointDataContainerIterator;
00081   typedef typename InputMeshType::CellsContainerPointer
00082       InputCellsContainerPointer;
00083   typedef typename InputMeshType::CellsContainer::Iterator
00084       InputCellsContainerIterator;
00085   typedef typename InputMeshType::CellDataContainerPointer
00086       InputCellDataContainerPointer;
00087   typedef typename InputMeshType::CellDataContainer::Iterator
00088       InputCellDataContainerIterator;
00089   typedef typename OutputMeshType::PointsContainerPointer
00090       OutputPointsContainerPointer;
00091   typedef typename OutputMeshType::PointsContainer::Iterator
00092       OutputPointsContainerIterator;
00093   typedef Image<unsigned short, 3>   ImageType;
00094   typedef CovariantVector<float, 3> GradientType;
00095   typedef Image<GradientType, 3>  GradientImageType;
00096   typedef ImageRegionIterator<ImageType> ImageIterator;
00097   typedef ImageRegionIterator<GradientImageType> GradientIterator;
00098   typedef typename InputMeshType::Pointer InputMeshPointer;
00099   typedef typename OutputMeshType::Pointer  OutputMeshPointer;
00100   typedef typename ImageType::Pointer   ImagePointer;
00101   typedef typename ImageType::IndexType   IndexType;
00102   typedef typename GradientImageType::Pointer   GradientPointer;
00103 
00105   typedef Vector<float, 3>       FloatVector;
00106   typedef Vector<int, 3>       IntVector;
00107 
00109   typedef typename InputMeshType::CellType    CellType;
00110   typedef typename InputMeshType::CellTraits  CellTraits;
00111   typedef CellInterface<float, CellTraits>    CellInterfaceType;
00112   typedef TriangleCell<CellInterfaceType>     TriCell;
00113   typedef typename InputMeshType::PointType   IPT;
00114   typedef typename InputMeshType::PixelType   PT;
00115 
00117   void ComputeForce();
00118   void Initialize();
00119   void SetStiffnessMatrix();
00120   void Advance();             // update data for next iteration
00121   void SetStiffness(double a, double b);
00122   void SetResolution(int a, int b, int c);
00123   void SetCenter(int a, int b, int c);
00124   void Reset();               // reset all data
00125   void ComputeDt();             // compute point positions
00126   void ComputeOutput();
00127   void SetPotential(ImagePointer potential);
00128   void SetGradient(GradientPointer gradient);
00129   void NodeAddition();
00130   void SliceAddition(int i);
00131   void NodesRearrange();          
00132   void GapSearch();       
00133   void GradientFit();           // fit the model with gradient information
00134   void ComputeNormals();
00135   void ACDSearch();             // remove weird structures on the model surface
00136   void ComputeShrinkForce();        // force in case we shrink the model
00137   void InitialFit();              // locate the model near the objects
00138 
00140   itkSetMacro(ImageOutput, ImagePointer);
00141   itkGetMacro(ImageOutput, ImagePointer);
00142 
00144   itkSetMacro(FirstSlice, int);
00145   itkGetMacro(FirstSlice, int);
00146 
00148   itkSetMacro(NeighborRadius, int);
00149   itkSetMacro(StepThreshold1, int);
00150   itkSetMacro(StepThreshold2, int);
00151   itkGetMacro(Resolution, int*);
00152   itkGetMacro(Normals, InputMeshPointer);
00153 
00154 protected:
00155   DeformableMeshFilter();
00156   ~DeformableMeshFilter() {}
00157   void PrintSelf(std::ostream& os, Indent indent) const;
00158 
00159   virtual void GenerateData();
00160 
00161 private:
00162   DeformableMeshFilter(const Self&); //purposely not implemented
00163   void operator=(const Self&); //purposely not implemented
00164   
00166   InputMeshPointer  m_Forces; 
00167   InputMeshPointer  m_Normals;
00168   InputMeshPointer  m_Displacements;
00169   InputMeshPointer  m_Derives;
00170   InputMeshPointer  m_Locations;
00171   InputMeshPointer  m_Input;
00172   OutputMeshPointer m_Output;
00173 
00175   vnl_matrix_fixed<double, 4, 4> NStiffness;
00176   vnl_matrix_fixed<double, 4, 4> SStiffness;
00177   vnl_matrix_fixed<double, 4, 4> CStiffness;
00178   vnl_matrix_fixed<double, 4, 4> **K;
00179   
00180   double  m_Stiffness[2];
00181   double  TimeStep;       // the time step of each iteration
00182   int   m_Resolution[3];
00183   IndexType m_Center;
00184   float   m_MiniT;        // variabel help to stop the model when near potential estimation
00185   int   m_Step;         // the number of iteration 
00186   int   m_NumNodes;
00187   int   m_NumCells;
00188   int   m_NumNewNodes;      // for adding new nodes, now disabled for further tests
00189   int   *m_GapLocations;
00190   bool   m_NewNode;
00191   int   m_NewNodesExisted;
00192   int   m_NewNodeLimit;
00193   int   m_ImageWidth;       // input image size
00194   int   m_ImageHeight;
00195   int   m_ImageDepth;
00196   int   m_ModelXUpLimit;    // the following 6 variables record the size of the model
00197   int   m_ModelXDownLimit;
00198   int   m_ModelYUpLimit;
00199   int   m_ModelYDownLimit;
00200   int   m_ModelZUpLimit;
00201   int   m_ModelZDownLimit;
00202   int   **m_ACD;        // help to remove the weird structure on the model surface
00203   int   m_ModelRestart;
00204   int   m_StepThreshold1;   // the threshold decide when to transfer from potential fit to gradient fit
00205   int   m_StepThreshold2;   // the threshold decide when to stop the model
00206   int   m_FirstSlice;     // variable help to relocate the model when try to load 
00207   int   m_NeighborRadius;   // the gradient fit range
00208 
00209   ImagePointer    m_Potential;  // for calculate of image force from potential
00210   GradientPointer m_Gradient;   // for calculate of image force from gradient
00211 
00212   // for Gibbs Prior Model parameters' recalculation 
00213   ImagePointer    m_ImageOutput; 
00214   unsigned short  m_ObjectLabel;
00215 
00216   typedef ImageType::SizeType PotentialSizeType;
00217   
00218 };
00219 
00220 } // end namespace itk
00221 
00222 #ifndef ITK_MANUAL_INSTANTIATION
00223 #include "itkDeformableMeshFilter.txx"
00224 #endif
00225 
00226 #endif

Generated at Wed Mar 12 01:12:52 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000