]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 12 Apr 2016 00:24:47 +0000 (19:24 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 12 Apr 2016 00:24:47 +0000 (19:24 -0500)
lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h
lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx
lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h
lib/fpa_Instances/Backtracking.i

index 4fc346070766ae6cd0330ff86b658defdfc46930..598e15d20b1d717593abdd83cadbe11b8d5d5dd8 100644 (file)
@@ -1,8 +1,10 @@
 #ifndef __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__
 #define __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__
 
+#include <utility>
 #include <vector>
 #include <itkProcessObject.h>
+#include <itkSimpleDataObjectDecorator.h>
 #include <cpExtensions/DataStructures/ImageIndexesContainer.h>
 
 namespace fpa
@@ -22,7 +24,9 @@ namespace fpa
       typedef itk::SmartPointer< const Self >                        ConstPointer;
 
       typedef _TMST  TMinimumSpanningTree;
-      typedef typename _TMST::TVertex TVertex;
+      typedef typename _TMST::TVertex       TVertex;
+      typedef std::pair< TVertex, TVertex > TBranch;
+      typedef itk::SimpleDataObjectDecorator< std::vector< TBranch > > TBranches;
 
       typedef
       cpExtensions::DataStructures::ImageIndexesContainer< TVertex::Dimension >
@@ -41,6 +45,7 @@ namespace fpa
       TVertices* GetEndPoints( );
       TVertices* GetBifurcations( );
       TVertices* GetCollisions( );
+      TBranches* GetBranches( );
 
       virtual void Update( ) ITK_OVERRIDE
         {
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;
index 2c067adddf45b4b5fc682804e8b5c6d1fc5f95cb..2b65112fbcae6a02f13bb0c444b1adc630a14b3a 100644 (file)
@@ -26,6 +26,8 @@ namespace fpa
       typedef
       cpExtensions::DataStructures::PolyLineParametricPath< TVertex::Dimension >
       TPath;
+      typedef std::pair< TVertex, TVertex >    _TBranch;
+      typedef std::vector< _TBranch >          _TBranches;
 
     public:
       itkNewMacro( Self );
index aa162ee6a9e9a035821c2a0cace51d478a732315..dd5916a28246469d2ad9f695b9e1c0e4d02b5416 100644 (file)
@@ -6,10 +6,14 @@ d #ebc=ExtractEndPointsAndBifurcationsFromMinimumSpanningTree
 
 f fpa_Instances/Instances.h
 
+i utility
+i vector
 t fpa/Base/#path.h
 t fpa/Base/#ebc.h
 t fpa/Image/#ebc.h
+t itkSimpleDataObjectDecorator.h
 
+c itk::SimpleDataObjectDecorator< std::vector< std::pair< itk::Index< #dims >, itk::Index< #dims > > > >
 c fpa::Base::#path< #mst< #dims > >
 c fpa::Base::#ebc< #mst< #dims > >
 c fpa::Image::#ebc< itk::Image< #floats, #dims >, #mst< #dims > >