#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
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 >
TVertices* GetEndPoints( );
TVertices* GetBifurcations( );
TVertices* GetCollisions( );
+ TBranches* GetBranches( );
virtual void Update( ) ITK_OVERRIDE
{
#include <cmath>
#include <map>
-#include <vector>
// -------------------------------------------------------------------------
template< class _TMST >
);
}
+// -------------------------------------------------------------------------
+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 >::
: 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( ) );
}
// -------------------------------------------------------------------------
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( );
// 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
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++;
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;