Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator_h
00019 #define __itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator_h
00020
00021 #include "itkQuadEdgeMeshDiscreteCurvatureEstimator.h"
00022 #include "itkQuadEdgeMeshParamMatrixCoefficients.h"
00023
00024 namespace itk
00025 {
00032 template< class TInputMesh, class TOutputMesh >
00033 class QuadEdgeMeshDiscretePrincipalCurvaturesEstimator :
00034 public QuadEdgeMeshDiscreteCurvatureEstimator< TInputMesh, TOutputMesh >
00035 {
00036 public:
00037 typedef QuadEdgeMeshDiscretePrincipalCurvaturesEstimator Self;
00038 typedef SmartPointer< Self > Pointer;
00039 typedef SmartPointer< const Self > ConstPointer;
00040 typedef QuadEdgeMeshDiscreteCurvatureEstimator<
00041 TInputMesh, TOutputMesh > Superclass;
00042
00043 typedef typename Superclass::InputMeshType InputMeshType;
00044 typedef typename Superclass::InputMeshPointer InputMeshPointer;
00045 typedef typename Superclass::OutputMeshType OutputMeshType;
00046 typedef typename Superclass::OutputMeshPointer OutputMeshPointer;
00047 typedef typename Superclass::OutputPointsContainerPointer OutputPointsContainerPointer;
00048 typedef typename Superclass::OutputPointsContainerIterator OutputPointsContainerIterator;
00049 typedef typename Superclass::OutputPointType OutputPointType;
00050 typedef typename Superclass::OutputVectorType OutputVectorType;
00051 typedef typename Superclass::OutputCoordType OutputCoordType;
00052 typedef typename Superclass::OutputPointIdentifier OutputPointIdentifier;
00053 typedef typename Superclass::OutputCellIdentifier OutputCellIdentifier;
00054 typedef typename Superclass::OutputQEType OutputQEType;
00055 typedef typename Superclass::OutputMeshTraits OutputMeshTraits;
00056 typedef typename Superclass::OutputCurvatureType OutputCurvatureType;
00057
00058 typedef typename Superclass::TriangleType TriangleType;
00059
00061 itkTypeMacro( QuadEdgeMeshDiscretePrincipalCurvaturesEstimator, QuadEdgeMeshDiscreteCurvatureEstimator );
00062
00063 typedef ConformalMatrixCoefficients< OutputMeshType > CoefficientType;
00064
00065 protected:
00066 QuadEdgeMeshDiscretePrincipalCurvaturesEstimator() :
00067 m_Gaussian( 0.0 ), m_Mean( 0.0 ){}
00068 ~QuadEdgeMeshDiscretePrincipalCurvaturesEstimator() {}
00069
00070 OutputCurvatureType m_Gaussian;
00071 OutputCurvatureType m_Mean;
00072
00073 void ComputeMeanAndGaussianCurvatures( const OutputPointType& iP )
00074 {
00075 OutputMeshPointer output = this->GetOutput();
00076
00077 OutputQEType* qe = iP.GetEdge( );
00078 m_Mean = 0.;
00079 m_Gaussian = 0.;
00080
00081 if( qe != 0 )
00082 {
00083 OutputVectorType Laplace;
00084 Laplace.Fill( 0. );
00085
00086 OutputQEType* qe_it = qe;
00087
00088 OutputCurvatureType area( 0. ), sum_theta( 0. );
00089
00090 if( qe_it != qe_it->GetOnext() )
00091 {
00092 qe_it = qe;
00093 OutputQEType* qe_it2;
00094
00095 OutputPointType q0, q1;
00096 OutputVectorType face_normal;
00097
00098 OutputVectorType normal;
00099 normal.Fill( 0. );
00100
00101 OutputCurvatureType temp_area;
00102 OutputCoordType temp_coeff;
00103
00104 CoefficientType coefficent;
00105
00106 do
00107 {
00108 qe_it2 = qe_it->GetOnext();
00109 q0 = output->GetPoint( qe_it->GetDestination() );
00110 q1 = output->GetPoint( qe_it2->GetDestination() );
00111
00112 temp_coeff = coefficent( output, qe_it );
00113 Laplace += temp_coeff * ( iP - q0 );
00114
00115
00116 sum_theta += static_cast< OutputCurvatureType >(
00117 TriangleType::ComputeAngle( q0, iP, q1 ) );
00118
00119 temp_area = ComputeMixedArea( qe_it, qe_it2 );
00120 area += temp_area;
00121
00122 face_normal = TriangleType::ComputeNormal( q0, iP, q1 );
00123 normal += face_normal;
00124
00125 qe_it = qe_it2;
00126 } while( qe_it != qe );
00127
00128 if( area > 1e-10 )
00129 {
00130 area = 1. / area;
00131 Laplace *= 0.25 * area;
00132 m_Mean = Laplace * normal;
00133 m_Gaussian = ( 2. * vnl_math::pi - sum_theta ) * area;
00134 }
00135 }
00136 }
00137 }
00138
00139 virtual OutputCurvatureType ComputeDelta( )
00140 {
00141 return vnl_math_max( 0., m_Mean * m_Mean - m_Gaussian );
00142 }
00143
00144 private:
00145 QuadEdgeMeshDiscretePrincipalCurvaturesEstimator( const Self& );
00146 void operator = ( const Self& );
00147
00148 };
00149
00150 }
00151
00152 #endif
00153