X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FBase%2FAlgorithm.hxx;fp=lib%2Ffpa%2FBase%2FAlgorithm.hxx;h=0000000000000000000000000000000000000000;hb=3c639e5da479c7216a0a302ffa156ac6762caeed;hp=68296bebba6393585839f81f02b9cfd2e4546548;hpb=5bf766068f54d061d3816f4950a076c3cf3a4d8b;p=FrontAlgorithms.git diff --git a/lib/fpa/Base/Algorithm.hxx b/lib/fpa/Base/Algorithm.hxx deleted file mode 100644 index 68296be..0000000 --- a/lib/fpa/Base/Algorithm.hxx +++ /dev/null @@ -1,220 +0,0 @@ -// ========================================================================= -// @author Leonardo Florez Valencia -// @email florez-l@javeriana.edu.co -// ========================================================================= - -#ifndef __fpa__Base__Algorithm__hxx__ -#define __fpa__Base__Algorithm__hxx__ - -// ------------------------------------------------------------------------- -template< class _TTraits > -fpa::Base::Algorithm< _TTraits >::TEvent:: -TEvent( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -fpa::Base::Algorithm< _TTraits >::TEvent:: -TEvent( const TVertex& v, unsigned long fid, bool intoq ) - : Superclass( ), - Vertex( v ), - FrontId( fid ), - IntoQueue( intoq ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -fpa::Base::Algorithm< _TTraits >::TEvent:: -~TEvent( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -const char* fpa::Base::Algorithm< _TTraits >::TEvent:: -GetEventName( ) const -{ - return( "fpa::Base::Algorithm< _TTraits >::TEvent" ); -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -bool fpa::Base::Algorithm< _TTraits >::TEvent:: -CheckEvent( const itk::EventObject* e ) const -{ - return( dynamic_cast< const Self* >( e ) != NULL ); -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -itk::EventObject* fpa::Base::Algorithm< _TTraits >::TEvent:: -MakeObject( ) const -{ - return( new Self ); -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -void fpa::Base::Algorithm< _TTraits >:: -InvokeEvent( const itk::EventObject& e ) -{ - TEvent a; - if( a.CheckEvent( &e ) ) - { - if( this->m_VisualDebug ) - this->Superclass::InvokeEvent( e ); - } - else - this->Superclass::InvokeEvent( e ); -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -void fpa::Base::Algorithm< _TTraits >:: -InvokeEvent( const itk::EventObject& e ) const -{ - TEvent a; - if( a.CheckEvent( &e ) ) - { - if( this->m_VisualDebug ) - this->Superclass::InvokeEvent( e ); - } - else - this->Superclass::InvokeEvent( e ); -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -fpa::Base::Algorithm< _TTraits >:: -Algorithm( ) - : Superclass( ), - TMarksInterface( this ), - TSeedsInterface( this ), - m_VisualDebug( false ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -fpa::Base::Algorithm< _TTraits >:: -~Algorithm( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -void fpa::Base::Algorithm< _TTraits >:: -GenerateData( ) -{ - this->InvokeEvent( itk::StartEvent( ) ); - - // Init objects - this->_BeforeGenerateData( ); - this->_ConfigureOutput( this->m_InitValue ); - this->_InitMarks( this->GetSeeds( ).size( ) ); - TNodes seeds = this->_UnifySeeds( ); - this->_PrepareSeeds( seeds ); - - // Init queue - this->_QueueInit( ); - typename TNodes::const_iterator sIt = seeds.begin( ); - for( ; sIt != seeds.end( ); ++sIt ) - { - this->_QueuePush( *sIt ); - this->InvokeEvent( TEvent( sIt->Vertex, sIt->FrontId, true ) ); - - } // rof - - // Main loop - while( this->_QueueSize( ) > 0 ) - { - // Get next candidate - TNode node = this->_QueuePop( ); - this->InvokeEvent( TEvent( node.Vertex, node.FrontId, false ) ); - if( !( this->_IsMarked( node.Vertex ) ) ) - { - // Update output value and mark vertex - this->_UpdateOutputValue( node ); - this->_Mark( node.Vertex, node.FrontId ); - - // The actual node was effectively marked? - if( node.FrontId > 0 ) - { - // Add neighborhood - TNeighborhood neighbors = this->_GetNeighbors( node.Vertex ); - typename TNeighborhood::const_iterator nIt = neighbors.begin( ); - bool coll = false; - while( nIt != neighbors.end( ) && !coll ) - { - if( this->_IsMarked( *nIt ) ) - { - // Invoke stop at collisions - if( this->_Collisions( node.Vertex, *nIt ) ) - { - this->_QueueClear( ); - coll = true; - - } // fi - } - else - { - TNode nnode; - nnode.Vertex = *nIt; - nnode.Parent = node.Vertex; - nnode.FrontId = node.FrontId; - this->_ComputeOutputValue( nnode ); - this->_QueuePush( nnode ); - this->InvokeEvent( TEvent( nnode.Vertex, nnode.FrontId, true ) ); - - } // fi - ++nIt; - - } // elihw - - } // fi - - } // fi - this->_FinishOneLoop( ); - - } // elihw - - // Finish - this->_AfterGenerateData( ); - this->InvokeEvent( itk::EndEvent( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -void fpa::Base::Algorithm< _TTraits >:: -_BeforeGenerateData( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -void fpa::Base::Algorithm< _TTraits >:: -_AfterGenerateData( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -void fpa::Base::Algorithm< _TTraits >:: -_FinishOneLoop( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TTraits > -void fpa::Base::Algorithm< _TTraits >:: -_QueueInit( ) -{ - this->_QueueClear( ); -} - -#endif // __fpa__Base__Algorithm__hxx__ - -// eof - $RCSfile$