/usr/include/InsightToolkit/Review/itkQuadEdgeMeshDiscreteCurvatureEstimator.h is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkQuadEdgeMeshDiscreteCurvatureEstimator.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkQuadEdgeMeshDiscreteCurvatureEstimator_h
#define __itkQuadEdgeMeshDiscreteCurvatureEstimator_h
#include <itkQuadEdgeMeshToQuadEdgeMeshFilter.h>
#include "itkTriangleHelper.h"
namespace itk
{
/**
* \class QuadEdgeMeshDiscreteCurvatureEstimator
*
* \brief FIXME
*
*/
template< class TInputMesh, class TOutputMesh >
class QuadEdgeMeshDiscreteCurvatureEstimator :
public QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
{
public:
typedef QuadEdgeMeshDiscreteCurvatureEstimator Self;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
typedef QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > Superclass;
typedef TInputMesh InputMeshType;
typedef typename InputMeshType::Pointer InputMeshPointer;
typedef TOutputMesh OutputMeshType;
typedef typename OutputMeshType::Pointer OutputMeshPointer;
typedef typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer;
typedef typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator;
typedef typename OutputMeshType::PointType OutputPointType;
typedef typename OutputPointType::CoordRepType OutputCoordType;
typedef typename OutputMeshType::PointIdentifier OutputPointIdentifier;
typedef typename OutputMeshType::CellIdentifier OutputCellIdentifier;
typedef typename OutputMeshType::QEType OutputQEType;
typedef typename OutputMeshType::MeshTraits OutputMeshTraits;
typedef typename OutputMeshTraits::PixelType OutputCurvatureType;
typedef TriangleHelper< OutputPointType > TriangleType;
/** Run-time type information (and related methods). */
itkTypeMacro( QuadEdgeMeshDiscreteCurvatureEstimator, QuadEdgeMeshToQuadEdgeMeshFilter );
protected:
QuadEdgeMeshDiscreteCurvatureEstimator() {}
~QuadEdgeMeshDiscreteCurvatureEstimator() {}
virtual OutputCurvatureType EstimateCurvature( const OutputPointType& iP ) = 0;
OutputCurvatureType ComputeMixedArea( OutputQEType* iQE1, OutputQEType* iQE2 )
{
OutputMeshPointer output = this->GetOutput();
OutputPointIdentifier id[3];
id[0] = iQE1->GetOrigin();
id[1] = iQE1->GetDestination();
id[2] = iQE2->GetDestination();
OutputPointType p[3];
for( int i = 0; i < 3; i++ )
{
p[i] = output->GetPoint( id[i] );
}
if( !TriangleType::IsObtuse( p[0], p[1], p[2] ) )
{
OutputCurvatureType sq_d01 =
static_cast< OutputCurvatureType >(
p[0].SquaredEuclideanDistanceTo( p[1] ) );
OutputCurvatureType sq_d02 =
static_cast< OutputCurvatureType >(
p[0].SquaredEuclideanDistanceTo( p[2] ) );
OutputCurvatureType cot_theta_210 =
TriangleType::Cotangent( p[2], p[1], p[0] );
OutputCurvatureType cot_theta_021 =
TriangleType::Cotangent( p[0], p[2], p[1] );
return 0.125 * ( sq_d02 * cot_theta_210 + sq_d01 * cot_theta_021 );
}
else
{
OutputCurvatureType area =
static_cast< OutputCurvatureType >(
TriangleType::ComputeArea( p[0], p[1], p[2] ) );
if( ( p[1] - p[0] ) * ( p[2] - p[0] ) < 0. )
{
return 0.5 * area;
}
else
{
return 0.25 * area;
}
}
}
virtual void GenerateData()
{
this->CopyInputMeshToOutputMesh();
OutputMeshPointer output = this->GetOutput();
OutputPointsContainerPointer points = output->GetPoints();
OutputPointsContainerIterator p_it = points->Begin();
OutputCurvatureType curvature;
while( p_it != points->End() )
{
curvature = EstimateCurvature( p_it->Value() );
output->SetPointData( p_it->Index(), curvature );
++p_it;
}
}
private:
QuadEdgeMeshDiscreteCurvatureEstimator( const Self& ); // purposely not implemented
void operator = ( const Self& ); // purposely not implemented
};
} // end namespace itk
#endif
|