DGtal  1.2.0
DGtal::FP< TIterator, TInteger, connectivity > Class Template Reference

Aim: Computes the faithful polygon (FP) of a range of 4/8-connected 2D Points. More...

#include <DGtal/geometry/curves/FP.h>

## Public Types

typedef DGtal::PointVector< 2, TInteger > Point

typedef DGtal::PointVector< 2, TInteger > Vector

typedef DGtal::PointVector< 2, double > RealPoint

typedef DGtal::PointVector< 2, double > RealVector

typedef DGtal::ArithmeticalDSSComputer< TIterator, TInteger, connectivity > DSSComputer

typedef std::list< PointPolygon

## Public Member Functions

BOOST_CONCEPT_ASSERT ((concepts::CInteger< TInteger >))

FP (const TIterator &itb, const TIterator &ite)

~FP ()

const Polygonpolygon () const

bool isClosed () const

bool isValid () const

Polygon::size_type size () const

template<typename OutputIterator >
OutputIterator copyFP (OutputIterator result) const

template<typename OutputIterator >
OutputIterator copyMLP (OutputIterator result) const

void selfDisplay (std::ostream &out) const

std::string className () const

## Private Member Functions

void algorithm (const TIterator &itb, const TIterator &ite)

void algorithm (const TIterator &itb, const TIterator &ite, IteratorType)

void algorithm (const TIterator &itb, const TIterator &ite, CirculatorType)

bool isValid (const Point &a, const Point &b, const Point &c) const

bool quadrant (const Vector &v, const int &q) const

RealPoint getRealPoint (const Point &a, const Point &b, const Point &c) const

FP (const FP &other)

FPoperator= (const FP &other)

## Private Attributes

Polygon myPolygon

## Detailed Description

### template<typename TIterator, typename TInteger, int connectivity> class DGtal::FP< TIterator, TInteger, connectivity >

Aim: Computes the faithful polygon (FP) of a range of 4/8-connected 2D Points.

The FP has several interesting properties:

• its vertices are points of the underlying digital curve, thus with integer coordinates,
• it respects the convex and concave parts of the underlying digital curve,
• it is reversible,
• it is unique for digital curves that are not digital straight segments,
• it is closed to the minimum length polygon (MLP) (and converges toward the MLP as the resolution tends to the infinity) for closed digital curves.

It is computed in the course of the maximal digital straight segments computation, because in convex parts (resp. concave parts), the first and last upper (resp. lower) leaning points of segments that are maximal at the front or at the back are also vertices of the FP.

ArithmeticalDSSComputer DSSDecorator DSSDecorator4ConvexPart DSSDecorator4ConcavePart
Note
T. ROUSSILLON and I. SIVIGNON, Faithful polygonal representation of the convex and concave parts of a digital curve, Pattern Recognition, Volume 44, Issues 10-11, October-November 2011, Pages 2693-2700.

Usage:

//r is a range of 4-connected 2D points
FP<ConstIterator, Integer, 4> theFP( r .begin(), r.end() );

Once the FP is computed, copyFP() is a way of geting its vertices. In the same way, copyMLP() is a way of getting the vertices of the MLP.

Template Parameters
 TIterator type ConstIterator on 2D points, TInteger (satisfying CInteger) connectivity 4 for standard (4-connected) DSS or 8 for naive (8-connected) DSS. (Any other integers act as 8).
testFP.cpp

Definition at line 292 of file FP.h.

## ◆ DSSComputer

template<typename TIterator , typename TInteger , int connectivity>
 typedef DGtal::ArithmeticalDSSComputer DGtal::FP< TIterator, TInteger, connectivity >::DSSComputer

Definition at line 307 of file FP.h.

## ◆ Point

template<typename TIterator , typename TInteger , int connectivity>
 typedef DGtal::PointVector<2,TInteger> DGtal::FP< TIterator, TInteger, connectivity >::Point

Definition at line 301 of file FP.h.

## ◆ Polygon

template<typename TIterator , typename TInteger , int connectivity>
 typedef std::list DGtal::FP< TIterator, TInteger, connectivity >::Polygon

Definition at line 309 of file FP.h.

## ◆ RealPoint

template<typename TIterator , typename TInteger , int connectivity>
 typedef DGtal::PointVector<2, double> DGtal::FP< TIterator, TInteger, connectivity >::RealPoint

Definition at line 304 of file FP.h.

## ◆ RealVector

template<typename TIterator , typename TInteger , int connectivity>
 typedef DGtal::PointVector<2, double> DGtal::FP< TIterator, TInteger, connectivity >::RealVector

Definition at line 305 of file FP.h.

## ◆ Vector

template<typename TIterator , typename TInteger , int connectivity>
 typedef DGtal::PointVector<2,TInteger> DGtal::FP< TIterator, TInteger, connectivity >::Vector

Definition at line 302 of file FP.h.

## ◆ FP() [1/2]

template<typename TIterator , typename TInteger , int connectivity>
 DGtal::FP< TIterator, TInteger, connectivity >::FP ( const TIterator & itb, const TIterator & ite )

Constructor.

Parameters
 itb begin iterator ite end iterator

## ◆ ~FP()

template<typename TIterator , typename TInteger , int connectivity>
 DGtal::FP< TIterator, TInteger, connectivity >::~FP ( )

Destructor.

## ◆ FP() [2/2]

template<typename TIterator , typename TInteger , int connectivity>
 DGtal::FP< TIterator, TInteger, connectivity >::FP ( const FP< TIterator, TInteger, connectivity > & other )
private

Copy constructor.

Parameters
 other the object to clone. Forbidden by default.

## Member Function Documentation

template<typename TIterator , typename TInteger , int connectivity>
private

Adding step in the closed case

Parameters
Template Parameters
details::DSSDecorator details::DSSDecorator4ConvexParts details::DSSDecorator4ConcaveParts

template<typename TIterator , typename TInteger , int connectivity>
private

Adding step in the open case

Parameters
 adapter an Adapter to the current DSS itEnd end iterator used to stop the algorithm (when currentDSS.end() == itEnd )
Returns
'false' if the algorithm has to stop and 'true' otherwise
Template Parameters
details::DSSDecorator details::DSSDecorator4ConvexParts details::DSSDecorator4ConcaveParts

## ◆ algorithm() [1/3]

template<typename TIterator , typename TInteger , int connectivity>
 void DGtal::FP< TIterator, TInteger, connectivity >::algorithm ( const TIterator & itb, const TIterator & ite )
private

Main algorithm

Parameters
 itb begin iterator ite end iterator

## ◆ algorithm() [2/3]

template<typename TIterator , typename TInteger , int connectivity>
 void DGtal::FP< TIterator, TInteger, connectivity >::algorithm ( const TIterator & itb, const TIterator & ite, CirculatorType )
private

Parameters
 itb begin iterator ite end iterator

## ◆ algorithm() [3/3]

template<typename TIterator , typename TInteger , int connectivity>
 void DGtal::FP< TIterator, TInteger, connectivity >::algorithm ( const TIterator & itb, const TIterator & ite, IteratorType )
private

Parameters
 itb begin iterator ite end iterator

## ◆ BOOST_CONCEPT_ASSERT()

template<typename TIterator , typename TInteger , int connectivity>
 DGtal::FP< TIterator, TInteger, connectivity >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< TInteger >) )

## ◆ className()

template<typename TIterator , typename TInteger , int connectivity>
 std::string DGtal::FP< TIterator, TInteger, connectivity >::className ( ) const
Returns
the style name used for drawing this object.

## ◆ copyFP()

template<typename TIterator , typename TInteger , int connectivity>
template<typename OutputIterator >
 OutputIterator DGtal::FP< TIterator, TInteger, connectivity >::copyFP ( OutputIterator result ) const
Returns
the vertices of the FP NB: O(n)

## ◆ copyMLP()

template<typename TIterator , typename TInteger , int connectivity>
template<typename OutputIterator >
 OutputIterator DGtal::FP< TIterator, TInteger, connectivity >::copyMLP ( OutputIterator result ) const
Returns
the vertices of the MLP NB: O(n)

## ◆ getRealPoint()

template<typename TIterator , typename TInteger , int connectivity>
 RealPoint DGtal::FP< TIterator, TInteger, connectivity >::getRealPoint ( const Point & a, const Point & b, const Point & c ) const
private

Gets a MLP vertex from three consecutive vertices of the FP.

Parameters
 a previous vertex of the FP b current vertex of the FP c next vertex of the FP
Returns
vertex of the MLP, which is the tranlated of b by (+- 0.5, +- 0.5)

## ◆ initConvexityConcavity()

template<typename TIterator , typename TInteger , int connectivity>
private

A DSS adapter is returned according to the local convexity/concavity

Parameters
 aDSS a DSS lying on the range to process
Returns
Template Parameters
details::DSSDecorator details::DSSDecorator4ConvexParts details::DSSDecorator4ConcaveParts

## ◆ isClosed()

template<typename TIterator , typename TInteger , int connectivity>
 bool DGtal::FP< TIterator, TInteger, connectivity >::isClosed ( ) const
Returns
true if the list has to be consider as circular.

## ◆ isValid() [1/2]

template<typename TIterator , typename TInteger , int connectivity>
 bool DGtal::FP< TIterator, TInteger, connectivity >::isValid ( ) const

Checks the validity/consistency of the object.

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

Referenced by testFP().

## ◆ isValid() [2/2]

template<typename TIterator , typename TInteger , int connectivity>
 bool DGtal::FP< TIterator, TInteger, connectivity >::isValid ( const Point & a, const Point & b, const Point & c ) const
private

Checks if a turn defined by three consecutive vertices of the FP is valid or not

Parameters
 a previous vertex of the FP b current vertex of the FP c next vertex of the FP
Returns
'true' if valid, 'false' otherwise.

## ◆ operator=()

template<typename TIterator , typename TInteger , int connectivity>
 FP& DGtal::FP< TIterator, TInteger, connectivity >::operator= ( const FP< TIterator, TInteger, connectivity > & other )
private

Assignment.

Parameters
 other the object to copy.
Returns
a reference on 'this'. Forbidden by default.

## ◆ polygon()

template<typename TIterator , typename TInteger , int connectivity>
 const Polygon& DGtal::FP< TIterator, TInteger, connectivity >::polygon ( ) const
Returns
the list where each vertex of the FP is stored.

template<typename TIterator , typename TInteger , int connectivity>
 bool DGtal::FP< TIterator, TInteger, connectivity >::quadrant ( const Vector & v, const int & q ) const
private

Returns the quadrant number of a vector

Parameters
 v any vector q a quandrant number (0,1,2 or 3)
Returns
'true' if v lies in quadrant number q, 'false' otherwise

## ◆ removingStep()

template<typename TIterator , typename TInteger , int connectivity>
private

Removing step

Parameters
Returns
'false' if the underlying digital curve is detected as disconnected and 'true' otherwise
Template Parameters
details::DSSDecorator details::DSSDecorator4ConvexParts details::DSSDecorator4ConcaveParts

## ◆ selfDisplay()

template<typename TIterator , typename TInteger , int connectivity>
 void DGtal::FP< TIterator, TInteger, connectivity >::selfDisplay ( std::ostream & out ) const

Writes/Displays the object on an output stream.

Parameters
 out the output stream where the object is written.

## ◆ size()

template<typename TIterator , typename TInteger , int connectivity>
 Polygon::size_type DGtal::FP< TIterator, TInteger, connectivity >::size ( ) const
Returns
number of FP vertices

## ◆ myPolygon

template<typename TIterator , typename TInteger , int connectivity>
 Polygon DGtal::FP< TIterator, TInteger, connectivity >::myPolygon
private

List where each vertex of the FP is stored

Definition at line 379 of file FP.h.

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