ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkDiscreteGaussianCurvatureQuadEdgeMeshFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkDiscreteGaussianCurvatureQuadEdgeMeshFilter_h
19 #define __itkDiscreteGaussianCurvatureQuadEdgeMeshFilter_h
20 
22 #include "vnl/vnl_math.h"
23 
24 
25 namespace itk
26 {
37 template< class TInputMesh, class TOutputMesh=TInputMesh >
39  public DiscreteCurvatureQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
40 {
41 public:
46  TInputMesh, TOutputMesh > Superclass;
47 
48  typedef typename Superclass::InputMeshType InputMeshType;
49  typedef typename Superclass::InputMeshPointer InputMeshPointer;
50 
51  typedef typename Superclass::OutputMeshType OutputMeshType;
52  typedef typename Superclass::OutputMeshPointer OutputMeshPointer;
53  typedef typename Superclass::OutputPointsContainerPointer OutputPointsContainerPointer;
54  typedef typename Superclass::OutputPointsContainerIterator OutputPointsContainerIterator;
55  typedef typename Superclass::OutputPointType OutputPointType;
56  typedef typename Superclass::OutputVectorType OutputVectorType;
57  typedef typename Superclass::OutputCoordType OutputCoordType;
58  typedef typename Superclass::OutputPointIdentifier OutputPointIdentifier;
59  typedef typename Superclass::OutputCellIdentifier OutputCellIdentifier;
60  typedef typename Superclass::OutputQEType OutputQEType;
61  typedef typename Superclass::OutputMeshTraits OutputMeshTraits;
62  typedef typename Superclass::OutputCurvatureType OutputCurvatureType;
63  typedef typename Superclass::TriangleType TriangleType;
64 
67 
69  itkNewMacro(Self);
70 
71 #ifdef ITK_USE_CONCEPT_CHECKING
72 
73  itkConceptMacro( OutputIsFloatingPointCheck,
75 
77 #endif
78 
79 protected:
82 
83  virtual OutputCurvatureType EstimateCurvature(const OutputPointType & iP)
84  {
85  OutputMeshPointer output = this->GetOutput();
86 
87  OutputQEType *qe = iP.GetEdge();
88 
89  if ( qe != 0 )
90  {
91  OutputQEType *qe_it = qe;
92  OutputQEType *qe_it2;
93 
94  OutputPointType q0, q1;
95 
96  OutputCurvatureType sum_theta = 0.;
97  OutputCurvatureType area = 0.;
98 
99  do
100  {
101  // cell_id = qe_it->GetLeft();
102  qe_it2 = qe_it->GetOnext();
103  q0 = output->GetPoint( qe_it->GetDestination() );
104  q1 = output->GetPoint( qe_it2->GetDestination() );
105 
106  // Compute Angle;
107  sum_theta += static_cast< OutputCurvatureType >(
108  TriangleType::ComputeAngle(q0, iP, q1) );
109  area += this->ComputeMixedArea(qe_it, qe_it2);
110  qe_it = qe_it2;
111  }
112  while ( qe_it != qe );
113 
114  return ( 2.0 * vnl_math::pi - sum_theta ) / area;
115  }
116 
117  return 0.;
118  }
119 
120 private:
121  DiscreteGaussianCurvatureQuadEdgeMeshFilter(const Self &); // purposely not
122  // implemented
123  void operator=(const Self &); // purposely not
124  // implemented
125 };
126 }
127 
128 #endif
129