From: Leonardo Flórez-Valencia Date: Tue, 23 May 2017 20:02:39 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=FrontAlgorithms.git;a=commitdiff_plain;h=d5fe8fd4bac61fafea412c358323ad90fe2b034b ... --- diff --git a/examples/Dijkstra_Maurer.cxx b/examples/Dijkstra_Maurer.cxx index c67024a..0f01131 100644 --- a/examples/Dijkstra_Maurer.cxx +++ b/examples/Dijkstra_Maurer.cxx @@ -109,9 +109,12 @@ int main( int argc, char* argv[] ) TMSTToImage::Pointer mst_image = TMSTToImage::New( ); mst_image->SetInput( filter->GetMinimumSpanningTree( ) ); - for( TIndex iseed: filter->GetSeeds( ) ) - for( TIndex jseed: filter->GetSeeds( ) ) - mst_image->AddPath( iseed, jseed, 255, 0, 0 ); + TFilter::TSeedsInterface::TSeeds::const_iterator iseed = + filter->BeginSeeds( ); + TFilter::TSeedsInterface::TSeeds::const_iterator jseed; + for( ; iseed != filter->EndSeeds( ); ++iseed ) + for( jseed = filter->BeginSeeds( ); jseed != filter->EndSeeds( ); ++jseed ) + mst_image->AddPath( *iseed, *jseed, 255, 0, 0 ); TColorImageWriter::Pointer paths_writer = TColorImageWriter::New( ); paths_writer->SetInput( mst_image->GetOutput( ) ); diff --git a/examples/RegionGrow_Mori.cxx b/examples/RegionGrow_Mori.cxx index bdff6aa..2c36e8b 100644 --- a/examples/RegionGrow_Mori.cxx +++ b/examples/RegionGrow_Mori.cxx @@ -123,9 +123,10 @@ int main( int argc, char* argv[] ) // Show data TFilter::TCurve curve = filter->GetCurve( ); - for( TFilter::TCurveData data: curve ) + TFilter::TCurve::const_iterator data = curve.begin( ); + for( ; data != curve.end( ); ++data ) { - std::cout << data.XValue << " " << data.YValue << " " << data.Diff1 << std::endl; + std::cout << data->XValue << " " << data->YValue << " " << data->Diff1 << std::endl; } std::cout << std::endl diff --git a/lib/fpa/Base/Dijkstra.hxx b/lib/fpa/Base/Dijkstra.hxx index 149363d..765b9a8 100644 --- a/lib/fpa/Base/Dijkstra.hxx +++ b/lib/fpa/Base/Dijkstra.hxx @@ -115,8 +115,9 @@ GenerateData( ) // Init queue std::vector< _TNode > q; unsigned long frontId = 1; - for( TVertex seed: this->GetSeeds( ) ) - q.push_back( _TNode( seed, seed, frontId++ ) ); + typename TSeedsInterface::TSeeds::const_iterator sIt = this->BeginSeeds( ); + for( ; sIt != this->EndSeeds( ); ++sIt ) + q.push_back( _TNode( *sIt, *sIt, frontId++ ) ); // Main loop while( q.size( ) > 0 ) diff --git a/lib/fpa/Base/Graph.hxx b/lib/fpa/Base/Graph.hxx index 89fec7b..03f85a8 100644 --- a/lib/fpa/Base/Graph.hxx +++ b/lib/fpa/Base/Graph.hxx @@ -20,8 +20,8 @@ template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare > bool fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >:: RenameVertex( const TIndex& old_index, const TIndex& new_index ) { - auto old_v = this->m_Vertices.find( old_index ); - auto new_v = this->m_Vertices.find( new_index ); + typename TVertices::iterator old_v = this->m_Vertices.find( old_index ); + typename TVertices::iterator new_v = this->m_Vertices.find( new_index ); if( old_v != this->m_Vertices.end( ) && new_v == this->m_Vertices.end( ) ) { // Replace vertex @@ -29,14 +29,14 @@ RenameVertex( const TIndex& old_index, const TIndex& new_index ) this->m_Vertices.erase( old_index ); // Duplicate edges - auto mIt = this->m_Matrix.begin( ); - auto found_row = this->m_Matrix.end( ); + typename TMatrix::iterator mIt = this->m_Matrix.begin( ); + typename TMatrix::iterator found_row = this->m_Matrix.end( ); for( ; mIt != this->m_Matrix.end( ); ++mIt ) { if( mIt->first == old_index ) found_row = mIt; - auto rIt = mIt->second.begin( ); + typename TMatrixRow::iterator rIt = mIt->second.begin( ); for( ; rIt != mIt->second.end( ); ++rIt ) { if( mIt->first == old_index ) @@ -55,7 +55,7 @@ RenameVertex( const TIndex& old_index, const TIndex& new_index ) mIt = this->m_Matrix.begin( ); for( ; mIt != this->m_Matrix.end( ); ++mIt ) { - auto rIt = mIt->second.begin( ); + typename TMatrixRow::iterator rIt = mIt->second.begin( ); while( rIt != mIt->second.end( ) ) { if( rIt->first == old_index ) @@ -80,14 +80,14 @@ template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare > void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >:: RemoveVertex( const TIndex& index ) { - auto i = this->m_Vertices.find( index ); + typename TVertices::iterator i = this->m_Vertices.find( index ); if( i != this->m_Vertices.end( ) ) { // Delete vertex this->m_Vertices.erase( i ); // Delete edges starting from given vertex - auto mIt = this->m_Matrix.find( index ); + typename TMatrix::iterator mIt = this->m_Matrix.find( index ); if( mIt != this->m_Matrix.end( ) ) this->m_Matrix.erase( mIt ); @@ -95,7 +95,7 @@ RemoveVertex( const TIndex& index ) mIt = this->m_Matrix.begin( ); for( ; mIt != this->m_Matrix.end( ); ++mIt ) { - auto rIt = mIt->second.begin( ); + typename TMatrixRow::iterator rIt = mIt->second.begin( ); while( rIt != mIt->second.end( ) ) { if( rIt->first == index ) @@ -122,10 +122,10 @@ fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >:: GetEdges( const TIndex& orig, const TIndex& dest ) { static TEdges null_edges; - auto o = this->m_Matrix.find( orig ); + typename TMatrix::iterator o = this->m_Matrix.find( orig ); if( o != this->m_Matrix.find( orig ) ) { - auto d = o->second.find( dest ); + typename TMatrixRow::iterator d = o->second.find( dest ); if( d == o->second.end( ) ) { null_edges.clear( ); @@ -151,10 +151,10 @@ fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >:: GetEdges( const TIndex& orig, const TIndex& dest ) const { static const TEdges null_edges; - auto o = this->m_Matrix.find( orig ); + typename TMatrix::iterator o = this->m_Matrix.find( orig ); if( o != this->m_Matrix.find( orig ) ) { - auto d = o->second.find( dest ); + typename TMatrixRow::iterator d = o->second.find( dest ); if( d == o->second.end( ) ) return( null_edges ); else @@ -169,7 +169,7 @@ template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare > bool fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >:: HasEdge( const TIndex& orig, const TIndex& dest ) const { - auto mIt = this->m_Matrix.find( orig ); + typename TMatrix::const_iterator mIt = this->m_Matrix.find( orig ); if( mIt != this->m_Matrix.end( ) ) return( mIt->second.find( dest ) != mIt->second.end( ) ); else @@ -181,15 +181,15 @@ template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare > void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >:: RemoveEdge( const TIndex& orig, const TIndex& dest, const TCost& cost ) { - auto m = this->m_Matrix.find( orig ); + typename TMatrix::iterator m = this->m_Matrix.find( orig ); if( m != this->m_Matrix.end( ) ) { - auto r = m->second.find( dest ); + typename TMatrixRow::iterator r = m->second.find( dest ); if( r != m->second.end( ) ) { - auto e = r->second.end( ); + typename TEdges::iterator e = r->second.end( ); for( - auto i = r->second.begin( ); + typename TEdges::iterator i = r->second.begin( ); i != r->second.end( ) && e == r->second.end( ); ++i ) @@ -218,10 +218,10 @@ template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare > void fpa::Base::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >:: RemoveEdges( const TIndex& orig, const TIndex& dest ) { - auto m = this->m_Matrix.find( orig ); + typename TMatrix::iterator m = this->m_Matrix.find( orig ); if( m != this->m_Matrix.end( ) ) { - auto r = m->second.find( dest ); + typename TMatrixRow::iterator r = m->second.find( dest ); if( r != m->second.end( ) ) { m->second.erase( r ); @@ -242,10 +242,10 @@ GetSinks( ) const { std::set< _TIndex, _TIndexCompare > sinks; - auto vIt = this->m_Vertices.begin( ); + typename TVertices::iterator vIt = this->m_Vertices.begin( ); for( ; vIt != this->m_Vertices.end( ); ++vIt ) sinks.insert( vIt->first ); - auto mIt = this->m_Matrix.begin( ); + typename TMatrix::iterator mIt = this->m_Matrix.begin( ); for( ; mIt != this->m_Matrix.end( ); ++mIt ) sinks.erase( mIt->first ); diff --git a/lib/fpa/Base/MarksInterface.hxx b/lib/fpa/Base/MarksInterface.hxx index 56de375..5e7a3bc 100644 --- a/lib/fpa/Base/MarksInterface.hxx +++ b/lib/fpa/Base/MarksInterface.hxx @@ -81,8 +81,8 @@ template< class _TVertex > unsigned long fpa::Base::MarksInterface< _TVertex >:: _Collisions( const TVertex& a, const TVertex& b ) { - auto ma = this->_GetMark( a ); - auto mb = this->_GetMark( b ); + unsigned long ma = this->_GetMark( a ); + unsigned long mb = this->_GetMark( b ); if( ma == mb || ma == 0 || mb == 0 ) return( this->m_NumberOfFronts ); diff --git a/lib/fpa/Base/MoriRegionGrow.hxx b/lib/fpa/Base/MoriRegionGrow.hxx index b619bce..3b7d839 100644 --- a/lib/fpa/Base/MoriRegionGrow.hxx +++ b/lib/fpa/Base/MoriRegionGrow.hxx @@ -65,8 +65,9 @@ GenerateData( ) typedef std::pair< TVertex, unsigned long > _TNode; std::queue< _TNode > queues[ 2 ]; unsigned long frontId = 1; - for( TVertex seed: this->GetSeeds( ) ) - queues[ 0 ].push( _TNode( seed, frontId++ ) ); + typename TSeedsInterface::TSeeds::const_iterator sIt = this->BeginSeeds( ); + for( ; sIt != this->EndSeeds( ); ++sIt ) + queues[ 0 ].push( _TNode( *sIt, frontId++ ) ); unsigned int cur_queue = 0; unsigned int aux_queue = 1; @@ -104,8 +105,10 @@ GenerateData( ) // Add neighborhood TVertices neighbors = this->_GetNeighbors( node.first ); - for( TVertex neigh: neighbors ) + typename TVertices::const_iterator neighIt = neighbors.begin( ); + for( ; neighIt != neighbors.end( ); ++neighIt ) { + TVertex neigh = *neighIt; if( this->_IsMarked( neigh ) ) { // Invoke stop at collisions diff --git a/lib/fpa/Base/RegionGrow.hxx b/lib/fpa/Base/RegionGrow.hxx index 9e7bb7b..b942dfd 100644 --- a/lib/fpa/Base/RegionGrow.hxx +++ b/lib/fpa/Base/RegionGrow.hxx @@ -91,8 +91,9 @@ GenerateData( ) typedef std::pair< TVertex, unsigned long > _TNode; std::queue< _TNode > q; unsigned long frontId = 1; - for( TVertex seed: this->GetSeeds( ) ) - q.push( _TNode( seed, frontId++ ) ); + typename TSeedsInterface::TSeeds::const_iterator sIt = this->BeginSeeds( ); + for( ; sIt != this->EndSeeds( ); ++sIt ) + q.push( _TNode( *sIt, frontId++ ) ); // Main loop while( q.size( ) > 0 ) @@ -119,8 +120,10 @@ GenerateData( ) // Add neighborhood TVertices neighbors = this->_GetNeighbors( node.first ); - for( TVertex neigh: neighbors ) + typename TVertices::const_iterator neighIt = neighbors.begin( ); + for( ; neighIt != neighbors.end( ); ++neighIt ) { + TVertex neigh = *neighIt; if( this->_IsMarked( neigh ) ) { // Invoke stop at collisions diff --git a/lib/fpa/Base/Skeleton.hxx b/lib/fpa/Base/Skeleton.hxx index 91ec404..494eca3 100644 --- a/lib/fpa/Base/Skeleton.hxx +++ b/lib/fpa/Base/Skeleton.hxx @@ -50,7 +50,7 @@ fpa::Base::Skeleton< _VDim >:: GetEndPoints( ) const { std::vector< TIndex > res; - auto mIt = this->BeginEdgesRows( ); + typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( ); for( ; mIt != this->EndEdgesRows( ); ++mIt ) { unsigned long count = mIt->second.size( ); @@ -68,7 +68,7 @@ fpa::Base::Skeleton< _VDim >:: GetBifurcations( ) const { std::vector< TIndex > res; - auto mIt = this->BeginEdgesRows( ); + typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( ); for( ; mIt != this->EndEdgesRows( ); ++mIt ) { unsigned long count = mIt->second.size( ); diff --git a/lib/fpa/Base/SkeletonWriter.h b/lib/fpa/Base/SkeletonWriter.h index ab07bba..26c4972 100644 --- a/lib/fpa/Base/SkeletonWriter.h +++ b/lib/fpa/Base/SkeletonWriter.h @@ -26,6 +26,11 @@ namespace fpa typedef itk::SmartPointer< const Self > ConstPointer; typedef _TSkeleton TSkeleton; + typedef typename TSkeleton::TEdges TEdges; + typedef typename TSkeleton::TMatrix TMatrix; + typedef typename TSkeleton::TMatrixRow TMatrixRow; + typedef typename TSkeleton::TPath TPath; + typedef typename TSkeleton::TVertex TVertex; public: itkNewMacro( Self ); diff --git a/lib/fpa/Base/SkeletonWriter.hxx b/lib/fpa/Base/SkeletonWriter.hxx index e99d9ce..e060ccc 100644 --- a/lib/fpa/Base/SkeletonWriter.hxx +++ b/lib/fpa/Base/SkeletonWriter.hxx @@ -69,46 +69,48 @@ void fpa::Base::SkeletonWriter< _TSkeleton >:: GenerateData( ) { const TSkeleton* sk = this->GetInput( ); - auto mIt = sk->BeginEdgesRows( ); - auto rIt = mIt->second.begin( ); - auto eIt = rIt->second.begin( ); - auto path = *eIt; + typename TMatrix::const_iterator mIt = sk->BeginEdgesRows( ); + typename TMatrixRow::const_iterator rIt = mIt->second.begin( ); + typename TEdges::const_iterator eIt = rIt->second.begin( ); + const TPath* path = *eIt; // Write base information std::stringstream out1, out2; out1 << TSkeleton::Dimension << std::endl; - auto spa = path->GetSpacing( ); + typename TPath::TSpacing spa = path->GetSpacing( ); for( unsigned int d = 0; d < TSkeleton::Dimension; ++d ) out1 << spa[ d ] << " "; out1 << std::endl; - auto dir = path->GetDirection( ); + typename TPath::TDirection dir = path->GetDirection( ); for( unsigned int d = 0; d < TSkeleton::Dimension; ++d ) for( unsigned int e = 0; e < TSkeleton::Dimension; ++e ) out1 << dir[ d ][ e ] << " "; out1 << std::endl; - auto ori = path->GetOrigin( ); + typename TPath::TPoint ori = path->GetOrigin( ); for( unsigned int d = 0; d < TSkeleton::Dimension; ++d ) out1 << ori[ d ] << " "; out1 << std::endl; // End points - auto end_points = sk->GetEndPoints( ); + std::vector< TVertex > end_points = sk->GetEndPoints( ); out1 << end_points.size( ) << std::endl; - for( auto point : end_points ) + typename std::vector< TVertex >::const_iterator epIt = end_points.begin( ); + for( ; epIt != end_points.end( ); ++epIt ) { for( unsigned int d = 0; d < TSkeleton::Dimension; ++d ) - out1 << point[ d ] << " "; + out1 << ( *epIt )[ d ] << " "; out1 << std::endl; } // rof // Bifurcations - auto bifurcations = sk->GetBifurcations( ); + std::vector< TVertex > bifurcations = sk->GetBifurcations( ); out1 << bifurcations.size( ) << std::endl; - for( auto point : bifurcations ) + typename std::vector< TVertex >::const_iterator bIt = bifurcations.begin( ); + for( ; bIt != bifurcations.end( ); ++bIt ) { for( unsigned int d = 0; d < TSkeleton::Dimension; ++d ) - out1 << point[ d ] << " "; + out1 << ( *bIt )[ d ] << " "; out1 << std::endl; } // rof @@ -118,19 +120,19 @@ GenerateData( ) mIt = sk->BeginEdgesRows( ); for( ; mIt != sk->EndEdgesRows( ); ++mIt ) { - auto rIt = mIt->second.begin( ); + typename TMatrixRow::const_iterator rIt = mIt->second.begin( ); for( ; rIt != mIt->second.end( ); ++rIt ) { - auto eIt = rIt->second.begin( ); + typename TEdges::const_iterator eIt = rIt->second.begin( ); for( ; eIt != rIt->second.end( ); ++eIt ) { - auto path = *eIt; + TPath* path = *eIt; pathCount++; unsigned int size = path->GetSize( ); out2 << size << std::endl; for( unsigned int i = 0; i < path->GetSize( ); ++i ) { - auto v = path->GetVertex( i ); + TVertex v = path->GetVertex( i ); for( unsigned int d = 0; d < TSkeleton::Dimension; ++d ) out2 << v[ d ] << " "; diff --git a/lib/fpa/Image/MinimumSpanningTreeToImageFilter.hxx b/lib/fpa/Image/MinimumSpanningTreeToImageFilter.hxx index 1ef0039..f52e759 100644 --- a/lib/fpa/Image/MinimumSpanningTreeToImageFilter.hxx +++ b/lib/fpa/Image/MinimumSpanningTreeToImageFilter.hxx @@ -59,15 +59,17 @@ GenerateData( ) output->Allocate( ); output->FillBuffer( color ); - for( TPathData d: this->m_Paths ) + typename TPaths::const_iterator d = this->m_Paths.begin( ); + for( ; d != this->m_Paths.end( ); ++d ) { - typename TMST::TVertices path = mst->GetPath( d.Start, d.End ); - color[ 0 ] = d.Red; - color[ 1 ] = d.Green; - color[ 2 ] = d.Blue; + typename TMST::TVertices path = mst->GetPath( d->Start, d->End ); + color[ 0 ] = d->Red; + color[ 1 ] = d->Green; + color[ 2 ] = d->Blue; color[ 3 ] = std::numeric_limits< TOutputPixelValue >::max( ); - for( TIndex i: path ) - output->SetPixel( i, color ); + typename TMST::TVertices::const_iterator i = path.begin( ); + for( ; i != path.end( ); ++i ) + output->SetPixel( *i, color ); } // rof } diff --git a/lib/fpa/Image/SkeletonFilter.hxx b/lib/fpa/Image/SkeletonFilter.hxx index 7e38fa2..f1e315f 100644 --- a/lib/fpa/Image/SkeletonFilter.hxx +++ b/lib/fpa/Image/SkeletonFilter.hxx @@ -237,8 +237,10 @@ _Skeleton( const std::vector< TVertex >& end_points, _TAdjacencies& A ) tags->SetBufferedRegion( mst->GetBufferedRegion( ) ); tags->Allocate( ); tags->FillBuffer( 0 ); - for( TVertex it: end_points ) + typename std::vector< TVertex >::const_iterator eIt = end_points.begin( ); + for( ; eIt != end_points.end( ); ++eIt ) { + TVertex it = *eIt; TVertex p = mst->GetParent( it ); while( it != p ) { @@ -252,8 +254,10 @@ _Skeleton( const std::vector< TVertex >& end_points, _TAdjacencies& A ) } // rof // Build paths (branches) - for( TVertex it: end_points ) + eIt = end_points.begin( ); + for( ; eIt != end_points.end( ); ++eIt ) { + TVertex it = *eIt; TVertex p = mst->GetParent( it ); TVertex sIdx = it; typename _TPath::Pointer path = _TPath::New( );