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::MLPLengthEstimator< TConstIterator > Class Template Reference

#include <MLPLengthEstimator.h>

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

Public Types

typedef TConstIterator ConstIterator
typedef double Quantity
typedef FP< ConstIterator, int, 4 > FaithfulPolygon
typedef FaithfulPolygon::RealPoint Point
typedef FaithfulPolygon::RealVector Vector

Public Member Functions

 MLPLengthEstimator ()
 ~MLPLengthEstimator ()
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

 MLPLengthEstimator (const MLPLengthEstimator &other)
MLPLengthEstimatoroperator= (const MLPLengthEstimator &other)

Private Attributes

double myH
std::vector< PointmyRep
bool myIsInitBefore

Detailed Description

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

Aim: a model of CGlobalCurveEstimator that computes the length of a digital curve using its MLP (given by the FP)

Description of template class 'MLPLengthEstimator'

Model of CGlobalCurveGeometricEstimator.

Template Parameters:
TConstIteratora model of CConstIteratorOnPoints.

Definition at line 69 of file MLPLengthEstimator.h.


Member Typedef Documentation

template<typename TConstIterator>
typedef TConstIterator DGtal::MLPLengthEstimator< TConstIterator >::ConstIterator
Todo:
CONCEPT CHECK sur ConstIterator

Definition at line 76 of file MLPLengthEstimator.h.

template<typename TConstIterator>
typedef FP<ConstIterator,int,4> DGtal::MLPLengthEstimator< TConstIterator >::FaithfulPolygon

Definition at line 80 of file MLPLengthEstimator.h.

template<typename TConstIterator>
typedef FaithfulPolygon::RealPoint DGtal::MLPLengthEstimator< TConstIterator >::Point

Definition at line 81 of file MLPLengthEstimator.h.

template<typename TConstIterator>
typedef double DGtal::MLPLengthEstimator< TConstIterator >::Quantity

Definition at line 78 of file MLPLengthEstimator.h.

template<typename TConstIterator>
typedef FaithfulPolygon::RealVector DGtal::MLPLengthEstimator< TConstIterator >::Vector

Definition at line 82 of file MLPLengthEstimator.h.


Constructor & Destructor Documentation

template<typename T >
DGtal::MLPLengthEstimator< T >::MLPLengthEstimator ( )
inline

Default Constructor.

Constructor.

Definition at line 49 of file MLPLengthEstimator.ih.

{
myIsInitBefore = false;
}
template<typename T >
DGtal::MLPLengthEstimator< T >::~MLPLengthEstimator ( )
inline

Destructor.

Definition at line 59 of file MLPLengthEstimator.ih.

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

Copy constructor.

Parameters:
otherthe object to clone. Forbidden by default.

Member Function Documentation

template<typename T >
DGtal::MLPLengthEstimator< T >::Quantity DGtal::MLPLengthEstimator< 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 91 of file MLPLengthEstimator.ih.

References DGtal::PointVector< dim, TEuclideanRing >::norm().

{
ASSERT(myH > 0);
ASSERT(myIsInitBefore);
Quantity val = 0;
if (myRep.size() > 1) {
typename std::vector<Point>::const_iterator i = myRep.begin();
typename std::vector<Point>::const_iterator j = i;
++j;
for ( ; j != myRep.end(); ++i, ++j) {
Vector v( *j - *i );
val += v.norm(Vector::L_2);
}
}
return val*myH;
}
template<typename T >
void DGtal::MLPLengthEstimator< 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 73 of file MLPLengthEstimator.ih.

References DGtal::FP< TIterator, TInteger, connectivity >::copyMLP(), and DGtal::FP< TIterator, TInteger, connectivity >::size().

{
myH = h;
myRep.clear();
FaithfulPolygon fp( itb, ite, isClosed );
myRep.resize( fp.size() );
fp.copyMLP( myRep.begin() );
if ( (isClosed)&&(myRep.size()!=0) )
myRep.push_back(myRep.front());
}
template<typename T >
bool DGtal::MLPLengthEstimator< T >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 140 of file MLPLengthEstimator.ih.

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

Assignment.

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

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 124 of file MLPLengthEstimator.ih.

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

Field Documentation

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

Grid size.

Definition at line 136 of file MLPLengthEstimator.h.

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

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

Definition at line 142 of file MLPLengthEstimator.h.

template<typename TConstIterator>
std::vector<Point> DGtal::MLPLengthEstimator< TConstIterator >::myRep
private

polygonal representation of the input

Definition at line 139 of file MLPLengthEstimator.h.


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