Go to the documentation of this file.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
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::PointsContainerConstPointer
00080 InputPointsContainerConstPointer;
00081 typedef typename InputMeshType::PointsContainer::Iterator
00082 InputPointsContainerIterator;
00083 typedef typename InputMeshType::PointsContainer::ConstIterator
00084 InputPointsContainerConstIterator;
00085 typedef typename InputMeshType::PointDataContainerPointer
00086 InputPointDataContainerPointer;
00087 typedef typename InputMeshType::PointDataContainer::Iterator
00088 InputPointDataContainerIterator;
00089 typedef typename InputMeshType::CellsContainerPointer
00090 InputCellsContainerPointer;
00091 typedef typename InputMeshType::CellsContainer::Iterator
00092 InputCellsContainerIterator;
00093 typedef typename InputMeshType::CellsContainerConstPointer
00094 InputCellsContainerConstPointer;
00095 typedef typename InputMeshType::CellsContainer::ConstIterator
00096 InputCellsContainerConstIterator;
00097 typedef typename InputMeshType::CellDataContainerPointer
00098 InputCellDataContainerPointer;
00099 typedef typename InputMeshType::CellDataContainer::Iterator
00100 InputCellDataContainerIterator;
00101 typedef typename InputMeshType::CellDataContainerConstPointer
00102 InputCellDataContainerConstPointer;
00103 typedef typename InputMeshType::CellDataContainer::ConstIterator
00104 InputCellDataContainerConstIterator;
00105
00106 typedef TOutputMesh OutputMeshType;
00107 typedef typename OutputMeshType::PointsContainerPointer
00108 OutputPointsContainerPointer;
00109 typedef typename OutputMeshType::CellsContainer
00110 OutputCellsContainer;
00111 typedef typename OutputMeshType::CellsContainerPointer
00112 OutputCellsContainerPointer;
00113 typedef typename OutputMeshType::PointsContainer::Iterator
00114 OutputPointsContainerIterator;
00115
00117 typedef typename InputMeshType::CellType CellType;
00118 typedef typename InputMeshType::CellTraits CellTraits;
00119 typedef typename InputMeshType::PointType InputPointType;
00120 typedef typename InputMeshType::PixelType PixelType;
00121
00123 typedef Image<unsigned char, 3> PotentialImageType;
00124 typedef ImageRegionIterator<PotentialImageType> PotentialIterator;
00125 typedef CovariantVector<PixelType, 3> GradientType;
00126 typedef Image<GradientType, 3> GradientImageType;
00127 typedef ImageRegionIterator<GradientImageType> GradientIterator;
00128 typedef typename GradientImageType::SizeType ImageSizeType;
00129 typedef typename GradientImageType::IndexType ImageIndexType;
00130
00131 typedef itk::CellInterface<PixelType, CellTraits> TCellInterface;
00132 typedef itk::TriangleCell<TCellInterface> TriCell;
00133
00134 typedef CovariantVector<int, 3> int3DVector;
00135 typedef CovariantVector<double, 2> double2DVector;
00136 typedef CovariantVector<double, 3> double3DVector;
00137
00138
00139 typedef typename InputMeshType::Pointer InputMeshPointer;
00140 typedef typename InputMeshType::ConstPointer InputMeshConstPointer;
00141 typedef typename OutputMeshType::Pointer OutputMeshPointer;
00142 typedef typename GradientImageType::Pointer GradientImagePointer;
00143
00144
00145 typedef vnl_matrix_fixed<double, 4, 4> StiffnessMatrixType;
00146 typedef StiffnessMatrixType * StiffnessMatrixRawPointer;
00147
00149 void SetStiffnessMatrix( StiffnessMatrixType *stiff, int i );
00150
00152 itkSetMacro(Gradient, GradientImagePointer);
00153 itkGetConstMacro(Gradient, GradientImagePointer);
00155
00156 itkSetMacro(StepThreshold, int);
00157 itkGetConstMacro(StepThreshold, int);
00158
00159 itkSetMacro(Stiffness, double2DVector);
00160 itkGetConstMacro(Stiffness, double2DVector);
00161
00162 itkSetMacro(TimeStep, double);
00163 itkGetConstMacro(TimeStep, double);
00164
00165 itkSetMacro(Scale, double3DVector);
00166
00167 itkSetMacro(PotentialMagnitude, PixelType);
00168 itkSetMacro(GradientMagnitude, PixelType);
00169 itkSetMacro(PotentialOn, unsigned short);
00170 itkSetMacro(ObjectLabel, unsigned char);
00171
00172 itkGetConstMacro(Normals, InputMeshPointer);
00173
00174 protected:
00175 DeformableMesh3DFilter();
00176 ~DeformableMesh3DFilter();
00177 DeformableMesh3DFilter(const Self&) {}
00178 void operator=(const Self&) {}
00179 void PrintSelf(std::ostream& os, Indent indent) const;
00180
00181 virtual void GenerateData();
00182
00183 private:
00185 InputMeshPointer m_Forces;
00186 InputMeshPointer m_Normals;
00187 InputMeshPointer m_Displacements;
00188 InputMeshPointer m_Derives;
00189 InputMeshPointer m_Locations;
00190
00191 void Initialize();
00192 void SetDefaultStiffnessMatrix();
00193 void SetMeshStiffness();
00194 void Advance();
00195 void ComputeDt();
00196 void ComputeOutput();
00197 void GradientFit();
00198 void ComputeNormals();
00199 void PotentialFit();
00200
00202 StiffnessMatrixType m_StiffnessMatrix[10];
00203 StiffnessMatrixRawPointer *m_K;
00204
00206 double2DVector m_Stiffness;
00207
00209 double3DVector m_Scale;
00210
00212 int m_NumberOfNodes;
00213 int m_NumberOfCells;
00214
00216 int m_ImageHeight;
00217 int m_ImageDepth;
00218
00221 unsigned short m_ModelXUpLimit;
00222 unsigned short m_ModelXDownLimit;
00223 unsigned short m_ModelYUpLimit;
00224 unsigned short m_ModelYDownLimit;
00225 unsigned short m_ModelZUpLimit;
00226 unsigned short m_ModelZDownLimit;
00227 unsigned short m_PotentialOn;
00228 unsigned char m_ObjectLabel;
00229 PixelType m_GradientMagnitude;
00230 PixelType m_PotentialMagnitude;
00231
00233 GradientImagePointer m_Gradient;
00234 PotentialImageType::Pointer m_Potential;
00235 };
00236
00237 }
00238
00239 #ifndef ITK_MANUAL_INSTANTIATION
00240 #include "itkDeformableMesh3DFilter.txx"
00241 #endif
00242
00243 #endif
00244