]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/MinimumSpanningTree.hxx
Almost there...
[FrontAlgorithms.git] / lib / fpa / Base / MinimumSpanningTree.hxx
index 1140e4022f717616c2aadee581d2898a1488962d..d932247c7bc2dcbc739e5902848da20879509bb5 100644 (file)
@@ -56,7 +56,6 @@ SetCollisions( const TCollisions& collisions )
     } // rof
 
   } // rof
-
   this->Modified( );
 }
 
@@ -65,8 +64,14 @@ template< class V, class C, class B >
 void fpa::Base::MinimumSpanningTree< V, C, B >::
 GetPath( std::vector< V >& path, const V& a, const V& b ) const
 {
-  long fa = this->_FrontId( a );
-  long fb = this->_FrontId( b );
+  typename TDecorated::const_iterator aIt = this->Get( ).find( a );
+  typename TDecorated::const_iterator bIt = this->Get( ).find( b );
+
+  if( aIt == this->Get( ).end( ) || bIt == this->Get( ).end( ) )
+    return;
+  
+  short fa = aIt->second.second;
+  short fb = bIt->second.second;
 
   if( fa == fb )
   {
@@ -164,14 +169,20 @@ template< class V, class C, class B >
 void fpa::Base::MinimumSpanningTree< V, C, B >::
 _Path( std::vector< V >& path, const V& a ) const
 {
-  V it = a;
-  do
+  typename TDecorated::const_iterator dIt = this->Get( ).find( a );
+  if( dIt != this->Get( ).end( ) )
   {
-    path.push_back( it );
-    it = this->_Parent( it );
+    do
+    {
+      path.push_back( dIt->first );
+      dIt = this->Get( ).find( dIt->second.first );
 
-  } while( it != this->_Parent( it ) );
-  path.push_back( it );
+    } while( dIt->first != dIt->second.first && dIt != this->Get( ).end( ) );
+
+    if( dIt != this->Get( ).end( ) )
+      path.push_back( dIt->first );
+
+  } // fi
 }
 
 #endif // __FPA__BASE__MINIMUMSPANNINGTREE__HXX__