From: Leonardo Florez-Valencia Date: Tue, 12 Apr 2016 00:24:47 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=4dc9dddd928daeb91104d5c18fa73a02975cedeb;p=FrontAlgorithms.git ... --- diff --git a/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h b/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h index 4fc3460..598e15d 100644 --- a/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h +++ b/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.h @@ -1,8 +1,10 @@ #ifndef __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ #define __FPA__BASE__EXTRACTENDPOINTSANDBIFURCATIONSFROMMINIMUMSPANNINGTREE__H__ +#include #include #include +#include #include 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 { diff --git a/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx b/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx index af63bb0..3e8b6e5 100644 --- a/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx +++ b/lib/fpa/Base/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.hxx @@ -3,7 +3,6 @@ #include #include -#include // ------------------------------------------------------------------------- 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; diff --git a/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h b/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h index 2c067ad..2b65112 100644 --- a/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h +++ b/lib/fpa/Base/ExtractPathFromMinimumSpanningTree.h @@ -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 ); diff --git a/lib/fpa_Instances/Backtracking.i b/lib/fpa_Instances/Backtracking.i index aa162ee..dd5916a 100644 --- a/lib/fpa_Instances/Backtracking.i +++ b/lib/fpa_Instances/Backtracking.i @@ -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 > >