+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
#ifndef __fpa__Base__Dijkstra__hxx__
#define __fpa__Base__Dijkstra__hxx__
-#include <algorithm>
-#include <limits>
-
// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-_TMST* fpa::Base::Dijkstra< _TSuperclass, _TMST >::
+template< class _TAlgorithm, class _TMST >
+typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
+TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
GetMinimumSpanningTree( )
{
- return(
- dynamic_cast< _TMST* >(
- this->itk::ProcessObject::GetOutput( this->m_MSTIndex )
- )
+ dynamic_cast< TMST* >(
+ this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
);
}
// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-const _TMST* fpa::Base::Dijkstra< _TSuperclass, _TMST >::
+template< class _TAlgorithm, class _TMST >
+const typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
+TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
GetMinimumSpanningTree( ) const
{
- return(
- dynamic_cast< const _TMST* >(
- this->itk::ProcessObject::GetOutput( this->m_MSTIndex )
- )
+ dynamic_cast< const TMST* >(
+ this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
);
}
// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-fpa::Base::Dijkstra< _TSuperclass, _TMST >::
+template< class _TAlgorithm, class _TMST >
+fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
Dijkstra( )
: Superclass( )
{
- this->m_InitResult = TOutput( 0 );
- this->m_MSTIndex = this->GetNumberOfRequiredOutputs( );
- this->SetNumberOfRequiredOutputs( this->m_MSTIndex + 1 );
- this->itk::ProcessObject::SetNthOutput( this->m_MSTIndex, _TMST::New( ) );
+ this->m_MSTIdx = this->GetNumberOfRequiredOutputs( );
+ this->itk::ProcessObject::SetNumberOfRequiredOutputs( this->m_MSTIdx + 1 );
+ this->SetNthOutput( this->m_MSTIdx, TMST::New( ) );
}
// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-fpa::Base::Dijkstra< _TSuperclass, _TMST >::
+template< class _TAlgorithm, class _TMST >
+fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
~Dijkstra( )
{
}
// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
+template< class _TAlgorithm, class _TMST >
+void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
_AfterGenerateData( )
{
+ typedef typename Superclass::TSeedsInterface::TSeeds::iterator _TIt;
+
this->Superclass::_AfterGenerateData( );
- auto mst = this->GetMinimumSpanningTree( );
+ TMST* mst = this->GetMinimumSpanningTree( );
mst->ClearSeeds( );
- for( auto s = this->m_Seeds.begin( ); s != this->m_Seeds.end( ); ++s )
- mst->AddSeed( s->Vertex );
mst->SetCollisions( this->m_Collisions );
+ for( _TIt sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
+ mst->AddSeed( sIt->Vertex );
}
// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_UpdateResult( const _TQueueNode& n )
+template< class _TAlgorithm, class _TMST >
+void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
+_UpdateOutputValue( const TNode& n )
{
- this->Superclass::_UpdateResult( n );
+ this->Superclass::_UpdateOutputValue( n );
this->GetMinimumSpanningTree( )->SetParent( n.Vertex, n.Parent );
}
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-bool fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
-{
- v.Result = this->m_CostFunction->Evaluate( p.Vertex, v.Vertex );
- if( this->m_CostConversionFunction.IsNotNull( ) )
- v.Result = this->m_CostConversionFunction->Evaluate( v.Result );
- if( v.Result >= TOutput( 0 ) )
- {
- v.Result += p.Result;
- return( true );
- }
- else
- {
- v.Result = this->m_InitResult;
- return( false );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-unsigned long fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_QueueSize( ) const
-{
- return( this->m_Queue.size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_QueueClear( )
-{
- this->m_Queue.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_QueuePush( const _TQueueNode& node )
-{
- static _TQueueNodeCompare cmp;
- this->m_Queue.push_back( node );
- std::push_heap( this->m_Queue.begin( ), this->m_Queue.end( ), cmp );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-typename fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_TQueueNode fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_QueuePop( )
-{
- static _TQueueNodeCompare cmp;
- std::pop_heap( this->m_Queue.begin( ), this->m_Queue.end( ), cmp );
- _TQueueNode f = this->m_Queue.back( );
- this->m_Queue.pop_back( );
- return( f );
-}
-
#endif // __fpa__Base__Dijkstra__hxx__
// eof - $RCSfile$