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

#include <DSSLengthEstimator.h>

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

Public Types

typedef TConstIterator ConstIterator
typedef double Quantity
typedef ArithmeticalDSS
< ConstIterator, int, 4 > 
DSSComputer
typedef DSSComputer::Point Point
typedef DSSComputer::Vector Vector

Public Member Functions

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

 DSSLengthEstimator (const DSSLengthEstimator &other)
DSSLengthEstimatoroperator= (const DSSLengthEstimator &other)

Private Attributes

double myH
std::vector< PointmyRep
bool myIsInitBefore

Detailed Description

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

Aim: a model of CGlobalCurveEstimator that segments the digital curve into DSS and computes the length of the resulting (not uniquely defined) polygon.

Description of template class 'DSSLengthEstimator'

Model of CGlobalCurveGeometricEstimator.

Template Parameters:
TConstIteratora model of CConstIteratorOnPoints.

Definition at line 75 of file DSSLengthEstimator.h.


Member Typedef Documentation

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

Definition at line 82 of file DSSLengthEstimator.h.

template<typename TConstIterator>
typedef ArithmeticalDSS<ConstIterator,int,4> DGtal::DSSLengthEstimator< TConstIterator >::DSSComputer

Definition at line 86 of file DSSLengthEstimator.h.

template<typename TConstIterator>
typedef DSSComputer::Point DGtal::DSSLengthEstimator< TConstIterator >::Point

Definition at line 87 of file DSSLengthEstimator.h.

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

Definition at line 84 of file DSSLengthEstimator.h.

template<typename TConstIterator>
typedef DSSComputer::Vector DGtal::DSSLengthEstimator< TConstIterator >::Vector

Definition at line 88 of file DSSLengthEstimator.h.


Constructor & Destructor Documentation

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

Default Constructor.

Constructor.

Definition at line 49 of file DSSLengthEstimator.ih.

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

Destructor.

Definition at line 59 of file DSSLengthEstimator.ih.

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

Copy constructor.

Parameters:
otherthe object to clone. Forbidden by default.

Member Function Documentation

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

{
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::DSSLengthEstimator< 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 DSSLengthEstimator.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::begin(), DGtal::deprecated::GreedyDecomposition< TSegment >::end(), DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::getBack(), and DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::getFront().

{
myH = h;
myRep.clear();
//segments into DSS
DSSComputer computer;
deprecated::GreedyDecomposition<DSSComputer> decomposition ( itb, ite, computer, isClosed );
//computes the resulting polygonal representation
typename deprecated::GreedyDecomposition<DSSComputer>::SegmentIterator segIt = decomposition.begin();
for ( ; segIt != decomposition.end(); ++segIt ) {
myRep.push_back( *segIt.getBack() );
}
//last point
ConstIterator i( segIt.getFront() );
myRep.push_back(*--i);
}
template<typename T >
bool DGtal::DSSLengthEstimator< T >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 146 of file DSSLengthEstimator.ih.

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

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename T >
void DGtal::DSSLengthEstimator< 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 130 of file DSSLengthEstimator.ih.

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

Field Documentation

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

Grid size.

Definition at line 142 of file DSSLengthEstimator.h.

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

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

Definition at line 148 of file DSSLengthEstimator.h.

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

polygonal representation of the input

Definition at line 145 of file DSSLengthEstimator.h.


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