DGtal 0.3.0
Data Structures | Public Types | Public Member Functions | Protected Attributes | Private Member Functions

DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity > Class Template Reference

Aim: Dynamic recognition of a digital straight segment (DSS) defined as the sequence of simply connected points (x,y) such that mu <= ax - by < mu + omega. (see Debled and Reveilles [1995]). This class is a model of the concept CSegmentComputer. More...

#include <ArithmeticalDSS.h>

Collaboration diagram for DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >:
Collaboration graph
[legend]

Data Structures

struct  DefaultDrawStyleBB
struct  DefaultDrawStylePoints
struct  Tools
struct  Tools< TInt, 4 >

Public Types

typedef TIterator Iterator
typedef TInteger Integer
typedef DGtal::PointVector
< 2, Integer
Point
typedef DGtal::PointVector
< 2, Integer
Vector
typedef DGtal::PointVector
< 2, double > 
PointD

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CInteger< TInteger >))
 ArithmeticalDSS ()
 ArithmeticalDSS (const Iterator &it)
void init (const Iterator &it)
 ArithmeticalDSS (const ArithmeticalDSS &other)
ArithmeticalDSSoperator= (const ArithmeticalDSS &other)
bool operator== (const ArithmeticalDSS &other) const
bool operator!= (const ArithmeticalDSS &other) const
 ~ArithmeticalDSS ()
bool isExtendable (const Iterator &itf)
bool extend (const Iterator &itf)
bool extendOppositeEnd (const Iterator &itb)
bool retract ()
bool retractOppositeEnd ()
Integer getRemainder (const Iterator &it) const
Integer getRemainder (const Point &aPoint) const
bool isInDSL (const Point &aPoint) const
bool isInDSL (const Iterator &it) const
bool isInDSS (const Point &aPoint) const
bool isInDSS (const Iterator &it) const
Integer getA () const
Integer getB () const
Integer getMu () const
Integer getOmega () const
Point getUf () const
Point getUl () const
Point getLf () const
Point getLl () const
Point getBackPoint () const
Point getFrontPoint () const
bool isValid () const
PointD project (const Point &m) const
PointD project (const Point &m, double r) const
PointD project (const Point &m, const Point &p) const
double projectedSegmentLength () const
void selfDisplay (std::ostream &out)
void selfDrawAsDigitalPoints (DGtalBoard &board) const
void selfDrawAsBoundingBox (DGtalBoard &board) const
DrawableWithDGtalBoarddefaultStyle (std::string mode="") const
std::string styleName () const
void selfDraw (DGtalBoard &board) const

Protected Attributes

Integer myA
Integer myB
Integer myMu
Integer myOmega
Integer myNbUpPat
Integer myNbLowPat
Point myUf
Point myUl
Point myLf
Point myLl
Iterator myF
Iterator myL
std::vector< Vectorstep

Private Member Functions

bool extend (const Iterator &it, Iterator &lastIt, const Vector &lastMove, Point &Uf, Point &Ul, Point &Lf, Point &Ll)
bool retract (Iterator &firstIt, Iterator &lastIt, Iterator &nextIt, Point &Uf, Point &Ul, Point &Lf, Point &Ll, const Integer &s)
bool hasLessThanTwoSteps (const Vector &aStep) const
Vector vectorFrom0ToOmega () const

Detailed Description

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

Aim: Dynamic recognition of a digital straight segment (DSS) defined as the sequence of simply connected points (x,y) such that mu <= ax - by < mu + omega. (see Debled and Reveilles [1995]). This class is a model of the concept CSegmentComputer.

Description of class 'ArithmeticalDSS'

This class is templated by the typename 'TIterator', the type of an iterator on a sequence of points, the typename 'TInteger', the type of the coordinates of the points (satisfying CInteger) and by the integer 'connectivity', which may be equal to 4 for standard (4-connected) DSS or 8 for naive (8-connected) DSS. Any other integers act as 8.

Here is a short example of how to use this class:

   //type definitions: sequence of points, iterator and DSS recognition
   typedef PointVector<2,int> Point;
   typedef std::vector<Point> Sequence;
   typedef Sequence::iterator Iterator;
   typedef ArithmeticalDSS<Iterator, int, 4> DSS4;

   // Sequence of input points
   Sequence contour;
   contour.push_back(Point(0,0));
   contour.push_back(Point(1,0));
   contour.push_back(Point(2,0));
   contour.push_back(Point(3,0));
   contour.push_back(Point(3,1));
   contour.push_back(Point(4,1));
   contour.push_back(Point(5,1));
   contour.push_back(Point(5,2));

  
   // Add points while it is possible
   Iterator i = contour.begin();
   DSS4 theDSS4(i);             
   do {
   i++;
   } while ( (i!=contour.end())
   &&(theDSS4.extend(i)) );

   // Output parameters
   cout << theDSS4 << endl;

   //You must get:
   //[ArithmeticalDSS]
   //Parameters (a,b,mu,omega)=(2, 5, 0, 7)
   //Number of upper patterns: 1
   //Number of lower patterns: 0
   //First point [PointVector] {0, 0} Last point [PointVector] {5, 2}
   //Leaning points:
   //   Uf [PointVector] {0, 0}
   //   Ul [PointVector] {5, 2}
   //   Lf [PointVector] {3, 0}
   //   Ll [PointVector] {3, 0}
   //Steps:
   //   [PointVector] {1, 0}
   //   [PointVector] {0, 1}
   //[End ArithmeticalDSS]

Definition at line 126 of file ArithmeticalDSS.h.


Member Typedef Documentation

template<typename TIterator, typename TInteger, int connectivity>
typedef TInteger DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::Integer

Definition at line 138 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
typedef TIterator DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::Iterator

Definition at line 134 of file ArithmeticalDSS.h.

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

Definition at line 141 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
typedef DGtal::PointVector<2,double> DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::PointD

Definition at line 144 of file ArithmeticalDSS.h.

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

Definition at line 142 of file ArithmeticalDSS.h.


Constructor & Destructor Documentation

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

Default constructor. not valid

template<typename TIterator, typename TInteger, int connectivity>
DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::ArithmeticalDSS ( const Iterator it)

Constructor with initialisation

Parameters:
itan iterator on a sequence of points
template<typename TIterator, typename TInteger, int connectivity>
DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::ArithmeticalDSS ( const ArithmeticalDSS< TIterator, TInteger, connectivity > &  other)

Copy constructor.

Parameters:
otherthe object to clone.
template<typename TIterator, typename TInteger, int connectivity>
DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::~ArithmeticalDSS ( ) [inline]

Destructor.

Definition at line 275 of file ArithmeticalDSS.h.


Member Function Documentation

template<typename TIterator, typename TInteger, int connectivity>
DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::BOOST_CONCEPT_ASSERT ( (CInteger< TInteger >)  )
template<typename TIterator, typename TInteger, int connectivity>
DrawableWithDGtalBoard* DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::defaultStyle ( std::string  mode = "") const

Default drawing style object.

Returns:
the dyn. alloc. default style for this object.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::extend ( const Iterator it,
Iterator lastIt,
const Vector lastMove,
Point Uf,
Point Ul,
Point Lf,
Point Ll 
) [private]

Tests whether the union between a point (pointing by it) and the DSS is a DSS. Computes the parameters of the new DSS with the adding point if true.

Parameters:
itan iterator on a sequence of points
lastIt,aniterator pointing at the end of the DSS
lastMove,endshift vector of the DSS
Uf,firstupper leaning point
Ul,lastupper leaning point
Lf,firstlower leaning point
Ll,lastlower leaning point
Returns:
'true' if the union is a DSS, 'false' otherwise.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::extend ( const Iterator itf)

Tests whether the union between a point (adding to the front of the DSS with respect to the scan orientaion) and a DSS is a DSS. Computes the parameters of the new DSS with the adding point if true.

Parameters:
itfan iterator on a sequence of points
Returns:
'true' if the union is a DSS, 'false' otherwise.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::extendOppositeEnd ( const Iterator itb)

Tests whether the union between a point (adding to the back of the DSS with respect to the scan orientaion) and a DSS is a DSS. Computes the parameters of the new DSS with the adding point if true.

Parameters:
itban iterator on a sequence of points
Returns:
'true' if the union is a DSS, 'false' otherwise.
template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getA ( ) const

myA accessor

Returns:
an Integer of value myA.
template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getB ( ) const

myB accessor

Returns:
an Integer of value myB.
template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getBackPoint ( ) const

Accessor to the first added point to the DSS

Returns:
point.
template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getFrontPoint ( ) const

Accessor to the last added point to the DSS

Returns:
point.
template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getLf ( ) const

Accessor to the first lower leaning point

Returns:
first lower leaning point.
template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getLl ( ) const

Accessor to the last lower leaning point

Returns:
last lower leaning point.
template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getMu ( ) const

myMu accessor

Returns:
an Integer of value myMu.
template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getOmega ( ) const

myOmega accessor

Returns:
an Integer of value myOmega.
template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getRemainder ( const Iterator it) const

Computes the remainder of a point (that does not necessarily belong to the DSS)

Parameters:
itan iterator on a sequence of points
Returns:
the remainder.
template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getRemainder ( const Point aPoint) const

Computes the remainder of a point (that does not necessarily belong to the DSS)

Parameters:
aPointthe point whose remainder is returned
Returns:
the remainder.
template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getUf ( ) const

Accessor to the first upper leaning point

Returns:
first upper leaning point.
template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::getUl ( ) const

Accessor to the last upper leaning point

Returns:
last upper leaning point.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::hasLessThanTwoSteps ( const Vector aStep) const [private]

Checks whether the DSS has less or more than two displacement vectors (steps) between two consecutive points (must be called only in the main stage)

Parameters:
aStep,thelast displacement vector.
Returns:
'true' if less or equal, 'false' otherwise.
template<typename TIterator, typename TInteger, int connectivity>
void DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::init ( const Iterator it)

Initialisation.

Parameters:
itan iterator on a sequence of points

Referenced by testCorner().

template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::isExtendable ( const Iterator itf)

Tests whether the union between a point (adding to the front of the DSS with respect to the scan orientaion) and a DSS is a DSS.

Parameters:
itfan iterator on a sequence of points
Returns:
'true' if the union is a DSS, 'false' otherwise.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::isInDSL ( const Point aPoint) const

Checks whether a point is in the DSL of parameters (myA,myB,myMu,myOmega)

Parameters:
aPointthe point checked
Returns:
'true' if yes, 'false' otherwise
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::isInDSL ( const Iterator it) const

Checks whether a point is in the DSL of parameters (myA,myB,myMu,myOmega)

Parameters:
itan iterator on the point to be checked
Returns:
'true' if yes, 'false' otherwise
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::isInDSS ( const Iterator it) const

Checks whether a point belongs to the DSS or not

Parameters:
itan iterator on the point to be checked
Returns:
'true' if yes, 'false' otherwise
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::isInDSS ( const Point aPoint) const

Checks whether a point belongs to the DSS or not

Parameters:
aPointthe point checked
Returns:
'true' if yes, 'false' otherwise
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::isValid ( ) const

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::operator!= ( const ArithmeticalDSS< TIterator, TInteger, connectivity > &  other) const

Difference operator.

Parameters:
otherthe object to compare with.
Returns:
'false' if equal 'true' otherwise
template<typename TIterator, typename TInteger, int connectivity>
ArithmeticalDSS& DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::operator= ( const ArithmeticalDSS< TIterator, TInteger, connectivity > &  other)

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::operator== ( const ArithmeticalDSS< TIterator, TInteger, connectivity > &  other) const

Equality operator.

Parameters:
otherthe object to compare with.
Returns:
'true' either if the leaning points perfectly match or if the first leaning points match to the last ones (same DSS scanned in the reverse way) and 'false' otherwise
template<typename TIterator, typename TInteger, int connectivity>
PointD DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::project ( const Point m,
const Point p 
) const

Projects the point [m] onto the straight line going through point [p].

Parameters:
many point expressed in the local reference frame (may not be part of the segment).
pany point expressed in the local reference frame (may not be part of the segment).
Returns:
the projected point.
template<typename TIterator, typename TInteger, int connectivity>
PointD DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::project ( const Point m,
double  r 
) const

Projects the point [m] onto the straight line whose points have remainder [r].

Parameters:
many point expressed in the local reference frame (may not be part of the segment).
rthe remainder (may not be an integer).
Returns:
the projected point.
template<typename TIterator, typename TInteger, int connectivity>
PointD DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::project ( const Point m) const

Projects the point [m] onto the average straight line (ie (mu+nu)/2).

Parameters:
many point expressed in the local reference frame (may not be part of the segment).
Returns:
the projected point.
template<typename TIterator, typename TInteger, int connectivity>
double DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::projectedSegmentLength ( ) const
Returns:
the projected length of the segment.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::retract ( )

Removes the back point of a DSS (located at the back with respect to the scan orientaion) if the DSS has more than two points

Returns:
'true' if the first point is removed, 'false' otherwise.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::retract ( Iterator firstIt,
Iterator lastIt,
Iterator nextIt,
Point Uf,
Point Ul,
Point Lf,
Point Ll,
const Integer s 
) [private]

Removes the end point of a DSS (pointing by firstIt)

Parameters:
firstIt,aniterator pointing at the end of the DSS
lastIt,aniterator pointing at the other end of the DSS
nextIt,aniterator pointing at the point following the one pointing by firstIt
Uf,firstupper leaning point
Ul,lastupper leaning point
Lf,firstlower leaning point
Ll,lastlower leaning point
s,asigned integer equal to 1 or -1
Returns:
'true'.
template<typename TIterator, typename TInteger, int connectivity>
bool DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::retractOppositeEnd ( )

Removes the front point of a DSS (located at the front with respect to the scan orientaion) if the DSS has more than two points

Returns:
'true' if the first point is removed, 'false' otherwise.
template<typename TIterator, typename TInteger, int connectivity>
void DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::selfDisplay ( std::ostream &  out)

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.
template<typename TIterator, typename TInteger, int connectivity>
void DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::selfDraw ( DGtalBoard board) const

Draw the DSS on a LiBoard board as its bounding box and the polyline of its points

See also:
BoundingBoxDraw
DigitalPointsDraw
Parameters:
boardthe output board where the object is drawn.
template<typename TIterator, typename TInteger, int connectivity>
void DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::selfDrawAsBoundingBox ( DGtalBoard board) const

Draw the bounding box of the DSS on a LiBoard board

Parameters:
boardthe output board where the object is drawn.
Template Parameters:
Functora Functor to specialize the Board style
template<typename TIterator, typename TInteger, int connectivity>
void DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::selfDrawAsDigitalPoints ( DGtalBoard board) const

Draw the digital points of the DSS linked into a polygonal line on a LiBoard board

Parameters:
boardthe output board where the object is drawn.
Template Parameters:
Functora Functor to specialize the Board style
template<typename TIterator, typename TInteger, int connectivity>
std::string DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::styleName ( ) const
Returns:
the style name used for drawing this object.
template<typename TIterator, typename TInteger, int connectivity>
Vector DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::vectorFrom0ToOmega ( ) const [private]

Returns the 2D vector starting at a point of remainder 0 and pointing at the closer point of remainder omega

Returns:
the 2D vector.

Field Documentation

template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myA [protected]

Definition at line 576 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myB [protected]

Definition at line 576 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Iterator DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myF [protected]

Definition at line 584 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Iterator DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myL [protected]

Definition at line 584 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myLf [protected]

Definition at line 581 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myLl [protected]

Definition at line 581 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myMu [protected]

Definition at line 576 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myNbLowPat [protected]

Definition at line 578 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myNbUpPat [protected]

Definition at line 578 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Integer DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myOmega [protected]

Definition at line 576 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myUf [protected]

Definition at line 581 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
Point DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::myUl [protected]

Definition at line 581 of file ArithmeticalDSS.h.

template<typename TIterator, typename TInteger, int connectivity>
std::vector<Vector> DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::step [protected]

Definition at line 588 of file ArithmeticalDSS.h.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines