]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx
index afb5252f43c693f5e08644a9213dc3634ad38369..82debb4f0c139a90f8e368a9342d2387e92c20bf 100644 (file)
@@ -120,7 +120,7 @@ GenerateData( )
     auto vertex = qIt->second;
 
     // 2.1. Check if the vertex has already been visited
-    if( this->_Mark( vertex ) > 0 )
+    if( this->_Mark( vertex ) > 0 || this->_SkeletonMark( vertex ) > 0 )
       continue;
 
     // 2.2. Get path from front seed
@@ -144,8 +144,8 @@ GenerateData( )
         bifurcations->Get( ).push_back( *pIt );
 
         // Reorder labels
-        auto coll_branch = this->m_Branches[ mark ];
-        this->m_Branches[ mark  ] = _TBranch( coll_branch.first, *pIt );
+        auto coll_branch = this->m_Branches[ mark - 1 ];
+        this->m_Branches[ mark - 1 ] = _TBranch( coll_branch.first, *pIt );
         this->m_Branches[ label - 1 ] = _TBranch( qIt->second, *pIt );
         this->m_Branches.push_back( _TBranch( *pIt, coll_branch.second ) );
 
@@ -157,6 +157,8 @@ GenerateData( )
           pIt++;
 
         } // elihw
+        if( pIt != path.end( ) )
+          this->_MarkSkeleton( *pIt, label );
 
         // Force inner loop termination
         pIt = path.end( );
@@ -198,6 +200,18 @@ GenerateData( )
 
   } // rof
 
+  // Remove illegal branches
+  auto dIt = this->m_Branches.begin( );
+  while( dIt != this->m_Branches.end( ) )
+  {
+    if( dIt->first == dIt->second )
+      dIt = this->m_Branches.erase( dIt );
+    else
+      dIt++;
+    
+  } // fi
+
+  // Finish
   endpoints->SetReferenceImage( mst );
   bifurcations->SetReferenceImage( mst );
   collisions->SetReferenceImage( mst );