00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkDeformableMeshFilter_h
00018 #define __itkDeformableMeshFilter_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
00054 template <class TInputMesh, class TOutputMesh>
00055 class DeformableMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
00056 {
00057 public:
00059 typedef DeformableMeshFilter Self;
00060 typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;
00061 typedef SmartPointer<Self> Pointer;
00062 typedef SmartPointer<const Self> ConstPointer;
00063
00065 itkNewMacro(Self);
00066
00068 itkTypeMacro(DeformableMeshFilter,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::PointsContainer::Iterator
00092 OutputPointsContainerIterator;
00093 typedef Image<unsigned short, 3> ImageType;
00094 typedef CovariantVector<float, 3> GradientType;
00095 typedef Image<GradientType, 3> GradientImageType;
00096 typedef ImageRegionIterator<ImageType> ImageIterator;
00097 typedef ImageRegionIterator<GradientImageType> GradientIterator;
00098 typedef typename InputMeshType::Pointer InputMeshPointer;
00099 typedef typename OutputMeshType::Pointer OutputMeshPointer;
00100 typedef typename ImageType::Pointer ImagePointer;
00101 typedef typename ImageType::IndexType IndexType;
00102 typedef typename GradientImageType::Pointer GradientPointer;
00103
00105 typedef Vector<float, 3> FloatVector;
00106 typedef Vector<int, 3> IntVector;
00107
00109 typedef typename InputMeshType::CellType CellType;
00110 typedef typename InputMeshType::CellTraits CellTraits;
00111 typedef CellInterface<float, CellTraits> CellInterfaceType;
00112 typedef TriangleCell<CellInterfaceType> TriCell;
00113 typedef typename InputMeshType::PointType IPT;
00114 typedef typename InputMeshType::PixelType PT;
00115
00117 void ComputeForce();
00118 void Initialize();
00119 void SetStiffnessMatrix();
00120 void Advance();
00121 void SetStiffness(double a, double b);
00122 void SetResolution(int a, int b, int c);
00123 void SetCenter(int a, int b, int c);
00124 void Reset();
00125 void ComputeDt();
00126 void ComputeOutput();
00127 void SetPotential(ImagePointer potential);
00128 void SetGradient(GradientPointer gradient);
00129 void NodeAddition();
00130 void SliceAddition(int i);
00131 void NodesRearrange();
00132 void GapSearch();
00133 void GradientFit();
00134 void ComputeNormals();
00135 void ACDSearch();
00136 void ComputeShrinkForce();
00137 void InitialFit();
00138
00140 itkSetMacro(ImageOutput, ImagePointer);
00141 itkGetMacro(ImageOutput, ImagePointer);
00142
00144 itkSetMacro(FirstSlice, int);
00145 itkGetMacro(FirstSlice, int);
00146
00148 itkSetMacro(NeighborRadius, int);
00149 itkSetMacro(StepThreshold1, int);
00150 itkSetMacro(StepThreshold2, int);
00151 itkGetMacro(Resolution, int*);
00152 itkGetMacro(Normals, InputMeshPointer);
00153
00154 protected:
00155 DeformableMeshFilter();
00156 ~DeformableMeshFilter() {}
00157 void PrintSelf(std::ostream& os, Indent indent) const;
00158
00159 virtual void GenerateData();
00160
00161 private:
00162 DeformableMeshFilter(const Self&);
00163 void operator=(const Self&);
00164
00166 InputMeshPointer m_Forces;
00167 InputMeshPointer m_Normals;
00168 InputMeshPointer m_Displacements;
00169 InputMeshPointer m_Derives;
00170 InputMeshPointer m_Locations;
00171 InputMeshPointer m_Input;
00172 OutputMeshPointer m_Output;
00173
00175 vnl_matrix_fixed<double, 4, 4> NStiffness;
00176 vnl_matrix_fixed<double, 4, 4> SStiffness;
00177 vnl_matrix_fixed<double, 4, 4> CStiffness;
00178 vnl_matrix_fixed<double, 4, 4> **K;
00179
00180 double m_Stiffness[2];
00181 double TimeStep;
00182 int m_Resolution[3];
00183 IndexType m_Center;
00184 float m_MiniT;
00185 int m_Step;
00186 int m_NumNodes;
00187 int m_NumCells;
00188 int m_NumNewNodes;
00189 int *m_GapLocations;
00190 bool m_NewNode;
00191 int m_NewNodesExisted;
00192 int m_NewNodeLimit;
00193 int m_ImageWidth;
00194 int m_ImageHeight;
00195 int m_ImageDepth;
00196 int m_ModelXUpLimit;
00197 int m_ModelXDownLimit;
00198 int m_ModelYUpLimit;
00199 int m_ModelYDownLimit;
00200 int m_ModelZUpLimit;
00201 int m_ModelZDownLimit;
00202 int **m_ACD;
00203 int m_ModelRestart;
00204 int m_StepThreshold1;
00205 int m_StepThreshold2;
00206 int m_FirstSlice;
00207 int m_NeighborRadius;
00208
00209 ImagePointer m_Potential;
00210 GradientPointer m_Gradient;
00211
00212
00213 ImagePointer m_ImageOutput;
00214 unsigned short m_ObjectLabel;
00215
00216 typedef ImageType::SizeType PotentialSizeType;
00217
00218 };
00219
00220 }
00221
00222 #ifndef ITK_MANUAL_INSTANTIATION
00223 #include "itkDeformableMeshFilter.txx"
00224 #endif
00225
00226 #endif