/usr/include/InsightToolkit/Review/itkQuadEdgeMeshFrontIterator.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 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkQuadEdgeMeshFrontIterator.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 __itkQuadEdgeMeshFrontIterator_txx
#define __itkQuadEdgeMeshFrontIterator_txx
#include "itkQuadEdgeMeshFrontIterator.h"
namespace itk
{
// ---------------------------------------------------------------------
template< class TMesh, class TQE >
QuadEdgeMeshFrontBaseIterator< TMesh, TQE >::
QuadEdgeMeshFrontBaseIterator( MeshType* mesh,
bool start,
QEType* seed )
: m_Mesh( mesh ), m_Seed( seed ), m_Start( start )
{
if( !mesh )
{
// Invalidate the iterator and call it quits
m_Start = false;
return;
}
if( !seed )
{
seed = FindDefaultSeed( );
if( !seed )
{
// Invalidate the iterator and call it quits
m_Start = false;
return;
}
}
m_Front = new FrontType;
m_Front->push_back( FrontAtom( seed, 0 ) );
m_IsPointVisited = IsVisitedContainerType::New( );
m_IsPointVisited->SetElement( seed->GetOrigin( ), true );
m_IsPointVisited->SetElement( seed->GetDestination( ), true );
m_CurrentEdge = seed;
}
// ---------------------------------------------------------------------
template< class TMesh, class TQE >
QuadEdgeMeshFrontBaseIterator< TMesh, TQE >::
~QuadEdgeMeshFrontBaseIterator( )
{
if( m_Front )
{
delete m_Front;
}
}
// ---------------------------------------------------------------------
template< class TMesh, class TQE >
QuadEdgeMeshFrontBaseIterator< TMesh, TQE >&
QuadEdgeMeshFrontBaseIterator< TMesh, TQE >::
operator++( )
{
// We continue only if not previously marked as finish...
if( !m_Start )
{
return( *this );
}
// ... or until the front is empty:
if( m_Front->empty( ) )
{
m_Start = false;
return( *this );
}
// Sort on the Cost:
m_Front->sort( );
// Consider the edge with lowest Cost:
FrontTypeIterator fit = m_Front->begin( );
QEType* edge = fit->m_Edge;
// Traverse the Onext ring in search of an unvisited Origin:
typedef typename QEType::IteratorGeom QEIterator;
for( QEIterator qit = edge->BeginGeomOnext( );
qit != edge->EndGeomOnext( );
qit++ )
{
QEType* oEdge = qit.Value( );
// Things are quite straightforward except when QEType
// is in fact a QEDual (in disguise) AND oEdge->GetDestination( )
// is m_NoFace [in which case oEdge->GetDestination() has a value
// but oEdge->IsDestination() is false]. When this is the case
// we consider oEdge->GetDestination() as already visited.
if( ( m_IsPointVisited->IndexExists( oEdge->GetDestination() ) )
|| ( ! oEdge->IsDestinationSet() ) )
{
continue;
}
else
{
// Mark the destination as visited:
m_IsPointVisited->SetElement( oEdge->GetDestination( ), true );
// Compute the Cost of the new OriginType:
CoordRepType oCost = this->GetCost( oEdge ) + fit->m_Cost;
// Push the Sym() on the front:
m_Front->push_back( FrontAtom( oEdge->GetSym( ), oCost ) );
// We still want to handle oEdge
m_CurrentEdge = oEdge;
return( *this );
}
}
// All the edge->Origin() neighbours were allready visited. Remove
// the edge from the front, and move to next edge...
m_Front->pop_front( );
m_CurrentEdge = (QEType*)0;
return( this->operator++() );
}
/**
* Find in the cell container an arbitrary underlying edge with type
* QEType.
*/
template< class TMesh, class TQE >
typename QuadEdgeMeshFrontBaseIterator< TMesh, TQE >::QEType*
QuadEdgeMeshFrontBaseIterator< TMesh, TQE >::
FindDefaultSeed( )
{
if( QEType* edge = dynamic_cast< QEType* >( m_Mesh->GetEdge( ) ) )
{
return edge;
}
typedef typename QEType::DualType QEDual;
if( QEDual* edge = dynamic_cast< QEDual* >( m_Mesh->GetEdge( ) ) )
{
return edge->GetRot( );
}
return (QEType*)0;
}
}
#endif
|