ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkDiscreteGaussianCurvatureQuadEdgeMeshFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkDiscreteGaussianCurvatureQuadEdgeMeshFilter_h
00019 #define __itkDiscreteGaussianCurvatureQuadEdgeMeshFilter_h
00020 
00021 #include "itkDiscreteCurvatureQuadEdgeMeshFilter.h"
00022 #include "vnl/vnl_math.h"
00023 
00024 
00025 namespace itk
00026 {
00037 template< class TInputMesh, class TOutputMesh=TInputMesh >
00038 class ITK_EXPORT DiscreteGaussianCurvatureQuadEdgeMeshFilter:
00039   public DiscreteCurvatureQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
00040 {
00041 public:
00042   typedef DiscreteGaussianCurvatureQuadEdgeMeshFilter   Self;
00043   typedef SmartPointer< Self >                          Pointer;
00044   typedef SmartPointer< const Self >                    ConstPointer;
00045   typedef DiscreteCurvatureQuadEdgeMeshFilter<
00046     TInputMesh, TOutputMesh >                           Superclass;
00047 
00048   typedef typename Superclass::InputMeshType    InputMeshType;
00049   typedef typename Superclass::InputMeshPointer InputMeshPointer;
00050 
00051   typedef typename Superclass::OutputMeshType                OutputMeshType;
00052   typedef typename Superclass::OutputMeshPointer             OutputMeshPointer;
00053   typedef typename Superclass::OutputPointsContainerPointer  OutputPointsContainerPointer;
00054   typedef typename Superclass::OutputPointsContainerIterator OutputPointsContainerIterator;
00055   typedef typename Superclass::OutputPointType               OutputPointType;
00056   typedef typename Superclass::OutputVectorType              OutputVectorType;
00057   typedef typename Superclass::OutputCoordType               OutputCoordType;
00058   typedef typename Superclass::OutputPointIdentifier         OutputPointIdentifier;
00059   typedef typename Superclass::OutputCellIdentifier          OutputCellIdentifier;
00060   typedef typename Superclass::OutputQEType                  OutputQEType;
00061   typedef typename Superclass::OutputMeshTraits              OutputMeshTraits;
00062   typedef typename Superclass::OutputCurvatureType           OutputCurvatureType;
00063   typedef typename Superclass::TriangleType                  TriangleType;
00064 
00066   itkTypeMacro(DiscreteGaussianCurvatureQuadEdgeMeshFilter, DiscreteCurvatureQuadEdgeMeshFilter);
00067 
00069   itkNewMacro(Self);
00070 
00071 #ifdef ITK_USE_CONCEPT_CHECKING
00072 
00073   itkConceptMacro( OutputIsFloatingPointCheck,
00074                    ( Concept::IsFloatingPoint< OutputCurvatureType > ) );
00075 
00077 #endif
00078 
00079 protected:
00080   DiscreteGaussianCurvatureQuadEdgeMeshFilter() {}
00081   ~DiscreteGaussianCurvatureQuadEdgeMeshFilter() {}
00082 
00083   virtual OutputCurvatureType EstimateCurvature(const OutputPointType & iP)
00084   {
00085     OutputMeshPointer output = this->GetOutput();
00086 
00087     OutputQEType *qe = iP.GetEdge();
00088 
00089     if ( qe != 0 )
00090       {
00091       OutputQEType *qe_it = qe;
00092       OutputQEType *qe_it2;
00093 
00094       OutputPointType q0, q1;
00095 
00096       OutputCurvatureType sum_theta = 0.;
00097       OutputCurvatureType area = 0.;
00098 
00099       do
00100         {
00101         // cell_id = qe_it->GetLeft();
00102         qe_it2 = qe_it->GetOnext();
00103         q0 = output->GetPoint( qe_it->GetDestination() );
00104         q1 = output->GetPoint( qe_it2->GetDestination() );
00105 
00106         // Compute Angle;
00107         sum_theta += static_cast< OutputCurvatureType >(
00108           TriangleType::ComputeAngle(q0, iP, q1) );
00109         area += this->ComputeMixedArea(qe_it, qe_it2);
00110         qe_it = qe_it2;
00111         }
00112       while ( qe_it != qe );
00113 
00114       return ( 2.0 * vnl_math::pi - sum_theta ) / area;
00115       }
00116 
00117     return 0.;
00118   }
00119 
00120 private:
00121   DiscreteGaussianCurvatureQuadEdgeMeshFilter(const Self &); // purposely not
00122                                                                 // implemented
00123   void operator=(const Self &);                                 // purposely not
00124                                                                 // implemented
00125 };
00126 }
00127 
00128 #endif
00129