ITK  4.2.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:
75 
76  virtual OutputCurvatureType EstimateCurvature(const OutputPointType & iP) = 0;
77 
78  OutputCurvatureType ComputeMixedArea(OutputQEType *iQE1, OutputQEType *iQE2)
79  {
80  OutputMeshPointer output = this->GetOutput();
81 
83 
84  id[0] = iQE1->GetOrigin();
85  id[1] = iQE1->GetDestination();
86  id[2] = iQE2->GetDestination();
87 
88  OutputPointType p[3];
89 
90  for ( int i = 0; i < 3; i++ )
91  {
92  p[i] = output->GetPoint(id[i]);
93  }
94 
95  return static_cast< OutputCurvatureType >( TriangleType::ComputeMixedArea( p[0], p[1], p[2] ) );
96  }
97 
98  virtual void GenerateData()
99  {
100  this->CopyInputMeshToOutputMesh();
101 
102  OutputMeshPointer output = this->GetOutput();
103 
104  OutputPointsContainerPointer points = output->GetPoints();
105  OutputPointsContainerIterator p_it = points->Begin();
106 
107  OutputCurvatureType curvature;
108 
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:
118  DiscreteCurvatureQuadEdgeMeshFilter(const Self &); // purposely not
119  // implemented
120  void operator=(const Self &); // purposely not
121  // implemented
122 };
123 } // end namespace itk
124 
125 #endif
126