#define __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__H__
#include <set>
-#include <fpa/Base/MatrixValuesContainer.h>
+#include <fpa/Base/VectorValuesContainer.h>
#include <itkProcessObject.h>
#include <itkPolyLineParametricPath.h>
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
- typedef T TMinimumSpanningTree;
- typedef typename T::TVertex TVertex;
- typedef typename T::TVertexCompare TVertexCompare;
- typedef itk::PolyLineParametricPath< TVertex::Dimension > TPath;
- typedef fpa::Base::MatrixValuesContainer< TVertex, typename TPath::Pointer, TVertexCompare > TBranches;
+ typedef T TMinimumSpanningTree;
+ typedef typename T::TVertex TVertex;
+ typedef typename T::TVertexCompare TVertexCompare;
+ typedef itk::PolyLineParametricPath< TVertex::Dimension > TPath;
+ typedef std::set< TVertex, TVertexCompare > TEndPoints;
- typedef std::set< TVertex, TVertexCompare > TEndPoints;
+ typedef
+ fpa::Base::VectorValuesContainer< typename TPath::Pointer >
+ TBranches;
public:
itkNewMacro( Self );
const T* GetInput( ) const;
void SetInput( const T* tree );
- TBranches* GetOutput( );
+ TPath* GetOutput( );
void ClearEndPoints( );
void AddEndPoint( const TVertex& v );
// -------------------------------------------------------------------------
template< class T >
typename fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
-TBranches* fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
+TPath* fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
GetOutput( )
{
return(
- itkDynamicCastInDebugMode< TBranches* >( this->GetPrimaryOutput( ) )
+ itkDynamicCastInDebugMode< TPath* >( this->GetPrimaryOutput( ) )
);
}
{
this->itk::ProcessObject::SetNumberOfRequiredInputs( 1 );
- typename TBranches::Pointer out = TBranches::New( );
+ typename TPath::Pointer out = TPath::New( );
this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
}
GenerateData( )
{
auto tree = this->GetInput( );
- auto branches = this->GetOutput( );
+ auto path = this->GetOutput( );
+
+ // TODO: this is just a temporary code
+ auto v0 = *( this->m_EndPoints.begin( ) );
+ auto v1 = *( this->m_EndPoints.rbegin( ) );
+ auto lst = tree->GetPath( v0, v1 );
+ path->Initialize( );
+ for( auto i = lst.begin( ); i != lst.end( ); ++i )
+ path->AddVertex( *i );
// Find bifurcations
- TEndPoints bifurcations, marks;
- auto e0It = this->m_EndPoints.begin( );
- for( ; e0It != this->m_EndPoints.end( ); ++e0It )
- {
- auto e1It = e0It;
- e1It++;
- for( ; e1It != this->m_EndPoints.end( ); ++e1It )
- {
- auto path = tree->GetPath( *e0It, *e1It );
- std::cout << "path" << std::endl;
- auto pIt = path.begin( );
- for( ; pIt != path.end( ); ++pIt )
- {
- if( marks.find( *pIt ) == marks.end( ) )
- marks.insert( *pIt );
- else
- bifurcations.insert( *pIt );
-
- } // rof
-
- } // rof
-
- } // rof
-
- // Construct branches
- std::cout << bifurcations.size( ) << std::endl;
+ /* TODO: this should be the final code
+ TEndPoints bifurcations, marks;
+ auto e0It = this->m_EndPoints.begin( );
+ for( ; e0It != this->m_EndPoints.end( ); ++e0It )
+ {
+ auto e1It = e0It;
+ e1It++;
+ for( ; e1It != this->m_EndPoints.end( ); ++e1It )
+ {
+ auto path = tree->GetPath( *e0It, *e1It );
+ std::cout << "path" << std::endl;
+ auto pIt = path.begin( );
+ for( ; pIt != path.end( ); ++pIt )
+ {
+ if( marks.find( *pIt ) == marks.end( ) )
+ marks.insert( *pIt );
+ else
+ bifurcations.insert( *pIt );
+
+ } // rof
+
+ } // rof
+
+ } // rof
+
+ // Construct branches
+ std::cout << bifurcations.size( ) << std::endl;
+ */
}
#endif // __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__
--- /dev/null
+#ifndef __FPA__BASE__VECTORVALUESCONTAINER__H__
+#define __FPA__BASE__VECTORVALUESCONTAINER__H__
+
+#include <vector>
+#include <itkSimpleDataObjectDecorator.h>
+#include <itkSmartPointer.h>
+
+namespace fpa
+{
+ namespace Base
+ {
+ /**
+ */
+ template< class T >
+ class VectorValuesContainer
+ : public itk::SimpleDataObjectDecorator< std::vector< T > >
+ {
+ public:
+ typedef std::vector< T > TDecorated;
+ typedef VectorValuesContainer Self;
+ typedef itk::SimpleDataObjectDecorator< TDecorated > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ typedef T TValue;
+ typedef typename TDecorated::iterator Iterator;
+ typedef typename TDecorated::const_iterator ConstIterator;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( VectorValuesContainer, itkSimpleDataObjectDecorator );
+
+ public:
+ void PushBack( const T& v )
+ { this->Get( ).push_back( v ); this->Modified( ); }
+ void PopBack( const T& v )
+ { this->Get( ).pop_back( ); this->Modified( ); }
+ Iterator Begin( )
+ { return( this->Get( ).begin( ) ); }
+ Iterator End( )
+ { return( this->Get( ).end( ) ); }
+ ConstIterator Begin( ) const
+ { return( this->Get( ).begin( ) ); }
+ ConstIterator End( ) const
+ { return( this->Get( ).end( ) ); }
+
+ protected:
+ VectorValuesContainer( )
+ : Superclass( )
+ { }
+ virtual ~VectorValuesContainer( )
+ { }
+
+ private:
+ // Purposely not implemented
+ VectorValuesContainer( const Self& other );
+ Self& operator=( const Self& other );
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __FPA__BASE__VECTORVALUESCONTAINER__H__
+
+// eof - $RCSfile$
#include <itkIndex.h>
#include <cpPlugins/Interface/PointList.h>
+#include <cpPlugins/Interface/PolyLineParametricPath.h>
#include <fpaPlugins/MinimumSpanningTree.h>
#include <fpa/Base/MinimumSpanningTree.h>
{
this->_AddInput( "MinimumSpanningTree" );
this->_AddInput( "EndPoints" );
- this->_AddOutput< cpPlugins::Interface::DataObject >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::PolyLineParametricPath >( "Output" );
}
// -------------------------------------------------------------------------
// Connect output and finish
auto out =
- this->GetOutputData< cpPlugins::Interface::DataObject >( "Output" );
+ this->GetOutputData< cpPlugins::Interface::PolyLineParametricPath >( "Output" );
out->SetITK( filter->GetOutput( ) );
return( "" );
}