itkGetConstMacro( FinalTree, TTree );
itkGetConstMacro( EndPoints, TVertices );
+ itkGetConstMacro( BifurcationPoints, TVertices );
protected:
DijkstraWithSphereBacktracking( );
protected:
_TCandidates m_Candidates;
TTree m_FinalTree;
+ TVertices m_BifurcationPoints;
TVertices m_EndPoints;
};
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 ];
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( ) )
// 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
}
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 );
}