]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 10 Oct 2016 20:54:52 +0000 (15:54 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 10 Oct 2016 20:54:52 +0000 (15:54 -0500)
lib/fpa/Base/MinimumSpanningTree.hxx

index c85c28315fce60121bb44d3e2dbc836a51990327..e8ed6a2c286e94b5701e022531a9e418a105cec1 100644 (file)
@@ -142,9 +142,9 @@ GetPath(
     unsigned long N = this->m_Seeds.size( );
     for( unsigned long i = 0; i < N; ++i )
     {
-      if( this->m_Seeds[ i ] == pa->GetVertex( 0 ) )
+      if( this->m_Seeds[ i ] == pa->GetVertex( pa->GetSize( ) - 1 ) )
         ia = i;
-      if( this->m_Seeds[ i ] == pb->GetVertex( 0 ) )
+      if( this->m_Seeds[ i ] == pb->GetVertex( pb->GetSize( ) - 1 ) )
         ib = i;
 
     } // rof
@@ -153,49 +153,49 @@ GetPath(
     if( ia != ib )
     {
       // Compute front path
-      /* TODO
-         std::vector< long > fpath;
-         fpath.push_back( ia );
-         while( ia != ib )
-         {
-         ia = this->m_FrontPaths[ ia ][ ib ];
-         fpath.push_back( ia );
-
-         } // elihw
-
-         // Continue only if both fronts are connected
-         unsigned int N = fpath.size( );
-         if( N > 0 )
-         {
-         // First path: from start vertex to first collision
-         this->GetPath(
-         path, a,
-         this->m_Collisions[ fpath[ 0 ] ][ fpath[ 1 ] ].first
-         );
-
-         // Intermediary paths
-         for( unsigned int i = 1; i < N - 1; ++i )
-         {
-         TPathTVertices ipath =
-         this->GetPath(
-         this->m_Collisions[ fpath[ i ] ][ fpath[ i - 1 ] ].first,
-         this->m_Collisions[ fpath[ i ] ][ fpath[ i + 1 ] ].first
-         );
-         path.insert( path.end( ), ipath.begin( ), ipath.end( ) );
-
-         } // rof
-
-         // Final path: from last collision to end point
-         TVertices lpath =
-         this->GetPath(
-         this->m_Collisions[ fpath[ N - 1 ] ][ fpath[ N - 2 ] ].first, b
-         );
-         path.insert( path.end( ), lpath.begin( ), lpath.end( ) );
-
-         } // fi
-
-         } // fi
-      */
+      std::vector< long > fpath;
+      fpath.push_back( ia );
+      while( ia != ib )
+      {
+        ia = this->m_FrontPaths[ ia ][ ib ];
+        fpath.push_back( ia );
+
+      } // elihw
+
+      // Continue only if both fronts are connected
+      unsigned int N = fpath.size( );
+      if( N > 0 )
+      {
+        // First path: from start vertex to first collision
+        this->GetPath(
+          path, a,
+          this->m_Collisions[ fpath[ 0 ] ][ fpath[ 1 ] ].first
+          );
+
+        // Intermediary paths
+        for( unsigned int i = 1; i < N - 1; ++i )
+        {
+          typename _TPath::Pointer ipath;
+          this->GetPath(
+            ipath,
+            this->m_Collisions[ fpath[ i ] ][ fpath[ i - 1 ] ].first,
+            this->m_Collisions[ fpath[ i ] ][ fpath[ i + 1 ] ].first
+            );
+          for( long id = 0; id < ipath->GetSize( ); ++id )
+            path->AddVertex( ipath->GetVertex( id ) );
+
+        } // rof
+
+        // Final path: from last collision to end point
+        typename _TPath::Pointer lpath;
+        this->GetPath(
+          lpath,
+          this->m_Collisions[ fpath[ N - 1 ] ][ fpath[ N - 2 ] ].first, b
+          );
+        for( long id = 0; id < lpath->GetSize( ); ++id )
+          path->AddVertex( lpath->GetVertex( id ) );
+
+      } // fi
     }
     else
     {