00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkDeformableSimplexMesh3DFilter_H
00018 #define __itkDeformableSimplexMesh3DFilter_H
00019
00020 #include "itkMeshToMeshFilter.h"
00021 #include "itkSimplexMesh.h"
00022 #include "itkSimplexMeshGeometry.h"
00023 #include "itkImage.h"
00024 #include "itkCovariantVector.h"
00025 #include "itkVector.h"
00026 #include "itkSphereSpatialFunction.h"
00027 #include "itkFloodFilledSpatialFunctionConditionalIterator.h"
00028 #include "itkVectorGradientMagnitudeImageFilter.h"
00029 #include "itkBinaryThresholdImageFilter.h"
00030 #include "itkArray.h"
00031
00032 #include <set>
00033
00034 namespace itk
00035 {
00036
00072 template <class TInputMesh, class TOutputMesh>
00073 class DeformableSimplexMesh3DFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
00074 {
00075 public:
00077 typedef DeformableSimplexMesh3DFilter Self;
00078
00080 typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;
00081
00083 typedef SmartPointer<Self> Pointer;
00084 typedef SmartPointer<const Self> ConstPointer;
00085
00087 itkNewMacro(Self);
00088
00090 itkTypeMacro(DeformableSimplexMesh3DFilter,MeshToMeshFilter);
00091
00093 typedef TInputMesh InputMeshType;
00094 typedef TOutputMesh OutputMeshType;
00095
00096 typedef typename InputMeshType::PointsContainerPointer InputPointsContainerPointer;
00097 typedef typename InputMeshType::PointsContainer InputPointsContainer;
00098 typedef typename InputMeshType::PointsContainer::Iterator InputPointsContainerIterator;
00099
00101 typedef typename InputMeshType::PointType PointType;
00102 typedef typename PointType::VectorType VectorType;
00103 typedef CovariantVector<
00104 typename VectorType::ValueType, 3 > CovariantVectorType;
00105 typedef typename InputMeshType::PixelType PixelType;
00106
00108 typedef CovariantVector<PixelType, 3> GradientType;
00109 typedef Image<GradientType, 3> GradientImageType;
00110 typedef Image<unsigned char, 3> BinaryOutput;
00111 typedef Image<float, 3> MagnitudeOutput;
00112 typedef typename GradientImageType::Pointer GradientImagePointer;
00113 typedef typename GradientImageType::IndexType GradientIndexType;
00114 typedef typename GradientImageType::PixelType GradientPixelType;
00115 typedef typename GradientIndexType::IndexValueType GradientIndexValueType;
00116 typedef typename GradientImageType::SizeType GradientImageSizeType;
00117
00118 typedef std::vector<GradientIndexType> ArrayGradientIndexType;
00119
00120
00121 typedef typename InputMeshType::Pointer InputMeshPointer;
00122 typedef typename OutputMeshType::Pointer OutputMeshPointer;
00123
00124
00125 typedef typename InputMeshType::PointType MeshPointType;
00126 typedef typename InputMeshType::CellsContainerPointer CellsContainerPointer;
00127 typedef typename InputMeshType::CellsContainer::Iterator CellsContainerIterator;
00128 typedef typename InputMeshType::NeighborListType InputNeighbors;
00129 typedef typename InputMeshType::NeighborListType::iterator InputNeighborsIterator;
00130
00131 typedef itk::MapContainer<unsigned long, std::set<unsigned long> > VertexNeighborListType;
00132 typedef std::set<unsigned long> NeighborSetType;
00133 typedef std::set<unsigned long> IndexSetType;
00134 typedef typename NeighborSetType::iterator NeighborSetIterator;
00135 typedef typename IndexSetType::iterator IndexSetIterator;
00136
00137
00138 typedef typename InputMeshType::GeometryMapType GeometryMapType;
00139 typedef typename GeometryMapType::Pointer GeometryMapPointer;
00140 typedef typename GeometryMapType::Iterator GeometryMapIterator;
00141
00142
00150 itkSetMacro(Gradient, GradientImagePointer);
00151
00155 itkGetMacro(Gradient, GradientImagePointer);
00156
00160 itkSetMacro(Iterations, int);
00161 itkGetMacro(Iterations, int);
00162
00164 itkSetMacro(Alpha, double);
00165
00167 itkGetMacro(Alpha, double);
00168
00170 itkSetMacro(Beta, double);
00171
00173 itkGetMacro(Beta, double);
00174
00176 itkSetMacro(Gamma, double);
00177
00179 itkGetMacro(Gamma, double);
00180
00182 itkSetMacro(Damping, double);
00183
00185 itkGetMacro(Damping, double);
00186
00188 itkSetMacro(Rigidity, unsigned int);
00189
00191 itkGetMacro(Rigidity, unsigned int);
00192
00194 itkSetMacro(Locality, double);
00195
00197 itkGetMacro(Locality, double);
00198
00200 itkSetMacro(MaxMagnitude, float);
00201
00202
00204 itkSetMacro(Range, int);
00205
00207 itkGetMacro(Range, int);
00208
00209 itkSetObjectMacro(Data, GeometryMapType );
00210 itkGetObjectMacro(Data, GeometryMapType );
00211
00213 itkGetMacro(ImageWidth,int);
00214 itkGetMacro(ImageHeight,int);
00215 itkGetMacro(ImageDepth,int);
00216
00218 itkGetMacro(Step, int);
00219
00220
00221 protected:
00222 DeformableSimplexMesh3DFilter();
00223 ~DeformableSimplexMesh3DFilter();
00224 DeformableSimplexMesh3DFilter(const Self&);
00225 void operator=(const Self&);
00226
00227 void PrintSelf(std::ostream& os, Indent indent) const;
00228
00229
00231 virtual void GenerateData();
00232
00233
00239 virtual void Initialize();
00240
00246 virtual void ComputeGeometry();
00247
00253 virtual void ComputeDisplacement();
00254
00258 virtual void ComputeInternalForce(SimplexMeshGeometry* data);
00259
00263 virtual void ComputeExternalForce(SimplexMeshGeometry* data);
00264
00269 virtual void ComputeOutput();
00270
00274 virtual void UpdateReferenceMetrics();
00275
00279 double L_Func(double r,double d, double phi);
00280
00284 GradientIndexType BresenhamLine(GradientIndexType a,GradientIndexType b);
00285
00289 PointType ComputeBarycentricCoordinates(PointType p, SimplexMeshGeometry* data);
00290
00291
00299 double m_Alpha;
00300
00307 double m_Beta;
00308
00315 double m_Gamma;
00316
00317 double m_Damping;
00324 unsigned int m_Rigidity;
00325
00329 double m_Locality;
00330
00331
00335 int m_Range;
00336
00337
00339 int m_Step;
00341 int m_ImageWidth;
00343 int m_ImageHeight;
00345 int m_ImageDepth;
00346
00348 int m_Iterations;
00349
00350
00351 float m_MaxMagnitude;
00355 GeometryMapPointer m_Data;
00356
00357
00358 GradientImagePointer m_Gradient;
00359
00360
00361 };
00362
00363
00364 }
00365
00366 #ifndef ITK_MANUAL_INSTANTIATION
00367 #include "itkDeformableSimplexMesh3DFilter.txx"
00368 #endif
00369
00370 #endif //__itkDeformableSimplexMesh3DFilter_H