00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 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 typename InputMeshType::PointType InputPointType;
00102 typedef typename InputMeshType::PixelType PixelType;
00103
00105 typedef Image<unsigned char, 3> PotentialImageType;
00106 typedef ImageRegionIterator<PotentialImageType> PotentialIterator;
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
00113 typedef itk::CellInterface<PixelType, CellTraits> TCellInterface;
00114 typedef itk::TriangleCell<TCellInterface> TriCell;
00115
00116 typedef CovariantVector<int, 3> int3DVector;
00117 typedef CovariantVector<double, 2> double2DVector;
00118 typedef CovariantVector<double, 3> double3DVector;
00119
00120
00121 typedef typename InputMeshType::Pointer InputMeshPointer;
00122 typedef typename OutputMeshType::Pointer OutputMeshPointer;
00123 typedef typename GradientImageType::Pointer GradientImagePointer;
00124
00125
00126 typedef vnl_matrix_fixed<double, 4, 4> StiffnessMatrixType;
00127 typedef StiffnessMatrixType * StiffnessMatrixRawPointer;
00128
00130 void SetStiffnessMatrix( StiffnessMatrixType *stiff, int i );
00131
00133 itkSetMacro(Gradient, GradientImagePointer);
00134 itkGetMacro(Gradient, GradientImagePointer);
00135
00136 itkSetMacro(StepThreshold, int);
00137 itkGetMacro(StepThreshold, int);
00138
00139 itkSetMacro(Stiffness, double2DVector);
00140 itkGetMacro(Stiffness, double2DVector);
00141
00142 itkSetMacro(TimeStep, double);
00143 itkGetMacro(TimeStep, double);
00144
00145 itkSetMacro(Scale, double3DVector);
00146
00147 itkSetMacro(PotentialMagnitude, PixelType);
00148 itkSetMacro(GradientMagnitude, PixelType);
00149 itkSetMacro(PotentialOn, unsigned short);
00150 itkSetMacro(ObjectLabel, unsigned char);
00151
00152 itkGetMacro(Normals, InputMeshPointer);
00153
00154 protected:
00155 DeformableMesh3DFilter();
00156 ~DeformableMesh3DFilter();
00157 DeformableMesh3DFilter(const Self&) {}
00158 void operator=(const Self&) {}
00159 void PrintSelf(std::ostream& os, Indent indent) const;
00160
00161 virtual void GenerateData();
00162
00163 private:
00165 InputMeshPointer m_Forces;
00166 InputMeshPointer m_Normals;
00167 InputMeshPointer m_Displacements;
00168 InputMeshPointer m_Derives;
00169 InputMeshPointer m_Locations;
00170
00171 void Initialize();
00172 void SetDefaultStiffnessMatrix();
00173 void SetMeshStiffness();
00174 void Advance();
00175 void ComputeDt();
00176 void ComputeOutput();
00177 void GradientFit();
00178 void ComputeNormals();
00179 void PotentialFit();
00180
00182 StiffnessMatrixType m_StiffnessMatrix[10];
00183 StiffnessMatrixRawPointer *m_K;
00184
00186 double2DVector m_Stiffness;
00187 double m_TimeStep;
00188 double3DVector m_Scale;
00189 int m_Step;
00190 int m_NumberOfNodes;
00191 int m_NumberOfCells;
00192 int m_ImageWidth;
00193 int m_ImageHeight;
00194 int m_ImageDepth;
00195 int m_StepThreshold;
00196 unsigned short m_ModelXUpLimit;
00197 unsigned short m_ModelXDownLimit;
00198 unsigned short m_ModelYUpLimit;
00199 unsigned short m_ModelYDownLimit;
00200 unsigned short m_ModelZUpLimit;
00201 unsigned short m_ModelZDownLimit;
00202 unsigned short m_PotentialOn;
00203 unsigned char m_ObjectLabel;
00204 PixelType m_GradientMagnitude;
00205 PixelType m_PotentialMagnitude;
00206
00208 GradientImagePointer m_Gradient;
00209 PotentialImageType::Pointer m_Potential;
00210 };
00211
00212 }
00213
00214 #ifndef ITK_MANUAL_INSTANTIATION
00215 #include "itkDeformableMesh3DFilter.txx"
00216 #endif
00217
00218 #endif