]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/Dijkstra.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / Dijkstra.hxx
index 149363d64128543dd1bfa29de9edd04cf2b8cac3..b7c10f478a2d6eee59fa04fbc08b0501ca23b4e6 100644 (file)
@@ -108,15 +108,16 @@ void fpa::Base::Dijkstra< _TFilter, _TMarksInterface, _TSeedsInterface, _TMST >:
 GenerateData( )
 {
   // Init objects
-  this->_ConfigureOutputs( TOutputValue( 0 ) );
+  this->_ConfigureOutputs( std::numeric_limits< TOutputValue >::max( ) );
   this->_InitMarks( this->GetNumberOfSeeds( ) );
   TMST* mst = this->GetMinimumSpanningTree( );
 
   // 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 )
@@ -135,8 +136,11 @@ GenerateData( )
 
     // Add neighborhood
     TVertices neighbors = this->_GetNeighbors( node.Vertex );
-    for( TVertex neigh: neighbors )
+    typename TVertices::const_iterator neighIt = neighbors.begin( );
+    bool coll = false;
+    while( neighIt != neighbors.end( ) && !coll )
     {
+      TVertex neigh = *neighIt;
       if( this->_IsMarked( neigh ) )
       {
         // Invoke stop at collisions
@@ -146,7 +150,11 @@ GenerateData( )
           this->GetNumberOfSeeds( ) > 1 &&
           nColl == 1
           )
+        {
           q.clear( );
+          coll = true;
+
+        } // fi
       }
       else
       {
@@ -168,8 +176,9 @@ GenerateData( )
         } // fi
 
       } // fi
+      ++neighIt;
 
-    } // rof
+    } // elihw
 
   } // elihw
   this->_FreeMarks( );
@@ -177,8 +186,8 @@ GenerateData( )
   // Complete data into minimum spanning tree
   mst->ClearSeeds( );
   mst->SetCollisions( this->m_Collisions );
-  for( TVertex seed: this->GetSeeds( ) )
-    mst->AddSeed( seed );
+  for( sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
+    mst->AddSeed( *sIt );
 }
 
 #endif // __fpa__Base__Dijkstra__hxx__