+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__Base__MarksInterfaceWithCollisions__hxx__
-#define __fpa__Base__MarksInterfaceWithCollisions__hxx__
-
-#include <queue>
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-bool fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-StopAtOneFront( ) const
-{
- return( this->m_StopAtOneFront );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-StopAtOneFrontOn( )
-{
- this->SetStopAtOneFront( true );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-StopAtOneFrontOff( )
-{
- this->SetStopAtOneFront( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-SetStopAtOneFront( bool v )
-{
- if( this->m_StopAtOneFront != v )
- {
- this->m_StopAtOneFront = v;
- if( this->m_Filter != NULL )
- this->m_Filter->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-MarksInterfaceWithCollisions( itk::ProcessObject* filter )
- : Superclass( filter ),
- m_StopAtOneFront( false ),
- m_NumberOfFronts( 0 )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-~MarksInterfaceWithCollisions( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-void fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-_InitMarks( unsigned long nSeeds )
-{
- this->Superclass::_InitMarks( nSeeds );
- this->m_NumberOfFronts = nSeeds;
- TCollision coll( TVertex( ), false );
- TCollisionsRow row( this->m_NumberOfFronts, coll );
- this->m_Collisions.clear( );
- this->m_Collisions.resize( this->m_NumberOfFronts, row );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex >
-bool fpa::Base::MarksInterfaceWithCollisions< _TVertex >::
-_Collisions( const TVertex& a, const TVertex& b )
-{
- unsigned long ma = this->_GetMark( a );
- unsigned long mb = this->_GetMark( b );
- if( ma == mb || ma == 0 || mb == 0 )
- return( false );
-
- // Mark collision, if it is new
- ma--; mb--;
- bool ret = false;
- bool exists = this->m_Collisions[ ma ][ mb ].second;
- exists &= this->m_Collisions[ mb ][ ma ].second;
- if( !exists )
- {
- this->m_Collisions[ ma ][ mb ].first = a;
- this->m_Collisions[ ma ][ mb ].second = true;
- this->m_Collisions[ mb ][ ma ].first = b;
- this->m_Collisions[ mb ][ ma ].second = true;
-
- // Update number of fronts
- unsigned long count = 0;
- std::vector< bool > m( this->m_NumberOfSeeds, false );
- std::queue< unsigned long > q;
- q.push( 0 );
- while( !q.empty( ) )
- {
- unsigned long f = q.front( );
- q.pop( );
-
- if( m[ f ] )
- continue;
- m[ f ] = true;
- count++;
-
- for( unsigned int n = 0; n < this->m_NumberOfSeeds; ++n )
- if( this->m_Collisions[ f ][ n ].second && !m[ n ] )
- q.push( n );
-
- } // elihw
- this->m_NumberOfFronts = this->m_NumberOfSeeds - count + 1;
-
- } // fi
- return(
- this->m_StopAtOneFront &&
- this->m_NumberOfSeeds > 1 &&
- this->m_NumberOfFronts == 1
- );
-}
-
-#endif // __fpa__Base__MarksInterfaceWithCollisions__hxx__
-
-// eof - $RCSfile$