ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkDiscreteMeanCurvatureQuadEdgeMeshFilter.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 __itkDiscreteMeanCurvatureQuadEdgeMeshFilter_h
19 #define __itkDiscreteMeanCurvatureQuadEdgeMeshFilter_h
20 
23 
24 namespace itk
25 {
35 template< class TInputMesh, class TOutputMesh=TInputMesh >
37  public DiscreteCurvatureQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
38 {
39 public:
44 
45  typedef typename Superclass::InputMeshType InputMeshType;
46  typedef typename Superclass::InputMeshPointer InputMeshPointer;
47 
48  typedef typename Superclass::OutputMeshType OutputMeshType;
49  typedef typename Superclass::OutputMeshPointer OutputMeshPointer;
50  typedef typename Superclass::OutputPointsContainerPointer OutputPointsContainerPointer;
51  typedef typename Superclass::OutputPointsContainerIterator OutputPointsContainerIterator;
52  typedef typename Superclass::OutputPointType OutputPointType;
53  typedef typename Superclass::OutputVectorType OutputVectorType;
54  typedef typename Superclass::OutputCoordType OutputCoordType;
55  typedef typename Superclass::OutputPointIdentifier OutputPointIdentifier;
56  typedef typename Superclass::OutputCellIdentifier OutputCellIdentifier;
57  typedef typename Superclass::OutputQEType OutputQEType;
58  typedef typename Superclass::OutputMeshTraits OutputMeshTraits;
59  typedef typename Superclass::OutputCurvatureType OutputCurvatureType;
60 
61  typedef typename Superclass::TriangleType TriangleType;
62 
65 
67  itkNewMacro(Self);
68 
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  OutputCurvatureType oH(0.);
90 
91  OutputVectorType Laplace;
92 
93  Laplace.Fill(0.);
94 
95  OutputCurvatureType area(0.);
96  OutputVectorType normal;
97  normal.Fill(0.);
98 
99  if ( qe != 0 )
100  {
101  if ( qe != qe->GetOnext() )
102  {
103  CoefficientType coefficent;
104 
105  OutputQEType *qe_it = qe;
106  OutputQEType *qe_it2;
107 
108  OutputCurvatureType temp_area;
109  OutputCoordType temp_coeff;
110 
111  OutputPointType q0, q1;
112  OutputVectorType face_normal;
113 
114  do
115  {
116  qe_it2 = qe_it->GetOnext();
117  q0 = output->GetPoint( qe_it->GetDestination() );
118  q1 = output->GetPoint( qe_it2->GetDestination() );
119 
120  temp_coeff = coefficent(output, qe_it);
121  Laplace += temp_coeff * ( iP - q0 );
122 
123  temp_area = this->ComputeMixedArea(qe_it, qe_it2);
124  area += temp_area;
125 
126  face_normal = TriangleType::ComputeNormal(q0, iP, q1);
127  normal += face_normal;
128 
129  qe_it = qe_it2;
130  }
131  while ( qe_it != qe );
132 
133  if ( area < 1e-6 )
134  {
135  oH = 0.;
136  }
137  else
138  {
139  if ( normal.GetSquaredNorm() > 0. )
140  {
141  normal.Normalize();
142  Laplace *= 0.25 / area;
143  oH = Laplace * normal;
144  }
145  else
146  {
147  oH = 0.;
148  }
149  }
150  }
151  }
152  return oH;
153  }
154 
155 private:
156  DiscreteMeanCurvatureQuadEdgeMeshFilter(const Self &); // purposely not
157  // implemented
158  void operator=(const Self &); // purposely not
159  // implemented
160 };
161 }
162 #endif
163