ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkDiscreteMeanCurvatureQuadEdgeMeshFilter_h 00019 #define __itkDiscreteMeanCurvatureQuadEdgeMeshFilter_h 00020 00021 #include "itkDiscreteCurvatureQuadEdgeMeshFilter.h" 00022 #include "itkQuadEdgeMeshParamMatrixCoefficients.h" 00023 00024 namespace itk 00025 { 00035 template< class TInputMesh, class TOutputMesh=TInputMesh > 00036 class ITK_EXPORT DiscreteMeanCurvatureQuadEdgeMeshFilter: 00037 public DiscreteCurvatureQuadEdgeMeshFilter< TInputMesh, TOutputMesh > 00038 { 00039 public: 00040 typedef DiscreteMeanCurvatureQuadEdgeMeshFilter Self; 00041 typedef SmartPointer< Self > Pointer; 00042 typedef SmartPointer< const Self > ConstPointer; 00043 typedef DiscreteCurvatureQuadEdgeMeshFilter< TInputMesh, TOutputMesh > Superclass; 00044 00045 typedef typename Superclass::InputMeshType InputMeshType; 00046 typedef typename Superclass::InputMeshPointer InputMeshPointer; 00047 00048 typedef typename Superclass::OutputMeshType OutputMeshType; 00049 typedef typename Superclass::OutputMeshPointer OutputMeshPointer; 00050 typedef typename Superclass::OutputPointsContainerPointer OutputPointsContainerPointer; 00051 typedef typename Superclass::OutputPointsContainerIterator OutputPointsContainerIterator; 00052 typedef typename Superclass::OutputPointType OutputPointType; 00053 typedef typename Superclass::OutputVectorType OutputVectorType; 00054 typedef typename Superclass::OutputCoordType OutputCoordType; 00055 typedef typename Superclass::OutputPointIdentifier OutputPointIdentifier; 00056 typedef typename Superclass::OutputCellIdentifier OutputCellIdentifier; 00057 typedef typename Superclass::OutputQEType OutputQEType; 00058 typedef typename Superclass::OutputMeshTraits OutputMeshTraits; 00059 typedef typename Superclass::OutputCurvatureType OutputCurvatureType; 00060 00061 typedef typename Superclass::TriangleType TriangleType; 00062 00064 itkTypeMacro(DiscreteMeanCurvatureQuadEdgeMeshFilter, DiscreteCurvatureQuadEdgeMeshFilter); 00065 00067 itkNewMacro(Self); 00068 00069 typedef ConformalMatrixCoefficients< OutputMeshType > CoefficientType; 00070 00071 #ifdef ITK_USE_CONCEPT_CHECKING 00072 00073 itkConceptMacro( OutputIsFloatingPointCheck, 00074 ( Concept::IsFloatingPoint< OutputCurvatureType > ) ); 00075 00077 #endif 00078 00079 protected: 00080 DiscreteMeanCurvatureQuadEdgeMeshFilter() {} 00081 ~DiscreteMeanCurvatureQuadEdgeMeshFilter() {} 00082 00083 virtual OutputCurvatureType EstimateCurvature(const OutputPointType & iP) 00084 { 00085 OutputMeshPointer output = this->GetOutput(); 00086 00087 OutputQEType *qe = iP.GetEdge(); 00088 00089 OutputCurvatureType oH(0.); 00090 00091 OutputVectorType Laplace; 00092 00093 Laplace.Fill(0.); 00094 00095 OutputCurvatureType area(0.); 00096 OutputVectorType normal; 00097 normal.Fill(0.); 00098 00099 if ( qe != 0 ) 00100 { 00101 if ( qe != qe->GetOnext() ) 00102 { 00103 CoefficientType coefficent; 00104 00105 OutputQEType *qe_it = qe; 00106 OutputQEType *qe_it2; 00107 00108 OutputCurvatureType temp_area; 00109 OutputCoordType temp_coeff; 00110 00111 OutputPointType q0, q1; 00112 OutputVectorType face_normal; 00113 00114 do 00115 { 00116 qe_it2 = qe_it->GetOnext(); 00117 q0 = output->GetPoint( qe_it->GetDestination() ); 00118 q1 = output->GetPoint( qe_it2->GetDestination() ); 00119 00120 temp_coeff = coefficent(output, qe_it); 00121 Laplace += temp_coeff * ( iP - q0 ); 00122 00123 temp_area = this->ComputeMixedArea(qe_it, qe_it2); 00124 area += temp_area; 00125 00126 face_normal = TriangleType::ComputeNormal(q0, iP, q1); 00127 normal += face_normal; 00128 00129 qe_it = qe_it2; 00130 } 00131 while ( qe_it != qe ); 00132 00133 if ( area < 1e-6 ) 00134 { 00135 oH = 0.; 00136 } 00137 else 00138 { 00139 if ( normal.GetSquaredNorm() > 0. ) 00140 { 00141 normal.Normalize(); 00142 Laplace *= 0.25 / area; 00143 oH = Laplace * normal; 00144 } 00145 else 00146 { 00147 oH = 0.; 00148 } 00149 } 00150 } 00151 } 00152 return oH; 00153 } 00154 00155 private: 00156 DiscreteMeanCurvatureQuadEdgeMeshFilter(const Self &); // purposely not 00157 // implemented 00158 void operator=(const Self &); // purposely not 00159 // implemented 00160 }; 00161 } 00162 #endif 00163