]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Filters/RegionGrow.hxx
...
[FrontAlgorithms.git] / lib / fpa / Filters / RegionGrow.hxx
diff --git a/lib/fpa/Filters/RegionGrow.hxx b/lib/fpa/Filters/RegionGrow.hxx
new file mode 100644 (file)
index 0000000..50ae38d
--- /dev/null
@@ -0,0 +1,107 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Filters__RegionGrow__hxx__
+#define __fpa__Filters__RegionGrow__hxx__
+
+#include <limits>
+#include <fpa/Functors/RegionGrow/Tautology.h>
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+void fpa::Filters::RegionGrow< _TDataInterface >::
+SetPredicate( TScalarPredicate* p )
+{
+  if( this->m_ScalarPredicate.GetPointer( ) != p )
+  {
+    this->_Deassociate( this->m_ScalarPredicate );
+    this->m_ScalarPredicate = p;
+    this->_Associate( this->m_ScalarPredicate );
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+void fpa::Filters::RegionGrow< _TDataInterface >::
+SetPredicate( TVertexPredicate* p )
+{
+  if( this->m_VertexPredicate.GetPointer( ) != p )
+  {
+    this->_Deassociate( this->m_VertexPredicate );
+    this->m_VertexPredicate = p;
+    this->_Associate( this->m_VertexPredicate );
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+typename fpa::Filters::RegionGrow< _TDataInterface >::
+TOutputValue fpa::Filters::RegionGrow< _TDataInterface >::
+GetOutsideValue( ) const
+{
+  return( this->GetInitValue( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+void fpa::Filters::RegionGrow< _TDataInterface >::
+SetOutsideValue( const TOutputValue& v )
+{
+  this->SetInitValue( v );
+}
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+fpa::Filters::RegionGrow< _TDataInterface >::
+RegionGrow( )
+  : Superclass( false )
+{
+  this->SetOutsideValue( TOutputValue( 0 ) );
+  this->m_InsideValue = std::numeric_limits< TOutputValue >::max( );
+  this->SetPredicate(
+    fpa::Functors::RegionGrow::Tautology< TInputValue >::New( )
+    );
+}
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+fpa::Filters::RegionGrow< _TDataInterface >::
+~RegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+void fpa::Filters::RegionGrow< _TDataInterface >::
+_PostComputeOutputValue( TNode& n )
+{
+  TInputValue value = this->_GetInputValue( n.Vertex );
+  bool inside = false;
+  if( this->m_ScalarPredicate.IsNotNull( ) )
+    inside = this->m_ScalarPredicate->Evaluate( value );
+  if( this->m_VertexPredicate.IsNotNull( ) )
+    inside &= this->m_VertexPredicate->Evaluate( n.Vertex, n.Parent );
+  if( !inside )
+  {
+    n.Value = this->GetOutsideValue( );
+    n.FrontId = 0;
+  }
+  else
+    n.Value = this->GetInsideValue( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+void fpa::Filters::RegionGrow< _TDataInterface >::
+_PreComputeOutputValue( TNode& n )
+{
+  // Nothing to do with this algorithm
+}
+
+#endif // __fpa__Filters__RegionGrow__hxx__
+// eof - $RCSfile$