/usr/include/InsightToolkit/Review/itkQuadEdgeMeshSmoothing.txx 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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkQuadEdgeMeshSmoothing.txx
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 __itkQuadEdgeMeshSmoothing_txx
#define __itkQuadEdgeMeshSmoothing_txx
#include "itkQuadEdgeMeshSmoothing.h"
namespace itk
{
template< class TInputMesh, class TOutputMesh >
QuadEdgeMeshSmoothing< TInputMesh, TOutputMesh >
::QuadEdgeMeshSmoothing()
{
this->m_CoefficientsMethod = 0;
this->m_DelaunayConforming = false;
this->m_NumberOfIterations = 1;
this->m_RelaxationFactor = static_cast< OutputCoordType >( 1.0 );
this->m_InputDelaunayFilter = InputOutputDelaunayConformingType::New();
this->m_OutputDelaunayFilter = OutputDelaunayConformingType::New();
}
template< class TInputMesh, class TOutputMesh >
QuadEdgeMeshSmoothing< TInputMesh, TOutputMesh >::~QuadEdgeMeshSmoothing()
{
}
template< class TInputMesh, class TOutputMesh >
void QuadEdgeMeshSmoothing< TInputMesh, TOutputMesh >::
GenerateData()
{
OutputMeshPointer mesh = OutputMeshType::New();
OutputPointsContainerPointer temp = OutputPointsContainer::New();
temp->Reserve( this->GetInput()->GetNumberOfPoints() );
OutputPointsContainerPointer points;
OutputPointsContainerIterator it;
OutputPointType p;
OutputPointType q;
OutputPointType r;
OutputVectorType v;
OutputCoordType coeff;
OutputCoordType sum_coeff;
OutputCoordType den;
OutputQEType * qe;
OutputQEType * qe_it;
if( this->m_DelaunayConforming )
{
m_InputDelaunayFilter->SetInput( this->GetInput() );
if( m_NumberOfIterations == 0 )
{
m_InputDelaunayFilter->GraftOutput( this->GetOutput() );
m_InputDelaunayFilter->Update();
this->GraftOutput( m_InputDelaunayFilter->GetOutput() );
}
else
{
m_InputDelaunayFilter->Update();
mesh = m_InputDelaunayFilter->GetOutput();
}
}
else
{
if( m_NumberOfIterations == 0 )
{
this->CopyInputMeshToOutputMesh();
}
else
{
this->CopyMeshToMesh(this->GetInput(), mesh);
}
}
for( unsigned int iter = 0; iter < m_NumberOfIterations; ++iter )
{
points = mesh->GetPoints();
for( it = points->Begin(); it != points->End(); ++it )
{
p = it.Value();
qe = p.GetEdge();
if( qe != 0 )
{
r = p;
v.Fill( 0.0 );
qe_it = qe;
sum_coeff = 0.;
do
{
q = mesh->GetPoint( qe_it->GetDestination() );
coeff = ( *m_CoefficientsMethod )( mesh, qe_it );
sum_coeff += coeff;
v += coeff * ( q - p );
qe_it = qe_it->GetOnext();
} while( qe_it != qe );
den = 1.0 / static_cast< OutputCoordType >( sum_coeff );
v *= den;
r += m_RelaxationFactor * v;
r.SetEdge( qe );
temp->SetElement( it.Index(), r );
}
else
{
temp->SetElement( it.Index(), p );
}
}
mesh->SetPoints( temp );
if( this->m_DelaunayConforming )
{
mesh->DisconnectPipeline();
m_OutputDelaunayFilter->SetInput( mesh );
if( iter + 1 == m_NumberOfIterations )
{
m_OutputDelaunayFilter->GraftOutput( this->GetOutput() );
m_OutputDelaunayFilter->Update();
this->GraftOutput( m_OutputDelaunayFilter->GetOutput() );
}
else
{
m_OutputDelaunayFilter->Update();
mesh = m_OutputDelaunayFilter->GetOutput();
}
}
if( iter + 1 == m_NumberOfIterations )
{
this->GraftOutput( mesh );
}
}
}
}
#endif
|