]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx
index af63bb0614a2b2ccdd6bf744475bb89f069fd1d9..3e8b6e591dc33fb916a1e22f849ddbeeb8af2bbf 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <cmath>
 #include <map>
-#include <vector>
 
 // -------------------------------------------------------------------------
 template< class _TMST >
@@ -66,6 +65,19 @@ GetCollisions( )
     );
 }
 
+// -------------------------------------------------------------------------
+template< class _TMST >
+typename
+fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >::
+TBranches*
+fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >::
+GetBranches( )
+{
+  return(
+    dynamic_cast< TBranches* >( this->itk::ProcessObject::GetOutput( 3 ) )
+    );
+}
+
 // -------------------------------------------------------------------------
 template< class _TMST >
 fpa::Base::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TMST >::
@@ -73,13 +85,15 @@ ExtractEndPointsAndBifurcationsFromMinimumSpanningTree( )
   : Superclass( )
 {
   this->SetNumberOfRequiredInputs( 1 );
-  this->SetNumberOfRequiredOutputs( 3 );
+  this->SetNumberOfRequiredOutputs( 4 );
   typename TVertices::Pointer ep = TVertices::New( );
   typename TVertices::Pointer bf = TVertices::New( );
   typename TVertices::Pointer co = TVertices::New( );
+  typename TBranches::Pointer br = TBranches::New( );
   this->itk::ProcessObject::SetNthOutput( 0, ep.GetPointer( ) );
   this->itk::ProcessObject::SetNthOutput( 1, bf.GetPointer( ) );
   this->itk::ProcessObject::SetNthOutput( 2, co.GetPointer( ) );
+  this->itk::ProcessObject::SetNthOutput( 3, br.GetPointer( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -105,10 +119,11 @@ GenerateData( )
   auto endpoints = this->GetEndPoints( );
   auto bifurcations = this->GetBifurcations( );
   auto collisions = this->GetCollisions( );
-  _TBranches branches;
+  auto branches = this->GetBranches( );
   endpoints->Get( ).clear( );
   bifurcations->Get( ).clear( );
   collisions->Get( ).clear( );
+  branches->Get( ).clear( );
 
   // 1. Get priority queue
   auto& q = mst->GetNodeQueue( );
@@ -129,7 +144,7 @@ GenerateData( )
 
     // 2.3. Prepare new branch data and prepare new end-point
     label++;
-    branches.push_back( _TBranch( vertex, vertex ) );
+    branches->Get( ).push_back( _TBranch( vertex, vertex ) );
     endpoints->Get( ).push_back( vertex );
 
     // 2.4. Backtracking
@@ -145,10 +160,10 @@ GenerateData( )
         bifurcations->Get( ).push_back( *pIt );
 
         // Reorder labels
-        auto coll_branch = branches[ mark ];
-        branches[ mark  ] = _TBranch( coll_branch.first, *pIt );
-        branches[ label - 1 ] = _TBranch( qIt->second, *pIt );
-        branches.push_back( _TBranch( *pIt, coll_branch.second ) );
+        auto coll_branch = branches->Get( )[ mark ];
+        branches->Get( )[ mark  ] = _TBranch( coll_branch.first, *pIt );
+        branches->Get( )[ label - 1 ] = _TBranch( qIt->second, *pIt );
+        branches->Get( ).push_back( _TBranch( *pIt, coll_branch.second ) );
 
         // Mark skeleton (b,coll_branch_second) with the new label
         label++;
@@ -180,7 +195,7 @@ GenerateData( )
             double r = this->_Radius( *pIt );
             this->_MarkSkeleton( *pIt, label );
             this->_MarkSphere( *pIt, r, label );
-            branches[ label - 1 ].second = *pIt;
+            branches->Get( )[ label - 1 ].second = *pIt;
 
             // 2.4.4. Is this a seed? -> add it to endpoints
             auto sIt = pIt;