]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/RegionGrow.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / RegionGrow.hxx
index e7dba1fa3fbb6a7453846a2e00507352d5dec9d9..c3cb9f3a355fccca44f8f8776702fea5d2ea7013 100644 (file)
 
 // -------------------------------------------------------------------------
 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( )
-    );
+  // TODO: return( dynamic_cast< TGrowFunction* >( this->GetVertexFunction( ) ) );
+  return( this->m_GrowFunction );
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-fpa::Base::RegionGrow< _TSuperclass >::
-~RegionGrow( )
+const typename fpa::Base::RegionGrow< _TSuperclass >::
+TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
+GetGrowFunction( ) const
 {
+  /* TODO
+     return(
+     dynamic_cast< const TGrowFunction* >( this->GetVertexFunction( ) )
+     );
+  */
+  return( this->m_GrowFunction );
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-bool fpa::Base::RegionGrow< _TSuperclass >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
+typename fpa::Base::RegionGrow< _TSuperclass >::
+TOutput fpa::Base::RegionGrow< _TSuperclass >::
+GetInsideValue( ) 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->GetInsideValue( ) );
   else
+    return( this->m_InitResult );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+typename fpa::Base::RegionGrow< _TSuperclass >::
+TOutput fpa::Base::RegionGrow< _TSuperclass >::
+GetOutsideValue( ) const
+{
+  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->m_GrowFunction = 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__