]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/RegionGrow.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / RegionGrow.hxx
index c0f8a67059dd355b8d7f14c32d92e23fdd53f68f..c3cb9f3a355fccca44f8f8776702fea5d2ea7013 100644 (file)
-#ifndef __FPA__BASE__REGIONGROW__HXX__
-#define __FPA__BASE__REGIONGROW__HXX__
+#ifndef __fpa__Base__RegionGrow__hxx__
+#define __fpa__Base__RegionGrow__hxx__
+
+#include <fpa/Base/Functors/RegionGrow/Tautology.h>
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-fpa::Base::RegionGrow< _TSuperclass >::
-RegionGrow( )
-  : Superclass( ),
-    m_RegionGrowFunction( NULL ),
-    m_InsideValue( TScalar( 1 ) ),
-    m_OutsideValue( TScalar( 0 ) )
+typename fpa::Base::RegionGrow< _TSuperclass >::
+TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
+GetGrowFunction( )
 {
+  // 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 >::
-_Result( TNode& node, const TNode& parent )
+typename fpa::Base::RegionGrow< _TSuperclass >::
+TOutput fpa::Base::RegionGrow< _TSuperclass >::
+GetInsideValue( ) const
 {
-  if( this->m_RegionGrowFunction.IsNotNull( ) )
-  {
-    bool res = this->m_RegionGrowFunction->Evaluate( node.Vertex );
-    node.Result = ( res )? this->m_InsideValue: this->m_OutsideValue;
-    return( res );
-  }
+  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 )
   {
-    node.Result = this->m_OutsideValue;
-    return( false );
+    f->SetInsideValue( old_f->GetInsideValue( ) );
+    f->SetOutsideValue( old_f->GetOutsideValue( ) );
 
   } // fi
+  this->m_GrowFunction = f;
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
 void fpa::Base::RegionGrow< _TSuperclass >::
-_QueueClear( )
+SetInsideValue( const TOutput& v )
 {
-  this->m_Queue.clear( );
+  TGrowFunction* f = this->GetGrowFunction( );
+  if( f != NULL )
+  {
+    f->SetInsideValue( v );
+    this->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
 void fpa::Base::RegionGrow< _TSuperclass >::
-_QueuePush( const TNode& node )
+SetOutsideValue( const TOutput& v )
 {
-  this->m_Queue.push_back( node );
+  TGrowFunction* f = this->GetGrowFunction( );
+  if( f != NULL )
+  {
+    f->SetOutsideValue( v );
+    this->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-typename fpa::Base::RegionGrow< _TSuperclass >::
-TNode fpa::Base::RegionGrow< _TSuperclass >::
-_QueuePop( )
+fpa::Base::RegionGrow< _TSuperclass >::
+RegionGrow( )
+  : Superclass( )
+{
+  typedef fpa::Base::Functors::RegionGrow::Tautology< TVertex, TOutput > _TFunc;
+  this->SetGrowFunction( _TFunc::New( ) );
+  this->m_InitResult = this->GetGrowFunction( )->GetOutsideValue( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::RegionGrow< _TSuperclass >::
+~RegionGrow( )
 {
-  TNode n = this->m_Queue.front( );
-  this->m_Queue.pop_front( );
-  return( n );
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
 bool fpa::Base::RegionGrow< _TSuperclass >::
-_IsQueueEmpty( ) const
+_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
 {
-  return( this->m_Queue.size( ) == 0 );
+  v.Result = this->_GetInputValue( v, p );
+  return( v.Result == this->GetInsideValue( ) );
 }
 
-#endif // __FPA__BASE__REGIONGROW__HXX__
+#endif // __fpa__Base__RegionGrow__hxx__
 
 // eof - $RCSfile$