1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__HXX__
6 #define __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__HXX__
8 // -------------------------------------------------------------------------
10 void cpExtensions::Algorithms::GradientFunctionBase< G >::
13 this->m_Buffer.clear( );
16 // -------------------------------------------------------------------------
18 typename cpExtensions::Algorithms::GradientFunctionBase< G >::
19 TOutput cpExtensions::Algorithms::GradientFunctionBase< G >::
20 Evaluate( const TPoint& p ) const
23 this->GetInputImage( )->TransformPhysicalPointToIndex( p, i );
24 return( this->EvaluateAtIndex( i ) );
27 // -------------------------------------------------------------------------
29 typename cpExtensions::Algorithms::GradientFunctionBase< G >::
30 TOutput cpExtensions::Algorithms::GradientFunctionBase< G >::
31 EvaluateAtIndex( const TIndex& i ) const
33 TOutput res = TOutput( 0 );
34 bool computed = false;
35 if( this->m_BufferResults )
37 typename TBuffer::const_iterator bIt = this->m_Buffer.find( i );
38 computed = ( bIt != this->m_Buffer.end( ) );
39 res = ( computed )? bIt->second: res;
44 res = this->_Evaluate( i );
46 if( this->m_BufferResults )
47 this->m_Buffer[ i ] = res;
51 // -------------------------------------------------------------------------
53 typename cpExtensions::Algorithms::GradientFunctionBase< G >::
54 TOutput cpExtensions::Algorithms::GradientFunctionBase< G >::
55 EvaluateAtContinuousIndex( const TContIndex& i ) const
58 this->GetInputImage( )->TransformContinuousIndexToPhysicalPoint( i, p );
59 return( this->Evaluate( p ) );
62 // -------------------------------------------------------------------------
64 cpExtensions::Algorithms::GradientFunctionBase< G >::
65 GradientFunctionBase( )
67 m_BufferResults( false )
69 this->m_Buffer.clear( );
72 // -------------------------------------------------------------------------
74 cpExtensions::Algorithms::GradientFunctionBase< G >::
75 ~GradientFunctionBase( )
77 this->m_Buffer.clear( );
80 #endif // __CPEXTENSIONS__ALGORITHMS__GRADIENTFUNCTIONBASE__HXX__