]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/Dijkstra.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / Dijkstra.hxx
index df9c75e5d07cbc994b5a4db3966bd879eabdfcc4..85380aa8a127de82828aadaf25c3111a459b4aeb 100644 (file)
@@ -1,92 +1,83 @@
+// =========================================================================
+// @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( )
 {
   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 );
-}
 
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_UpdateResult( const _TQueueNode& n )
-{
-  this->Superclass::_UpdateResult( n );
-  this->GetMinimumSpanningTree( )->SetParent( n.Vertex, n.Parent );
+  TSeeds seeds = this->GetSeeds( );
+  typename TSeeds::const_iterator sIt = seeds.begin( );
+  for( ; sIt != seeds.end( ); ++sIt )
+  {
+    if( sIt->IsUnified )
+      mst->AddSeed( sIt->Vertex );
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-bool fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
+template< class _TAlgorithm, class _TMST >
+void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
+_UpdateOutputValue( TNode& n )
 {
-  v.Result = this->_GetInputValue( p.Vertex, v.Vertex );
-  if( v.Result >= TOutput( 0 ) )
-  {
-    v.Result += p.Result;
-    return( true );
-  }
-  else
-  {
-    v.Result = this->m_InitResult;
-    return( false );
-
-  } // fi
+  this->Superclass::_UpdateOutputValue( n );
+  this->GetMinimumSpanningTree( )->SetParent( n.Vertex, n.Parent );
 }
 
 #endif // __fpa__Base__Dijkstra__hxx__