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: 2008-12-08 16:00:51 $
00007   Version:   $Revision: 1.27 $
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 
00050 template <class TInputMesh, class TOutputMesh>
00051 class ITK_EXPORT DeformableMesh3DFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
00052 {
00053 public:
00055   typedef DeformableMesh3DFilter  Self;
00056 
00058   typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;
00059 
00061   typedef SmartPointer<Self>        Pointer;
00062   typedef SmartPointer<const Self>  ConstPointer;
00063 
00065   itkNewMacro(Self);
00066 
00068   itkTypeMacro(DeformableMesh3DFilter,MeshToMeshFilter);
00069 
00071   typedef TInputMesh                          InputMeshType;
00072   typedef typename InputMeshType::PointsContainerPointer
00073                                               InputPointsContainerPointer;
00074   typedef typename InputMeshType::PointsContainer::Iterator
00075                                               InputPointsContainerIterator;
00076   typedef typename InputMeshType::PointDataContainerPointer
00077                                               InputPointDataContainerPointer;
00078   typedef typename InputMeshType::PointDataContainer::Iterator
00079                                               InputPointDataContainerIterator;
00080   typedef typename InputMeshType::CellsContainerPointer
00081                                               InputCellsContainerPointer;
00082   typedef typename InputMeshType::CellsContainer::Iterator
00083                                               InputCellsContainerIterator;
00084   typedef typename InputMeshType::CellDataContainerPointer
00085                                               InputCellDataContainerPointer;
00086   typedef typename InputMeshType::CellDataContainer::Iterator
00087                                               InputCellDataContainerIterator;
00088 
00089   typedef TOutputMesh                         OutputMeshType;
00090   typedef typename OutputMeshType::PointsContainerPointer
00091                                               OutputPointsContainerPointer;
00092   typedef typename OutputMeshType::CellsContainer
00093                                               OutputCellsContainer;
00094   typedef typename OutputMeshType::CellsContainerPointer
00095                                               OutputCellsContainerPointer;
00096   typedef typename OutputMeshType::PointsContainer::Iterator
00097                                               OutputPointsContainerIterator;
00098 
00100   typedef typename InputMeshType::CellType          CellType;
00101   typedef typename InputMeshType::CellTraits        CellTraits;
00102   typedef typename InputMeshType::PointType         InputPointType;
00103   typedef typename InputMeshType::PixelType         PixelType;
00104 
00106   typedef Image<unsigned char, 3>                      PotentialImageType;
00107   typedef ImageRegionIterator<PotentialImageType>      PotentialIterator;
00108   typedef CovariantVector<PixelType, 3>                GradientType;
00109   typedef Image<GradientType, 3>                       GradientImageType;
00110   typedef ImageRegionIterator<GradientImageType>       GradientIterator;
00111   typedef typename GradientImageType::SizeType         ImageSizeType;
00112   typedef typename GradientImageType::IndexType        ImageIndexType;
00113 
00114   typedef itk::CellInterface<PixelType, CellTraits>    TCellInterface;
00115   typedef itk::TriangleCell<TCellInterface>            TriCell;
00116 
00117   typedef CovariantVector<int, 3>                      int3DVector;
00118   typedef CovariantVector<double, 2>                   double2DVector;
00119   typedef CovariantVector<double, 3>                   double3DVector;
00120 
00121   /* Mesh pointer definition. */
00122   typedef typename InputMeshType::Pointer     InputMeshPointer;
00123   typedef typename OutputMeshType::Pointer    OutputMeshPointer;
00124   typedef typename GradientImageType::Pointer GradientImagePointer;
00125 
00126   /* Stiffness Matrix Type definition */
00127   typedef vnl_matrix_fixed<double, 4, 4>  StiffnessMatrixType;
00128   typedef StiffnessMatrixType *           StiffnessMatrixRawPointer; 
00129 
00131   void SetStiffnessMatrix( StiffnessMatrixType *stiff, int i );
00132 
00134   itkSetMacro(Gradient, GradientImagePointer);
00135   itkGetMacro(Gradient, GradientImagePointer);
00137 
00138   itkSetMacro(StepThreshold, int);
00139   itkGetMacro(StepThreshold, int);
00140 
00141   itkSetMacro(Stiffness, double2DVector);
00142   itkGetMacro(Stiffness, double2DVector);
00143 
00144   itkSetMacro(TimeStep, double);
00145   itkGetMacro(TimeStep, double);
00146 
00147   itkSetMacro(Scale, double3DVector);
00148 
00149   itkSetMacro(PotentialMagnitude, PixelType);
00150   itkSetMacro(GradientMagnitude, PixelType);
00151   itkSetMacro(PotentialOn, unsigned short);
00152   itkSetMacro(ObjectLabel, unsigned char);
00153 
00154   itkGetMacro(Normals, InputMeshPointer);
00155 
00156 protected:
00157   DeformableMesh3DFilter();
00158   ~DeformableMesh3DFilter();
00159   DeformableMesh3DFilter(const Self&) {}
00160   void operator=(const Self&) {}
00161   void PrintSelf(std::ostream& os, Indent indent) const;
00162 
00163   virtual void GenerateData();
00164 
00165 private:
00167   InputMeshPointer  m_Forces; 
00168   InputMeshPointer  m_Normals;
00169   InputMeshPointer  m_Displacements;
00170   InputMeshPointer  m_Derives;
00171   InputMeshPointer  m_Locations;
00172 
00173   void Initialize();
00174   void SetDefaultStiffnessMatrix();
00175   void SetMeshStiffness();
00176   void Advance();     // update data for next iteration
00177   void ComputeDt();   // compute point positions
00178   void ComputeOutput();
00179   void GradientFit(); // fit the model with gradient information
00180   void ComputeNormals();
00181   void PotentialFit();
00182 
00184   StiffnessMatrixType         m_StiffnessMatrix[10];
00185   StiffnessMatrixRawPointer  *m_K;
00186 
00188   double2DVector    m_Stiffness;
00189 
00191   double3DVector    m_Scale;
00192 
00194   int       m_NumberOfNodes;
00195   int       m_NumberOfCells;
00196 
00198   int       m_ImageHeight;
00199   int       m_ImageDepth;
00200 
00203   unsigned short m_ModelXUpLimit;
00204   unsigned short m_ModelXDownLimit;
00205   unsigned short m_ModelYUpLimit;
00206   unsigned short m_ModelYDownLimit;
00207   unsigned short m_ModelZUpLimit;
00208   unsigned short m_ModelZDownLimit;
00209   unsigned short m_PotentialOn;
00210   unsigned char  m_ObjectLabel;
00211   PixelType      m_GradientMagnitude;
00212   PixelType      m_PotentialMagnitude;
00213 
00215   GradientImagePointer        m_Gradient; 
00216   PotentialImageType::Pointer m_Potential;  
00217 };
00218 
00219 } // end namespace itk
00220 
00221 #ifndef ITK_MANUAL_INSTANTIATION
00222 #include "itkDeformableMesh3DFilter.txx"
00223 #endif
00224 
00225 #endif
00226 

Generated at Sat Feb 28 12:17:53 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000