X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffpa%2FBase%2FRegionGrow.hxx;h=6865916c412b5771fb7270b67a2a4e14b6ea1f92;hb=40fb0405cfef444001429f8ba49c407ce9168a94;hp=e7dba1fa3fbb6a7453846a2e00507352d5dec9d9;hpb=cf298be2de026712c5ab3487978e3a6954a809cd;p=FrontAlgorithms.git diff --git a/lib/fpa/Base/RegionGrow.hxx b/lib/fpa/Base/RegionGrow.hxx index e7dba1f..6865916 100644 --- a/lib/fpa/Base/RegionGrow.hxx +++ b/lib/fpa/Base/RegionGrow.hxx @@ -5,78 +5,118 @@ // ------------------------------------------------------------------------- template< class _TSuperclass > -fpa::Base::RegionGrow< _TSuperclass >:: -RegionGrow( ) - : Superclass( ), - m_InsideValue( TOutput( 1 ) ), - m_OutsideValue( TOutput( 0 ) ) +typename fpa::Base::RegionGrow< _TSuperclass >:: +TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >:: +GetGrowFunction( ) { - this->m_InitResult = TOutput( 0 ); - this->SetGrowFunction( - fpa::Base::Functors::RegionGrow::Tautology< TVertex >::New( ) + return( dynamic_cast< TGrowFunction* >( this->GetVertexFunction( ) ) ); +} + +// ------------------------------------------------------------------------- +template< class _TSuperclass > +const typename fpa::Base::RegionGrow< _TSuperclass >:: +TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >:: +GetGrowFunction( ) const +{ + return( + dynamic_cast< const TGrowFunction* >( this->GetVertexFunction( ) ) ); } // ------------------------------------------------------------------------- template< class _TSuperclass > -fpa::Base::RegionGrow< _TSuperclass >:: -~RegionGrow( ) +typename fpa::Base::RegionGrow< _TSuperclass >:: +TOutput fpa::Base::RegionGrow< _TSuperclass >:: +GetInsideValue( ) const { + const TGrowFunction* f = this->GetGrowFunction( ); + if( f != NULL ) + return( f->GetInsideValue( ) ); + else + return( this->m_InitResult ); } // ------------------------------------------------------------------------- template< class _TSuperclass > -bool fpa::Base::RegionGrow< _TSuperclass >:: -_UpdateValue( _TQueueNode& v, const _TQueueNode& p ) +typename fpa::Base::RegionGrow< _TSuperclass >:: +TOutput fpa::Base::RegionGrow< _TSuperclass >:: +GetOutsideValue( ) const { - if( this->m_GrowFunction.IsNotNull( ) ) - { - bool in = this->m_GrowFunction->Evaluate( p.Vertex, v.Vertex ); - v.Result = ( in )? this->m_InsideValue: this->m_OutsideValue; - return( in ); - } + const TGrowFunction* f = this->GetGrowFunction( ); + if( f != NULL ) + return( f->GetOutsideValue( ) ); else + return( this->m_InitResult ); +} + +// ------------------------------------------------------------------------- +template< class _TSuperclass > +void fpa::Base::RegionGrow< _TSuperclass >:: +SetGrowFunction( TGrowFunction* f ) +{ + TGrowFunction* old_f = this->GetGrowFunction( ); + if( old_f != NULL ) { - v.Result = this->m_InitResult; - return( false ); + f->SetInsideValue( old_f->GetInsideValue( ) ); + f->SetOutsideValue( old_f->GetOutsideValue( ) ); } // fi + this->SetVertexFunction( f ); } // ------------------------------------------------------------------------- template< class _TSuperclass > -unsigned long fpa::Base::RegionGrow< _TSuperclass >:: -_QueueSize( ) const +void fpa::Base::RegionGrow< _TSuperclass >:: +SetInsideValue( const TOutput& v ) { - return( this->m_Queue.size( ) ); + TGrowFunction* f = this->GetGrowFunction( ); + if( f != NULL ) + { + f->SetInsideValue( v ); + this->Modified( ); + + } // fi } // ------------------------------------------------------------------------- template< class _TSuperclass > void fpa::Base::RegionGrow< _TSuperclass >:: -_QueueClear( ) +SetOutsideValue( const TOutput& v ) { - while( this->m_Queue.size( ) > 0 ) - this->m_Queue.pop( ); + TGrowFunction* f = this->GetGrowFunction( ); + if( f != NULL ) + { + f->SetOutsideValue( v ); + this->Modified( ); + + } // fi } // ------------------------------------------------------------------------- template< class _TSuperclass > -void fpa::Base::RegionGrow< _TSuperclass >:: -_QueuePush( const _TQueueNode& node ) +fpa::Base::RegionGrow< _TSuperclass >:: +RegionGrow( ) + : Superclass( ) { - this->m_Queue.push( node ); + typedef fpa::Base::Functors::RegionGrow::Tautology< TVertex, TOutput > _TFunc; + this->SetGrowFunction( _TFunc::New( ) ); + this->m_InitResult = this->GetGrowFunction( )->GetOutsideValue( ); } // ------------------------------------------------------------------------- template< class _TSuperclass > -typename fpa::Base::RegionGrow< _TSuperclass >:: -_TQueueNode fpa::Base::RegionGrow< _TSuperclass >:: -_QueuePop( ) +fpa::Base::RegionGrow< _TSuperclass >:: +~RegionGrow( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TSuperclass > +bool fpa::Base::RegionGrow< _TSuperclass >:: +_UpdateValue( _TQueueNode& v, const _TQueueNode& p ) { - _TQueueNode f = this->m_Queue.front( ); - this->m_Queue.pop( ); - return( f ); + v.Result = this->_GetInputValue( v, p ); + return( v.Result == this->GetInsideValue( ) ); } #endif // __fpa__Base__RegionGrow__hxx__