DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::TwoStepLocalLengthEstimator< TConstIterator > Class Template Reference

#include <TwoStepLocalLengthEstimator.h>

Inheritance diagram for DGtal::TwoStepLocalLengthEstimator< TConstIterator >:
Inheritance graph
[legend]
Collaboration diagram for DGtal::TwoStepLocalLengthEstimator< TConstIterator >:
Collaboration graph
[legend]

Public Types

typedef TConstIterator ConstIterator
typedef double Quantity

Public Member Functions

 TwoStepLocalLengthEstimator (const double wdirect, const double wdiag)
 ~TwoStepLocalLengthEstimator ()
void init (const double h, const ConstIterator &itb, const ConstIterator &ite, const bool &isClosed)
Quantity eval () const
void selfDisplay (std::ostream &out) const
bool isValid () const

Private Member Functions

 TwoStepLocalLengthEstimator (const TwoStepLocalLengthEstimator &other)
TwoStepLocalLengthEstimatoroperator= (const TwoStepLocalLengthEstimator &other)

Private Attributes

double myH
ConstIterator myBeginIt
ConstIterator myEndIt
bool myIsInitBefore
double myWeightDirect
double myWeightDiagonal

Detailed Description

template<typename TConstIterator>
class DGtal::TwoStepLocalLengthEstimator< TConstIterator >

Aim: a simple model of CGlobalCurveEstimator that compute the length of a curve using the l_1 metric (just add 1/h for every step).

Description of template class 'TwoStepLocalLengthEstimator'

Model of CGlobalCurveGeometricEstimator.

Template Parameters:
TConstIteratora model of CConstIteratorOnArrows.

Definition at line 65 of file TwoStepLocalLengthEstimator.h.


Member Typedef Documentation

template<typename TConstIterator>
typedef TConstIterator DGtal::TwoStepLocalLengthEstimator< TConstIterator >::ConstIterator
template<typename TConstIterator>
typedef double DGtal::TwoStepLocalLengthEstimator< TConstIterator >::Quantity

Constructor & Destructor Documentation

template<typename TConstIterator>
DGtal::TwoStepLocalLengthEstimator< TConstIterator >::TwoStepLocalLengthEstimator ( const double  wdirect,
const double  wdiag 
)
inline

Default Constructor.

Definition at line 80 of file TwoStepLocalLengthEstimator.h.

:
{}
template<typename T >
DGtal::TwoStepLocalLengthEstimator< T >::~TwoStepLocalLengthEstimator ( )
inline

Destructor.

Definition at line 48 of file TwoStepLocalLengthEstimator.ih.

{
}
template<typename TConstIterator>
DGtal::TwoStepLocalLengthEstimator< TConstIterator >::TwoStepLocalLengthEstimator ( const TwoStepLocalLengthEstimator< TConstIterator > &  other)
private

Copy constructor.

Parameters:
otherthe object to clone. Forbidden by default.

Member Function Documentation

template<typename T >
DGtal::TwoStepLocalLengthEstimator< T >::Quantity DGtal::TwoStepLocalLengthEstimator< T >::eval ( ) const
inline

Computation of the l1 length of the curve. Complexity: O(|Range|)

Precondition:
init() method must be called before.
Returns:
the curve length.

Definition at line 76 of file TwoStepLocalLengthEstimator.ih.

{
ASSERT(myH > 0);
ASSERT(myIsInitBefore);
ASSERT(myBeginIt != myEndIt);
unsigned int nbDirect=0;
unsigned int nbDiag=0;
ConstIterator i = myBeginIt, ii = myBeginIt;
++ii;
while (( i != myEndIt) && (ii != myEndIt))
{
if (((*i).second).dot((*ii).second) == 0)
nbDiag++;
else
nbDirect+=2;
++i;
if (i == myEndIt)
continue;
++i;
++ii;
if (ii == myEndIt)
continue;
++ii;
}
if ( i!= myEndIt)
nbDirect ++;
return (nbDiag*myWeightDiagonal + nbDirect*myWeightDirect)*myH;
}
template<typename T >
void DGtal::TwoStepLocalLengthEstimator< T >::init ( const double  h,
const ConstIterator itb,
const ConstIterator ite,
const bool &  isClosed 
)
inline

Initialize the measure computation.

Parameters:
hgrid size (must be >0).
itbbegin iterator
iteend iterator
closedtrue if the input range is closed.

Definition at line 62 of file TwoStepLocalLengthEstimator.ih.

{
myH = h;
myBeginIt = itb;
myEndIt = ite;
}
template<typename T >
bool DGtal::TwoStepLocalLengthEstimator< T >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.

Definition at line 141 of file TwoStepLocalLengthEstimator.ih.

{
}
template<typename TConstIterator>
TwoStepLocalLengthEstimator& DGtal::TwoStepLocalLengthEstimator< TConstIterator >::operator= ( const TwoStepLocalLengthEstimator< TConstIterator > &  other)
private

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename T >
void DGtal::TwoStepLocalLengthEstimator< T >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Reimplemented in DGtal::RosenProffittLocalLengthEstimator< TConstIterator >, and DGtal::BLUELocalLengthEstimator< TConstIterator >.

Definition at line 125 of file TwoStepLocalLengthEstimator.ih.

{
out << "[TwoStepLocalLengthEstimator]";
out <<" myH="<<myH;
else
out<< " not initialized";
}

Field Documentation

template<typename TConstIterator>
ConstIterator DGtal::TwoStepLocalLengthEstimator< TConstIterator >::myBeginIt
private

Copy of the range.

Definition at line 136 of file TwoStepLocalLengthEstimator.h.

template<typename TConstIterator>
ConstIterator DGtal::TwoStepLocalLengthEstimator< TConstIterator >::myEndIt
private

Definition at line 137 of file TwoStepLocalLengthEstimator.h.

template<typename TConstIterator>
double DGtal::TwoStepLocalLengthEstimator< TConstIterator >::myH
private

Grid size.

Definition at line 133 of file TwoStepLocalLengthEstimator.h.

Referenced by DGtal::BLUELocalLengthEstimator< TConstIterator >::selfDisplay(), and DGtal::RosenProffittLocalLengthEstimator< TConstIterator >::selfDisplay().

template<typename TConstIterator>
bool DGtal::TwoStepLocalLengthEstimator< TConstIterator >::myIsInitBefore
private

Boolean to make sure that init() has been called before eval().

Definition at line 140 of file TwoStepLocalLengthEstimator.h.

Referenced by DGtal::BLUELocalLengthEstimator< TConstIterator >::selfDisplay(), and DGtal::RosenProffittLocalLengthEstimator< TConstIterator >::selfDisplay().

template<typename TConstIterator>
double DGtal::TwoStepLocalLengthEstimator< TConstIterator >::myWeightDiagonal
private

Definition at line 144 of file TwoStepLocalLengthEstimator.h.

template<typename TConstIterator>
double DGtal::TwoStepLocalLengthEstimator< TConstIterator >::myWeightDirect
private

Weights.

Definition at line 143 of file TwoStepLocalLengthEstimator.h.


The documentation for this class was generated from the following files: