#ifndef __fpa__Filters__Mori__hxx__
#define __fpa__Filters__Mori__hxx__
+#include <limits>
+
// -------------------------------------------------------------------------
-template< class _TTraits >
-typename fpa::Filters::Mori< _TTraits >::
-TOutputValue fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+typename fpa::Filters::Mori< _TDataInterface >::
+TOutputValue fpa::Filters::Mori< _TDataInterface >::
GetOutsideValue( ) const
{
return( this->GetInitValue( ) );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
SetOutsideValue( const TOutputValue& v )
{
this->SetInitValue( v );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-unsigned long fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+unsigned long fpa::Filters::Mori< _TDataInterface >::
GetSignalKernelSize( ) const
{
return( this->m_PeakDetector.GetKernelSize( ) );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
SetSignalKernelSize( unsigned long k )
{
this->m_PeakDetector.SetKernelSize( k );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-double fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+double fpa::Filters::Mori< _TDataInterface >::
GetSignalThreshold( ) const
{
return( this->m_PeakDetector.GetThreshold( ) );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
SetSignalThreshold( double t )
{
this->m_PeakDetector.SetThreshold( t );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-double fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+double fpa::Filters::Mori< _TDataInterface >::
GetSignalInfluence( ) const
{
return( this->m_PeakDetector.GetInfluence( ) );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
SetSignalInfluence( double i )
{
this->m_PeakDetector.SetInfluence( i );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
ClearThresholds( )
{
this->m_Thresholds.clear( );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
AddThreshold( const TInputValue& thr )
{
if( this->m_Thresholds.insert( thr ).second )
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-const typename fpa::Filters::Mori< _TTraits >::
-TThresholds& fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
+SetThresholds(
+ const TInputValue& lower,
+ const TInputValue& upper,
+ const TInputValue& delta
+ )
+{
+ for( TInputValue t = lower; t <= upper; t += delta )
+ this->AddThreshold( t );
+}
+
+// -------------------------------------------------------------------------
+template< class _TDataInterface >
+const typename fpa::Filters::Mori< _TDataInterface >::
+TThresholds& fpa::Filters::Mori< _TDataInterface >::
GetThresholds( ) const
{
return( this->m_Thresholds );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-unsigned long fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+unsigned long fpa::Filters::Mori< _TDataInterface >::
GetNumberOfEvaluatedThresholds( ) const
{
return( this->m_PeakDetector.GetNumberOfSamples( ) );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-typename fpa::Filters::Mori< _TTraits >::
-TInputValue fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+typename fpa::Filters::Mori< _TDataInterface >::
+TInputValue fpa::Filters::Mori< _TDataInterface >::
GetOptimumThreshold( ) const
{
TInputValue thr = TInputValue( 0 );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
-GetSignalValues(
- unsigned long i, double& x, double& y, TPeak& p
- ) const
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
+GetSignalValues( unsigned long i, double& x, double& y, TPeak& p ) const
{
if( i < this->m_PeakDetector.GetNumberOfSamples( ) )
{
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
-SetThresholds(
- const TInputValue& lower,
- const TInputValue& upper,
- const TInputValue& delta
- )
-{
- for( TInputValue t = lower; t <= upper; t += delta )
- this->AddThreshold( t );
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+fpa::Filters::Mori< _TDataInterface >::
Mori( )
- : Superclass( ),
- m_InsideValue( TOutputValue( 1 ) )
+ : Superclass( true )
{
- this->SetOutsideValue( 0 );
+ this->SetOutsideValue( TOutputValue( 0 ) );
+ this->m_InsideValue = std::numeric_limits< TOutputValue >::max( );
this->m_Predicate = TPredicate::New( );
this->m_Predicate->StrictOff( );
if( std::numeric_limits< TInputValue >::is_integer )
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+fpa::Filters::Mori< _TDataInterface >::
~Mori( )
{
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
_BeforeGenerateData( )
{
this->Superclass::_BeforeGenerateData( );
// Prepare queues
this->_QueueClear( );
- this->m_CurrQueue = 0;
// Prepare iteration over all thresholds
this->m_CurrThr = this->m_Thresholds.begin( );
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
-_Reinitialize( )
-{
- if( this->m_Queues[ this->m_CurrQueue ].size( ) == 0 )
- {
- // Update peak detector
- TPeak p = this->m_PeakDetector.AddValue(
- *this->m_CurrThr, this->m_CurrCount
- );
- this->m_CurrThr++;
- this->m_CurrQueue = ( this->m_CurrQueue + 1 ) % 2;
- if( this->m_CurrThr != this->m_Thresholds.end( ) )
- {
- // Update predicate and counting value
- this->m_Predicate->SetUpperThreshold( *( this->m_CurrThr ) );
- this->m_CurrCount = double( 0 );
-
- // Peak detected? -> stop!
- if(
- p == TPeakDetector::PosPeak &&
- this->m_MinimumThreshold < *( this->m_CurrThr )
- )
- this->_QueueClear( );
- }
- else
- this->_QueueClear( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
-_UpdateOutputValue( TNode& n )
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
+_PostComputeOutputValue( TNode& n )
{
TInputValue value = this->_GetInputValue( n.Vertex );
bool inside = this->m_Predicate->Evaluate( value );
{
n.Value = this->m_InitValue;
n.FrontId++;
- this->m_Queues[ ( this->m_CurrQueue + 1 ) % 2 ].push_back( n );
+ this->_QueueSwap( );
+ this->_QueuePush( n );
+ this->_QueueSwap( );
n.FrontId = 0;
}
else
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
-_QueueClear( )
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
+_PreComputeOutputValue( TNode& n )
{
- this->m_Queues[ 0 ].clear( );
- this->m_Queues[ 1 ].clear( );
+ // Nothing to do with this algorithm
}
// -------------------------------------------------------------------------
-template< class _TTraits >
-typename fpa::Filters::Mori< _TTraits >::
-TNode fpa::Filters::Mori< _TTraits >::
-_QueuePop( )
+template< class _TDataInterface >
+void fpa::Filters::Mori< _TDataInterface >::
+_Reinitialize( )
{
- TNode n = this->m_Queues[ this->m_CurrQueue ].front( );
- this->m_Queues[ this->m_CurrQueue ].pop_front( );
- return( n );
-}
+ if( this->_QueueSize( ) == 0 )
+ {
+ // Update peak detector
+ TPeak p = this->m_PeakDetector.AddValue(
+ *this->m_CurrThr, this->m_CurrCount
+ );
+ this->m_CurrThr++;
+ this->_QueueSwap( );
+ if( this->m_CurrThr != this->m_Thresholds.end( ) )
+ {
+ // Update predicate and counting value
+ this->m_Predicate->SetUpperThreshold( *( this->m_CurrThr ) );
+ this->m_CurrCount = double( 0 );
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
-_QueuePush( const TNode& n )
-{
- this->m_Queues[ this->m_CurrQueue ].push_back( n );
-}
+ // Peak detected? -> stop!
+ if(
+ p == TPeakDetector::PosPeak &&
+ this->m_MinimumThreshold < *( this->m_CurrThr )
+ )
+ this->_QueueClear( );
+ }
+ else
+ this->_QueueClear( );
-// -------------------------------------------------------------------------
-template< class _TTraits >
-unsigned long fpa::Filters::Mori< _TTraits >::
-_QueueSize( ) const
-{
- return( this->m_Queues[ this->m_CurrQueue ].size( ) );
-}
-// -------------------------------------------------------------------------
-template< class _TTraits >
-void fpa::Filters::Mori< _TTraits >::
-_ComputeOutputValue( TNode& n )
-{
- // Do nothing
+ } // fi
}
#endif // __fpa__Filters__Mori__hxx__