From: Leonardo Florez-Valencia Date: Tue, 16 Feb 2016 20:38:04 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0de7eb72cb770be02acc8ad9d4edfcd5085efab6;p=FrontAlgorithms.git ... --- diff --git a/lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.h b/lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.h index 183a7fa..cacc529 100644 --- a/lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.h +++ b/lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.h @@ -2,7 +2,7 @@ #define __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__H__ #include -#include +#include #include #include @@ -22,13 +22,15 @@ namespace fpa 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 ); @@ -41,7 +43,7 @@ namespace fpa const T* GetInput( ) const; void SetInput( const T* tree ); - TBranches* GetOutput( ); + TPath* GetOutput( ); void ClearEndPoints( ); void AddEndPoint( const TVertex& v ); diff --git a/lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.hxx b/lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.hxx index 9dd96ed..5a7433f 100644 --- a/lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.hxx +++ b/lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.hxx @@ -22,11 +22,11 @@ SetInput( const T* tree ) // ------------------------------------------------------------------------- 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( ) ) ); } @@ -76,7 +76,7 @@ ExtractBranchesFromMinimumSpanningTree( ) { 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( ) ); } @@ -94,35 +94,45 @@ void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >:: 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__ diff --git a/lib/fpa/Base/VectorValuesContainer.h b/lib/fpa/Base/VectorValuesContainer.h new file mode 100644 index 0000000..9358c33 --- /dev/null +++ b/lib/fpa/Base/VectorValuesContainer.h @@ -0,0 +1,66 @@ +#ifndef __FPA__BASE__VECTORVALUESCONTAINER__H__ +#define __FPA__BASE__VECTORVALUESCONTAINER__H__ + +#include +#include +#include + +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$ diff --git a/lib/fpaPlugins/ExtractBranchesFromMinimumSpanningTree.cxx b/lib/fpaPlugins/ExtractBranchesFromMinimumSpanningTree.cxx index dc07993..9c5e6af 100644 --- a/lib/fpaPlugins/ExtractBranchesFromMinimumSpanningTree.cxx +++ b/lib/fpaPlugins/ExtractBranchesFromMinimumSpanningTree.cxx @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -15,7 +16,7 @@ ExtractBranchesFromMinimumSpanningTree( ) { this->_AddInput( "MinimumSpanningTree" ); this->_AddInput( "EndPoints" ); - this->_AddOutput< cpPlugins::Interface::DataObject >( "Output" ); + this->_AddOutput< cpPlugins::Interface::PolyLineParametricPath >( "Output" ); } // ------------------------------------------------------------------------- @@ -69,7 +70,7 @@ _GD0( ) // Connect output and finish auto out = - this->GetOutputData< cpPlugins::Interface::DataObject >( "Output" ); + this->GetOutputData< cpPlugins::Interface::PolyLineParametricPath >( "Output" ); out->SetITK( filter->GetOutput( ) ); return( "" ); }