+++ /dev/null
-// =========================================================================
-// @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$