From: Leonardo Florez-Valencia Date: Tue, 17 Mar 2015 20:08:13 +0000 (-0500) Subject: Add X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=bf76a5f0c5668f993ff32b4584ae82dd63db5669;p=FrontAlgorithms.git Add --- diff --git a/lib/fpa/Image/DijkstraWithSphereBacktracking.h b/lib/fpa/Image/DijkstraWithSphereBacktracking.h index 0cc0c4f..070a01a 100644 --- a/lib/fpa/Image/DijkstraWithSphereBacktracking.h +++ b/lib/fpa/Image/DijkstraWithSphereBacktracking.h @@ -50,6 +50,7 @@ namespace fpa itkGetConstMacro( FinalTree, TTree ); itkGetConstMacro( EndPoints, TVertices ); + itkGetConstMacro( BifurcationPoints, TVertices ); protected: DijkstraWithSphereBacktracking( ); @@ -69,6 +70,7 @@ namespace fpa protected: _TCandidates m_Candidates; TTree m_FinalTree; + TVertices m_BifurcationPoints; TVertices m_EndPoints; }; diff --git a/lib/fpa/Image/DijkstraWithSphereBacktracking.hxx b/lib/fpa/Image/DijkstraWithSphereBacktracking.hxx index d71cef8..95f8dcb 100644 --- a/lib/fpa/Image/DijkstraWithSphereBacktracking.hxx +++ b/lib/fpa/Image/DijkstraWithSphereBacktracking.hxx @@ -73,11 +73,12 @@ _AfterMainLoop( ) this->Superclass::_AfterMainLoop( ); this->m_FinalTree.clear( ); this->m_EndPoints.clear( ); + this->m_BifurcationPoints.clear( ); if( this->m_Candidates.size( ) == 0 ) return; this->InvokeEvent( TEndEvent( ) ); - // Get input values + // Get some input values const I* input = this->GetInput( ); typename I::SpacingType spac = input->GetSpacing( ); double max_spac = spac[ 0 ]; @@ -133,6 +134,7 @@ _AfterMainLoop( ) this->m_EndPoints.push_back( max_vertex ); // Construct path (at least the part that hasn't been iterated) + bool terminate = false; do { if( this->m_FinalTree.find( max_vertex ) == this->m_FinalTree.end( ) ) @@ -148,13 +150,24 @@ _AfterMainLoop( ) // Next vertex in current path this->InvokeEvent( TBacktrackingEvent( max_vertex, backId ) ); this->m_FinalTree[ max_vertex ] = this->_Parent( max_vertex ); + } + else + { + // A bifurcation point has been reached! + this->m_BifurcationPoints.push_back( max_vertex ); + terminate = true; } // fi max_vertex = this->_Parent( max_vertex ); - } while( max_vertex != this->_Parent( max_vertex ) ); - this->m_FinalTree[ max_vertex ] = max_vertex; - this->InvokeEvent( TEndBacktrackingEvent( backId ) ); + } while( max_vertex != this->_Parent( max_vertex ) && !terminate ); + + if( !terminate ) + { + this->m_FinalTree[ max_vertex ] = max_vertex; + this->InvokeEvent( TEndBacktrackingEvent( backId ) ); + + } // fi } // rof } @@ -167,7 +180,8 @@ _UpdateNeigh( _TNode& nn, const _TNode& n ) C nc = this->_Cost( nn.Vertex, n.Vertex ); if( TCost( 0 ) < nc ) { - nn.Cost = n.Cost + ( TCost( 1 ) / nc ); + nc += TCost( 1 ); + nn.Cost = n.Cost + ( TCost( 1 ) / std::pow( nc, 4 ) ); nn.Result = nn.Cost; return( true ); }