X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FFilters%2FRegionGrow.hxx;fp=lib%2Ffpa%2FFilters%2FRegionGrow.hxx;h=50ae38d27fd4aa68f1c7fd77138ff387bfd5dc5d;hb=bd89a1af0c14ed2ac0afeca923103de54283cbaf;hp=0000000000000000000000000000000000000000;hpb=a8ac405fe1422bc0792a810f7f0693096a22c20e;p=FrontAlgorithms.git diff --git a/lib/fpa/Filters/RegionGrow.hxx b/lib/fpa/Filters/RegionGrow.hxx new file mode 100644 index 0000000..50ae38d --- /dev/null +++ b/lib/fpa/Filters/RegionGrow.hxx @@ -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 +#include + +// ------------------------------------------------------------------------- +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$