ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkDiscretePrincipalCurvaturesQuadEdgeMeshFilter.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 __itkDiscretePrincipalCurvaturesQuadEdgeMeshFilter_h
19 #define __itkDiscretePrincipalCurvaturesQuadEdgeMeshFilter_h
20 
23 
24 namespace itk
25 {
33 template< class TInputMesh, class TOutputMesh=TInputMesh >
35  public DiscreteCurvatureQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
36 {
37 public:
42  TInputMesh, TOutputMesh > Superclass;
43 
44  typedef typename Superclass::InputMeshType InputMeshType;
45  typedef typename Superclass::InputMeshPointer InputMeshPointer;
46  typedef typename Superclass::OutputMeshType OutputMeshType;
47  typedef typename Superclass::OutputMeshPointer OutputMeshPointer;
48  typedef typename Superclass::OutputPointsContainerPointer OutputPointsContainerPointer;
49  typedef typename Superclass::OutputPointsContainerIterator OutputPointsContainerIterator;
50  typedef typename Superclass::OutputPointType OutputPointType;
51  typedef typename Superclass::OutputVectorType OutputVectorType;
52  typedef typename Superclass::OutputCoordType OutputCoordType;
53  typedef typename Superclass::OutputPointIdentifier OutputPointIdentifier;
54  typedef typename Superclass::OutputCellIdentifier OutputCellIdentifier;
55  typedef typename Superclass::OutputQEType OutputQEType;
56  typedef typename Superclass::OutputMeshTraits OutputMeshTraits;
58 
59  typedef typename Superclass::TriangleType TriangleType;
60 
63 
65 
66 #ifdef ITK_USE_CONCEPT_CHECKING
67 
68  itkConceptMacro( OutputIsFloatingPointCheck,
70 
72 #endif
73 
74 protected:
76  m_Gaussian(0.0), m_Mean(0.0){}
78 
81 
82  void ComputeMeanAndGaussianCurvatures(const OutputPointType & iP)
83  {
84  OutputMeshPointer output = this->GetOutput();
85 
86  OutputQEType *qe = iP.GetEdge();
87 
88  m_Mean = 0.;
89  m_Gaussian = 0.;
90 
91  if ( qe != 0 )
92  {
93  OutputVectorType Laplace;
94  Laplace.Fill(0.);
95 
96  OutputQEType *qe_it = qe;
97 
98  OutputCurvatureType area(0.), sum_theta(0.);
99 
100  if ( qe_it != qe_it->GetOnext() )
101  {
102  qe_it = qe;
103  OutputQEType *qe_it2;
104 
105  OutputPointType q0, q1;
106  OutputVectorType face_normal;
107 
108  OutputVectorType normal;
109  normal.Fill(0.);
110 
111  OutputCurvatureType temp_area;
112  OutputCoordType temp_coeff;
113 
114  CoefficientType coefficent;
115 
116  do
117  {
118  qe_it2 = qe_it->GetOnext();
119  q0 = output->GetPoint( qe_it->GetDestination() );
120  q1 = output->GetPoint( qe_it2->GetDestination() );
121 
122  temp_coeff = coefficent(output, qe_it);
123  Laplace += temp_coeff * ( iP - q0 );
124 
125  // Compute Angle;
126  sum_theta += static_cast< OutputCurvatureType >(
127  TriangleType::ComputeAngle(q0, iP, q1) );
128 
129  temp_area = this->ComputeMixedArea(qe_it, qe_it2);
130  area += temp_area;
131 
132  face_normal = TriangleType::ComputeNormal(q0, iP, q1);
133  normal += face_normal;
134 
135  qe_it = qe_it2;
136  }
137  while ( qe_it != qe );
138 
139  if ( area > 1e-10 )
140  {
141  area = 1. / area;
142  Laplace *= 0.25 * area;
143  m_Mean = Laplace * normal;
144  m_Gaussian = ( 2. * vnl_math::pi - sum_theta ) * area;
145  }
146  }
147  }
148  }
149 
150  virtual OutputCurvatureType ComputeDelta()
151  {
152  return vnl_math_max( static_cast<OutputCurvatureType>( 0. ),
153  m_Mean * m_Mean - m_Gaussian );
154  }
155 
156 private:
157  DiscretePrincipalCurvaturesQuadEdgeMeshFilter(const Self &); // purposely
158  // not
159  // implemented
160  void operator=(const Self &); // purposely
161  // not
162  // implemented
163 };
164 }
165 
166 #endif
167