Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdgeMeshDiscretePrincipalCurvaturesEstimator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-01 23:03:04 $
00007   Version:   $Revision: 1.2 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
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       CoefficientType coefficent;
00087 
00088       OutputQEType* qe_it = qe;
00089       OutputQEType* qe_it2;
00090       OutputCurvatureType area( 0. ), sum_theta( 0. );
00091       OutputPointType q0, q1;
00092       OutputVectorType u;
00093 
00094       if( qe_it != qe_it->GetOnext() )
00095         {
00096         qe_it = qe;
00097         do
00098           {
00099           qe_it2 = qe_it->GetOnext();
00100           q0 = output->GetPoint( qe_it->GetDestination() );
00101           q1 = output->GetPoint( qe_it2->GetDestination() );
00102           
00103           Laplace += coefficent( output, qe_it ) * ( iP - q0 );
00104           // Compute Angle;
00105           sum_theta += static_cast< OutputCurvatureType >(
00106             TriangleType::ComputeAngle( q0, iP, q1 ) );
00107             
00108           area += ComputeMixedArea( qe_it, qe_it2 );
00109           qe_it = qe_it2;
00110           } while( qe_it != qe );
00111         area = ( area > 1e-10 ? ( 1. / area ) : 0. );
00112         Laplace *= 0.25 * area;
00113         m_Mean = Laplace.GetNorm();
00114         m_Gaussian = ( 2. * vnl_math::pi - sum_theta ) * area;
00115         }
00116       }
00117     }
00118     
00119   virtual OutputCurvatureType ComputeDelta( )
00120     {
00121     return  vnl_math_max( 0., m_Mean * m_Mean - m_Gaussian );
00122     }
00123     
00124 private:
00125   QuadEdgeMeshDiscretePrincipalCurvaturesEstimator( const Self& ); // purposely not implemented
00126   void operator = ( const Self& ); // purposely not implemented
00127 
00128 };
00129 
00130 }
00131 
00132 #endif
00133 

Generated at Tue Sep 15 04:27:03 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000