ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkDiscreteCurvatureQuadEdgeMeshFilter.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 __itkDiscreteCurvatureQuadEdgeMeshFilter_h
19 #define __itkDiscreteCurvatureQuadEdgeMeshFilter_h
20 
22 #include "itkConceptChecking.h"
23 #include "itkTriangleHelper.h"
24 
25 namespace itk
26 {
34 template< class TInputMesh, class TOutputMesh=TInputMesh >
36  public QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
37 {
38 public:
43 
44  typedef TInputMesh InputMeshType;
45  typedef typename InputMeshType::Pointer InputMeshPointer;
46 
47  typedef TOutputMesh OutputMeshType;
48  typedef typename OutputMeshType::Pointer OutputMeshPointer;
49  typedef typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer;
50  typedef typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator;
51  typedef typename OutputMeshType::PointType OutputPointType;
52  typedef typename OutputPointType::CoordRepType OutputCoordType;
53  typedef typename OutputMeshType::PointIdentifier OutputPointIdentifier;
54  typedef typename OutputMeshType::CellIdentifier OutputCellIdentifier;
55  typedef typename OutputMeshType::QEType OutputQEType;
56  typedef typename OutputMeshType::MeshTraits OutputMeshTraits;
57  typedef typename OutputMeshTraits::PixelType OutputCurvatureType;
58 
60 
63 
64 #ifdef ITK_USE_CONCEPT_CHECKING
65 
66  itkConceptMacro( OutputIsFloatingPointCheck,
68 
70 #endif
71 
72 protected:
73  DiscreteCurvatureQuadEdgeMeshFilter() : m_OutputMesh(0) {}
75 
76  virtual OutputCurvatureType EstimateCurvature(const OutputPointType & iP) = 0;
77 
78  OutputCurvatureType ComputeMixedArea(OutputQEType *iQE1, OutputQEType *iQE2)
79  {
80 
82 
83  id[0] = iQE1->GetOrigin();
84  id[1] = iQE1->GetDestination();
85  id[2] = iQE2->GetDestination();
86 
87  OutputPointType p[3];
88 
89  for ( int i = 0; i < 3; i++ )
90  {
91  p[i] = this->m_OutputMesh->GetPoint(id[i]);
92  }
93 
94  return static_cast< OutputCurvatureType >( TriangleType::ComputeMixedArea( p[0], p[1], p[2] ) );
95  }
96 
97  virtual void GenerateData()
98  {
99  this->CopyInputMeshToOutputMesh();
100 
101  OutputMeshPointer output = this->GetOutput();
102 
103  OutputPointsContainerPointer points = output->GetPoints();
104  OutputPointsContainerIterator p_it = points->Begin();
105 
106  OutputCurvatureType curvature;
107 
108  this->m_OutputMesh = this->GetOutput();
109  while ( p_it != points->End() )
110  {
111  curvature = this->EstimateCurvature( p_it->Value() );
112  output->SetPointData(p_it->Index(), curvature);
113  ++p_it;
114  }
115  }
116 
117 private:
120  DiscreteCurvatureQuadEdgeMeshFilter(const Self &); // purposely not
121  // implemented
122  void operator=(const Self &); // purposely not
123  // implemented
124 };
125 } // end namespace itk
127 
128 #endif
129