]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/RegionGrow.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / RegionGrow.hxx
index bdc1ed34c7818bb162480615ab83749cd107b345..bf0a862e23b36ee15e3bb512003c4d8f35a44245 100644 (file)
-#ifndef __FPA__BASE__REGIONGROWING__HXX__
-#define __FPA__BASE__REGIONGROWING__HXX__
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Base__RegionGrow__hxx__
+#define __fpa__Base__RegionGrow__hxx__
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-fpa::Base::RegionGrow< V, R, VV, VC, B >::
-RegionGrow( )
-  : Superclass( )
+template< class _TAlgorithm >
+itk::ModifiedTimeType fpa::Base::RegionGrow< _TAlgorithm >::
+GetMTime( ) const
 {
+  itk::ModifiedTimeType t = this->Superclass::GetMTime( );
+  if( this->m_ValuePredicate.IsNotNull( ) )
+  {
+    itk::ModifiedTimeType q = this->m_ValuePredicate->GetMTime( );
+    t = ( q < t )? q: t;
+
+  } // fi
+  if( this->m_VertexPredicate.IsNotNull( ) )
+  {
+    itk::ModifiedTimeType q = this->m_VertexPredicate->GetMTime( );
+    t = ( q < t )? q: t;
+
+  } // fi
+
+  return( t );
 }
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-fpa::Base::RegionGrow< V, R, VV, VC, B >::
-~RegionGrow( )
+template< class _TAlgorithm >
+typename fpa::Base::RegionGrow< _TAlgorithm >::
+TOutputValue fpa::Base::RegionGrow< _TAlgorithm >::
+GetOutsideValue( ) const
+{
+  return( this->GetInitValue( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+SetOutsideValue( const TOutputValue& v )
+{
+  this->SetInitValue( v );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+SetPredicate( TValuePredicate* p )
+{
+  if( this->m_ValuePredicate.GetPointer( ) != p )
+  {
+    this->m_ValuePredicate = p;
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+SetPredicate( TVertexPredicate* p )
+{
+  if( this->m_VertexPredicate.GetPointer( ) != p )
+  {
+    this->m_VertexPredicate = p;
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+fpa::Base::RegionGrow< _TAlgorithm >::
+RegionGrow( )
+  : Superclass( ),
+    m_InsideValue( TOutputValue( 1 ) )
 {
+  this->SetInitValue( TOutputValue( 0 ) );
 }
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-bool fpa::Base::RegionGrow< V, R, VV, VC, B >::
-_UpdateResult( _TNode& n )
+template< class _TAlgorithm >
+fpa::Base::RegionGrow< _TAlgorithm >::
+~RegionGrow( )
 {
-  n.Result = R( this->_CheckMembership( n ) );
-  return( n.Result );
 }
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-void fpa::Base::RegionGrow< V, R, VV, VC, B >::
-_InitializeQueue( )
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+_ComputeOutputValue( TNode& n )
 {
-  for(
-    typename _TNodes::const_iterator vIt = this->m_Seeds.begin( );
-    vIt != this->m_Seeds.end( );
-    vIt++
-    )
-    this->_QueuePush( *vIt );
+  // Do nothing!!!
 }
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-bool fpa::Base::RegionGrow< V, R, VV, VC, B >::
-_IsQueueEmpty( ) const
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+_UpdateOutputValue( TNode& n )
 {
-  return( this->m_Queue.empty( ) );
+  TInputValue value = this->_GetInputValue( n.Vertex );
+  bool inside = false;
+  if( this->m_ValuePredicate.IsNotNull( ) )
+    inside = this->m_ValuePredicate->Evaluate( value );
+  if( this->m_VertexPredicate.IsNotNull( ) )
+    inside &= this->m_VertexPredicate->Evaluate( n.Vertex );
+  if( !inside )
+  {
+    n.Value = this->m_InitValue;
+    n.FrontId = 0;
+  }
+  else
+    n.Value = this->m_InsideValue;
+  this->Superclass::_UpdateOutputValue( n );
 }
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-void fpa::Base::RegionGrow< V, R, VV, VC, B >::
-_QueuePush( const _TNode& n )
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+_QueueClear( )
 {
-  this->m_Queue.push( n );
+  this->m_Queue.clear( );
 }
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-typename fpa::Base::RegionGrow< V, R, VV, VC, B >::
-_TNode fpa::Base::RegionGrow< V, R, VV, VC, B >::
+template< class _TAlgorithm >
+typename fpa::Base::RegionGrow< _TAlgorithm >::
+TNode fpa::Base::RegionGrow< _TAlgorithm >::
 _QueuePop( )
 {
-  _TNode n = this->m_Queue.front( );
-  this->m_Queue.pop( );
+  TNode n = this->m_Queue.front( );
+  this->m_Queue.pop_front( );
   return( n );
 }
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-void fpa::Base::RegionGrow< V, R, VV, VC, B >::
-_QueueClear( )
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+_QueuePush( const TNode& node )
+{
+  this->m_Queue.push_back( node );
+}
+
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+unsigned long fpa::Base::RegionGrow< _TAlgorithm >::
+_QueueSize( ) const
 {
-  while( this->m_Queue.size( ) > 0 )
-    this->m_Queue.pop( );
+  return( this->m_Queue.size( ) );
 }
 
 // -------------------------------------------------------------------------
-template< class V, class R, class VV, class VC, class B >
-bool fpa::Base::RegionGrow< V, R, VV, VC, B >::
-_UpdateNeigh( _TNode& nn, const _TNode& n )
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+_PrepareSeeds( TNodes& nodes )
 {
-  return( true );
+  typename TNodes::iterator nIt = nodes.begin( );
+  for( ; nIt != nodes.end( ); ++nIt )
+    nIt->Value = this->m_InitValue;
 }
 
-#endif // __FPA__BASE__REGIONGROWING__HXX__
+#endif // __fpa__Base__RegionGrow__hxx__
 
 // eof - $RCSfile$