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

itkDeformableMesh3DFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDeformableMesh3DFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-28 17:42:50 $
00007   Version:   $Revision: 1.29 $
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 __itkDeformableMesh3DFilter_h
00018 #define __itkDeformableMesh3DFilter_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 
00055 template <class TInputMesh, class TOutputMesh>
00056 class ITK_EXPORT DeformableMesh3DFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
00057 {
00058 public:
00060   typedef DeformableMesh3DFilter  Self;
00061 
00063   typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;
00064 
00066   typedef SmartPointer<Self>        Pointer;
00067   typedef SmartPointer<const Self>  ConstPointer;
00068 
00070   itkNewMacro(Self);
00071 
00073   itkTypeMacro(DeformableMesh3DFilter,MeshToMeshFilter);
00074 
00076   typedef TInputMesh                          InputMeshType;
00077   typedef typename InputMeshType::PointsContainerPointer
00078                                               InputPointsContainerPointer;
00079   typedef typename InputMeshType::PointsContainer::Iterator
00080                                               InputPointsContainerIterator;
00081   typedef typename InputMeshType::PointDataContainerPointer
00082                                               InputPointDataContainerPointer;
00083   typedef typename InputMeshType::PointDataContainer::Iterator
00084                                               InputPointDataContainerIterator;
00085   typedef typename InputMeshType::CellsContainerPointer
00086                                               InputCellsContainerPointer;
00087   typedef typename InputMeshType::CellsContainer::Iterator
00088                                               InputCellsContainerIterator;
00089   typedef typename InputMeshType::CellDataContainerPointer
00090                                               InputCellDataContainerPointer;
00091   typedef typename InputMeshType::CellDataContainer::Iterator
00092                                               InputCellDataContainerIterator;
00093 
00094   typedef TOutputMesh                         OutputMeshType;
00095   typedef typename OutputMeshType::PointsContainerPointer
00096                                               OutputPointsContainerPointer;
00097   typedef typename OutputMeshType::CellsContainer
00098                                               OutputCellsContainer;
00099   typedef typename OutputMeshType::CellsContainerPointer
00100                                               OutputCellsContainerPointer;
00101   typedef typename OutputMeshType::PointsContainer::Iterator
00102                                               OutputPointsContainerIterator;
00103 
00105   typedef typename InputMeshType::CellType          CellType;
00106   typedef typename InputMeshType::CellTraits        CellTraits;
00107   typedef typename InputMeshType::PointType         InputPointType;
00108   typedef typename InputMeshType::PixelType         PixelType;
00109 
00111   typedef Image<unsigned char, 3>                      PotentialImageType;
00112   typedef ImageRegionIterator<PotentialImageType>      PotentialIterator;
00113   typedef CovariantVector<PixelType, 3>                GradientType;
00114   typedef Image<GradientType, 3>                       GradientImageType;
00115   typedef ImageRegionIterator<GradientImageType>       GradientIterator;
00116   typedef typename GradientImageType::SizeType         ImageSizeType;
00117   typedef typename GradientImageType::IndexType        ImageIndexType;
00118 
00119   typedef itk::CellInterface<PixelType, CellTraits>    TCellInterface;
00120   typedef itk::TriangleCell<TCellInterface>            TriCell;
00121 
00122   typedef CovariantVector<int, 3>                      int3DVector;
00123   typedef CovariantVector<double, 2>                   double2DVector;
00124   typedef CovariantVector<double, 3>                   double3DVector;
00125 
00126   /* Mesh pointer definition. */
00127   typedef typename InputMeshType::Pointer     InputMeshPointer;
00128   typedef typename OutputMeshType::Pointer    OutputMeshPointer;
00129   typedef typename GradientImageType::Pointer GradientImagePointer;
00130 
00131   /* Stiffness Matrix Type definition */
00132   typedef vnl_matrix_fixed<double, 4, 4>  StiffnessMatrixType;
00133   typedef StiffnessMatrixType *           StiffnessMatrixRawPointer; 
00134 
00136   void SetStiffnessMatrix( StiffnessMatrixType *stiff, int i );
00137 
00139   itkSetMacro(Gradient, GradientImagePointer);
00140   itkGetConstMacro(Gradient, GradientImagePointer);
00142 
00143   itkSetMacro(StepThreshold, int);
00144   itkGetConstMacro(StepThreshold, int);
00145 
00146   itkSetMacro(Stiffness, double2DVector);
00147   itkGetConstMacro(Stiffness, double2DVector);
00148 
00149   itkSetMacro(TimeStep, double);
00150   itkGetConstMacro(TimeStep, double);
00151 
00152   itkSetMacro(Scale, double3DVector);
00153 
00154   itkSetMacro(PotentialMagnitude, PixelType);
00155   itkSetMacro(GradientMagnitude, PixelType);
00156   itkSetMacro(PotentialOn, unsigned short);
00157   itkSetMacro(ObjectLabel, unsigned char);
00158 
00159   itkGetConstMacro(Normals, InputMeshPointer);
00160 
00161 protected:
00162   DeformableMesh3DFilter();
00163   ~DeformableMesh3DFilter();
00164   DeformableMesh3DFilter(const Self&) {}
00165   void operator=(const Self&) {}
00166   void PrintSelf(std::ostream& os, Indent indent) const;
00167 
00168   virtual void GenerateData();
00169 
00170 private:
00172   InputMeshPointer  m_Forces; 
00173   InputMeshPointer  m_Normals;
00174   InputMeshPointer  m_Displacements;
00175   InputMeshPointer  m_Derives;
00176   InputMeshPointer  m_Locations;
00177 
00178   void Initialize();
00179   void SetDefaultStiffnessMatrix();
00180   void SetMeshStiffness();
00181   void Advance();     // update data for next iteration
00182   void ComputeDt();   // compute point positions
00183   void ComputeOutput();
00184   void GradientFit(); // fit the model with gradient information
00185   void ComputeNormals();
00186   void PotentialFit();
00187 
00189   StiffnessMatrixType         m_StiffnessMatrix[10];
00190   StiffnessMatrixRawPointer  *m_K;
00191 
00193   double2DVector    m_Stiffness;
00194 
00196   double3DVector    m_Scale;
00197 
00199   int       m_NumberOfNodes;
00200   int       m_NumberOfCells;
00201 
00203   int       m_ImageHeight;
00204   int       m_ImageDepth;
00205 
00208   unsigned short m_ModelXUpLimit;
00209   unsigned short m_ModelXDownLimit;
00210   unsigned short m_ModelYUpLimit;
00211   unsigned short m_ModelYDownLimit;
00212   unsigned short m_ModelZUpLimit;
00213   unsigned short m_ModelZDownLimit;
00214   unsigned short m_PotentialOn;
00215   unsigned char  m_ObjectLabel;
00216   PixelType      m_GradientMagnitude;
00217   PixelType      m_PotentialMagnitude;
00218 
00220   GradientImagePointer        m_Gradient; 
00221   PotentialImageType::Pointer m_Potential;  
00222 };
00223 
00224 } // end namespace itk
00225 
00226 #ifndef ITK_MANUAL_INSTANTIATION
00227 #include "itkDeformableMesh3DFilter.txx"
00228 #endif
00229 
00230 #endif
00231 

Generated at Tue Sep 15 02:45:38 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000