From 0f167b3c36824ce1cd126e287aeeade116f60ccb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 13 Jul 2017 23:39:15 -0500 Subject: [PATCH] ... --- lib/fpa/Base/Dijkstra.hxx | 2 +- lib/fpa/Base/MinimumSpanningTree.hxx | 1 + lib/fpa/Base/SeedsInterface.h | 1 + lib/fpa/Base/SeedsInterface.hxx | 11 ++++ lib/fpa/Image/Algorithm.hxx | 2 +- lib/fpa/Image/MinimumSpanningTree.h | 23 +++----- lib/fpa/Image/MinimumSpanningTree.hxx | 75 +++++++++++++++++++++++++++ 7 files changed, 97 insertions(+), 18 deletions(-) create mode 100644 lib/fpa/Image/MinimumSpanningTree.hxx diff --git a/lib/fpa/Base/Dijkstra.hxx b/lib/fpa/Base/Dijkstra.hxx index 85380aa..9de7912 100644 --- a/lib/fpa/Base/Dijkstra.hxx +++ b/lib/fpa/Base/Dijkstra.hxx @@ -61,7 +61,7 @@ _AfterGenerateData( ) mst->ClearSeeds( ); mst->SetCollisions( this->m_Collisions ); - TSeeds seeds = this->GetSeeds( ); + const TSeeds& seeds = this->GetSeeds( ); typename TSeeds::const_iterator sIt = seeds.begin( ); for( ; sIt != seeds.end( ); ++sIt ) { diff --git a/lib/fpa/Base/MinimumSpanningTree.hxx b/lib/fpa/Base/MinimumSpanningTree.hxx index 6004aaa..00e4159 100644 --- a/lib/fpa/Base/MinimumSpanningTree.hxx +++ b/lib/fpa/Base/MinimumSpanningTree.hxx @@ -124,6 +124,7 @@ typename fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >:: TVertices fpa::Base::MinimumSpanningTree< _TVertex, _Superclass >:: GetPath( const _TVertex& a, const _TVertex& b ) const { +#error no hace bien el backtracking! static const unsigned long _inf = std::numeric_limits< unsigned long >::max( ); diff --git a/lib/fpa/Base/SeedsInterface.h b/lib/fpa/Base/SeedsInterface.h index 41debde..61860cc 100644 --- a/lib/fpa/Base/SeedsInterface.h +++ b/lib/fpa/Base/SeedsInterface.h @@ -71,6 +71,7 @@ namespace fpa typedef std::set< TNode, TNodeCompare > TNodes; public: + TSeeds& GetSeeds( ); const TSeeds& GetSeeds( ) const; virtual void AddSeed( const TVertex& seed ); diff --git a/lib/fpa/Base/SeedsInterface.hxx b/lib/fpa/Base/SeedsInterface.hxx index 5dd666e..5bfd16a 100644 --- a/lib/fpa/Base/SeedsInterface.hxx +++ b/lib/fpa/Base/SeedsInterface.hxx @@ -6,6 +6,17 @@ #ifndef __fpa__Base__SeedsInterface__hxx__ #define __fpa__Base__SeedsInterface__hxx__ +// ------------------------------------------------------------------------- +template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare > +typename +fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >:: +TSeeds& +fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >:: +GetSeeds( ) +{ + return( this->m_Seeds ); +} + // ------------------------------------------------------------------------- template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare > const typename diff --git a/lib/fpa/Image/Algorithm.hxx b/lib/fpa/Image/Algorithm.hxx index ba3497f..0fce0d5 100644 --- a/lib/fpa/Image/Algorithm.hxx +++ b/lib/fpa/Image/Algorithm.hxx @@ -64,7 +64,7 @@ _UnifySeeds( ) { const TInputImage* input = this->GetInput( ); typename TInputImage::RegionType region = input->GetRequestedRegion( ); - TSeeds seeds = this->GetSeeds( ); + TSeeds& seeds = this->GetSeeds( ); TNodes nodes; typename TSeeds::iterator sIt = seeds.begin( ); diff --git a/lib/fpa/Image/MinimumSpanningTree.h b/lib/fpa/Image/MinimumSpanningTree.h index 46d2231..22f7904 100644 --- a/lib/fpa/Image/MinimumSpanningTree.h +++ b/lib/fpa/Image/MinimumSpanningTree.h @@ -44,30 +44,21 @@ namespace fpa ); public: - virtual TVertex GetParent( const TVertex& v ) const override - { - return( v + this->GetPixel( v ) ); - } - virtual void SetParent( const TVertex& v, const TVertex& p ) override - { - this->SetPixel( v, p - v ); - } - - void GetPath( + virtual TVertex GetParent( const TVertex& v ) const override; + virtual void SetParent( const TVertex& v, const TVertex& p ) override; + + void GetPolyLineParametricPath( typename TPolyLineParametricPath::Pointer& path, const TVertex& a ) const; - void GetPath( + void GetPolyLineParametricPath( typename TPolyLineParametricPath::Pointer& path, const TVertex& a, const TVertex& b ) const; protected: - MinimumSpanningTree( ) - : Superclass( ) - { } - virtual ~MinimumSpanningTree( ) - { } + MinimumSpanningTree( ); + virtual ~MinimumSpanningTree( ); private: MinimumSpanningTree( const Self& other ); diff --git a/lib/fpa/Image/MinimumSpanningTree.hxx b/lib/fpa/Image/MinimumSpanningTree.hxx new file mode 100644 index 0000000..b6161ee --- /dev/null +++ b/lib/fpa/Image/MinimumSpanningTree.hxx @@ -0,0 +1,75 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= + +#ifndef __fpa__Image__MinimumSpanningTree__hxx__ +#define __fpa__Image__MinimumSpanningTree__hxx__ + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +typename fpa::Image::MinimumSpanningTree< _VDim >:: +TVertex fpa::Image::MinimumSpanningTree< _VDim >:: +GetParent( const TVertex& v ) const +{ + return( v + this->GetPixel( v ) ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void fpa::Image::MinimumSpanningTree< _VDim >:: +SetParent( const TVertex& v, const TVertex& p ) +{ + this->SetPixel( v, p - v ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void fpa::Image::MinimumSpanningTree< _VDim >:: +GetPolyLineParametricPath( + typename TPolyLineParametricPath::Pointer& path, + const TVertex& a + ) const +{ + TVertices v = this->GetPath( a ); + path = TPolyLineParametricPath::New( ); + path->SetReferenceImage( this ); + typename TVertices::const_iterator vIt = v.begin( ); + for( ; vIt != v.end( ); ++vIt ) + path->AddVertex( *vIt ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void fpa::Image::MinimumSpanningTree< _VDim >:: +GetPolyLineParametricPath( + typename TPolyLineParametricPath::Pointer& path, + const TVertex& a, const TVertex& b + ) const +{ + TVertices v = this->GetPath( a, b ); + path = TPolyLineParametricPath::New( ); + path->SetReferenceImage( this ); + typename TVertices::const_iterator vIt = v.begin( ); + for( ; vIt != v.end( ); ++vIt ) + path->AddVertex( *vIt ); +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +fpa::Image::MinimumSpanningTree< _VDim >:: +MinimumSpanningTree( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +fpa::Image::MinimumSpanningTree< _VDim >:: +~MinimumSpanningTree( ) +{ +} + +#endif // __fpa__Image__MinimumSpanningTree__hxx__ + +// eof - $RCSfile$ -- 2.45.0