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: 2002/10/01 04:30:35 $
00007   Version:   $Revision: 1.17 $
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 __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 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 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::CellsContainer
00092       OutputCellsContainer;
00093   typedef typename OutputMeshType::CellsContainerPointer
00094       OutputCellsContainerPointer;
00095   typedef typename OutputMeshType::PointsContainer::Iterator
00096       OutputPointsContainerIterator;
00097 
00099   typedef typename InputMeshType::CellType          CellType;
00100   typedef typename InputMeshType::CellTraits        CellTraits;
00101   typedef itk::CellInterface<double, CellTraits>    TCellInterface;
00102   typedef itk::TriangleCell<TCellInterface>         TriCell;
00103   typedef typename InputMeshType::PointType         InputPointType;
00104   typedef typename InputMeshType::PixelType         PixelType;
00105 
00107   typedef CovariantVector<PixelType, 3>                GradientType;
00108   typedef Image<GradientType, 3>                       GradientImageType;
00109   typedef ImageRegionIterator<GradientImageType>       GradientIterator;
00110   typedef typename GradientImageType::SizeType         ImageSizeType;
00111   typedef typename GradientImageType::IndexType        ImageIndexType;
00112   typedef CovariantVector<int, 3>                      int3DVector;
00113   typedef CovariantVector<double, 2>                   double2DVector;
00114   typedef CovariantVector<double, 3>                   double3DVector;
00115 
00116   /* Mesh pointer definition. */
00117   typedef typename InputMeshType::Pointer     InputMeshPointer;
00118   typedef typename OutputMeshType::Pointer    OutputMeshPointer;
00119   typedef typename GradientImageType::Pointer GradientImagePointer;
00120 
00122   void SetStiffnessMatrix( vnl_matrix_fixed<double, 4, 4> *stiff, int i );
00123 
00125   itkSetMacro(Gradient, GradientImagePointer);
00126   itkGetMacro(Gradient, GradientImagePointer);
00127 
00128   itkSetMacro(StepThreshold, int);
00129   itkGetMacro(StepThreshold, int);
00130 
00131   itkSetMacro(Resolution, int3DVector);
00132   itkGetMacro(Resolution, int3DVector);
00133 
00134   itkSetMacro(Stiffness, double2DVector);
00135   itkGetMacro(Stiffness, double2DVector);
00136 
00137   itkSetMacro(TimeStep, double);
00138   itkGetMacro(TimeStep, double);
00139 
00140   itkSetMacro(NormalUpdate, unsigned char);
00141   itkGetMacro(NormalUpdate, unsigned char);
00142 
00143   itkSetMacro(Center, ImageIndexType);
00144 
00145   itkSetMacro(Scale, double3DVector);
00146 
00147 protected:
00148   DeformableMesh3DFilter();
00149   ~DeformableMesh3DFilter() {}
00150   DeformableMesh3DFilter(const Self&) {}
00151   void operator=(const Self&) {}
00152   void PrintSelf(std::ostream& os, Indent indent) const;
00153 
00154   virtual void GenerateData();
00155 
00156 private:
00158   InputMeshPointer  m_Forces; 
00159   InputMeshPointer  m_Normals;
00160   InputMeshPointer  m_Displacements;
00161   InputMeshPointer  m_Derives;
00162   InputMeshPointer  m_Locations;
00163 
00164   void Initialize();
00165   void SetDefaultStiffnessMatrix();
00166   void SetMeshStiffness();
00167   void Advance();     // update data for next iteration
00168   void ComputeDt();   // compute point positions
00169   void ComputeOutput();
00170   void GradientFit(); // fit the model with gradient information
00171   void ComputeNormals();
00172 
00174   vnl_matrix_fixed<double, 4, 4> Stiffness[10];
00175   vnl_matrix_fixed<double, 4, 4> **K;
00176   
00178   double2DVector    m_Stiffness;
00179   double            m_TimeStep;      
00180   int3DVector       m_Resolution;
00181   ImageIndexType    m_Center;
00182   double3DVector    m_Scale;
00183   int       m_Step;          
00184   int       m_NumberOfNodes;
00185   int       m_NumberOfCells;
00186   int       m_ImageWidth;      
00187   int       m_ImageHeight;
00188   int       m_ImageDepth;
00189   int       m_StepThreshold;
00190   unsigned short m_ModelXUpLimit;
00191   unsigned short m_ModelXDownLimit;
00192   unsigned short m_ModelYUpLimit;
00193   unsigned short m_ModelYDownLimit;
00194   unsigned short m_ModelZUpLimit;
00195   unsigned short m_ModelZDownLimit;
00196   unsigned char  m_NormalUpdate;
00197 
00199   GradientImagePointer  m_Gradient; 
00200   
00201 };
00202 
00203 } // end namespace itk
00204 
00205 #ifndef ITK_MANUAL_INSTANTIATION
00206 #include "itkDeformableMesh3DFilter.txx"
00207 #endif
00208 
00209 #endif

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