]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 15 Feb 2016 23:16:25 +0000 (18:16 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 15 Feb 2016 23:16:25 +0000 (18:16 -0500)
lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.h
lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.hxx

index 06c304607d4317ce7d8eb63c6104878631640fe0..985d339f5b851a7ca2f4592d774a16f23a70232f 100644 (file)
@@ -24,8 +24,9 @@ namespace fpa
       typedef T                          TMinimumSpanningTree;
       typedef typename T::TVertex        TVertex;
       typedef typename T::TVertexCompare TVertexCompare;
+      typedef std::vector< TVertex >     TPath;
       typedef
-      fpa::Base::MatrixValuesContainer< TVertex, bool, TVertexCompare >
+      fpa::Base::MatrixValuesContainer< TVertex, TPath, TVertexCompare >
       TBranches;
 
       typedef std::set< TVertex, TVertexCompare > TEndPoints;
index 4af465fb06773b34eb2f52fe6c55637e1579b6af..f8793c9c5936f3a2c0259b7b9585a71ab6537e8e 100644 (file)
@@ -46,8 +46,6 @@ AddEndPoint( const TVertex& v )
 {
   if( this->m_EndPoints.find( v ) == this->m_EndPoints.end( ) )
   {
-    std::cout << "Add " << v << std::endl;
-
     this->m_EndPoints.insert( v );
     this->Modified( );
 
@@ -78,8 +76,7 @@ ExtractBranchesFromMinimumSpanningTree( )
 {
   this->itk::ProcessObject::SetNumberOfRequiredInputs( 1 );
 
-  typename TBranches::Pointer out =
-    static_cast< TBranches* >( this->MakeOutput( 0 ).GetPointer( ) );
+  typename TBranches::Pointer out = TBranches::New( );
   this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
   this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
 }
@@ -99,35 +96,38 @@ GenerateData( )
   const T* tree = this->GetInput( );
   TBranches* branches = this->GetOutput( );
 
+  // Find bifurcations
+  TEndPoints all_points, marks;
   auto e0It = this->m_EndPoints.begin( );
   for( ; e0It != this->m_EndPoints.end( ); ++e0It )
   {
+    all_points.insert( *e0It );
     auto e1It = e0It;
     e1It++;
     for( ; e1It != this->m_EndPoints.end( ); ++e1It )
     {
-      std::cout << *e0It << " " << *e1It << std::endl;
-      // std::vector< TVertex > path = tree->GetPath( *e0It, *e1It );
+      all_points.insert( *e0It );
+      auto path = tree->GetPath( *e0It, *e1It );
+      auto pIt = path.begin( );
+      for( ; pIt != path.end( ); ++pIt )
+      {
+        if( *pIt == *e0It || *pIt == *e1It )
+          continue;
+
+        if( marks.find( *pIt ) == marks.end( ) )
+          marks.insert( *pIt );
+        else
+          all_points.insert( *pIt );
+        
+      } // rof
 
     } // rof
 
   } // rof
-}
-
-/*
-  private:
-  // Purposely not implemented
-  ExtractBranchesFromMinimumSpanningTree( const Self& other );
-  Self& operator=( const Self& other );
 
-  protected:
-  TEndPoints m_EndPoints;
-  };
-
-  } // ecapseman
-
-  } // ecapseman
-*/
+  // Construct branches
+  std::cout << all_points.size( ) << std::endl;
+}
 
 #endif // __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__