DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::Pattern< TFraction > Class Template Reference

Aim: This class represents a pattern, i.e. the path between two consecutive upper leaning points on a digital straight line. More...

#include <DGtal/arithmetic/Pattern.h>

Inheritance diagram for DGtal::Pattern< TFraction >:
[legend]

Public Types

typedef TFraction Fraction
 
typedef Pattern< TFraction > Self
 
typedef Fraction::Integer Integer
 
typedef Fraction::Quotient Quotient
 
typedef IntegerComputer< IntegerIC
 
typedef IC::Point2I Point2I
 
typedef IC::Vector2I Vector2I
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CPositiveIrreducibleFraction< Fraction >))
 
 ~Pattern ()
 
 Pattern (Fraction f=Fraction(0))
 
 Pattern (Integer p, Integer q)
 
 Pattern (const Pattern &other)
 
Patternoperator= (const Pattern &other)
 
std::string rE () const
 
std::string rEs (const std::string &seps="(|)") const
 
Fraction slope () const
 
Integer length () const
 
Integer posU (Quotient k) const
 
Integer posL (Quotient k) const
 
Point2I U (Quotient k) const
 
Point2I L (Quotient k) const
 
Vector2I bezout () const
 
Vector2I v () const
 
Pattern previousPattern () const
 
bool getSmallestCoveringSubpattern (Pattern &subpattern, Quotient &nb, Vector2I &startPos, Integer posA, Integer posB, bool reversed=false) const
 
bool getGreatestIncludedSubpattern (Pattern &subpattern, Quotient &nb, Vector2I &startPos, Integer posA, Integer posB, bool reversed=false) const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Attributes

Fraction mySlope
 The fraction that characterizes the slope of the pattern.
 

Detailed Description

template<typename TFraction>
class DGtal::Pattern< TFraction >

Aim: This class represents a pattern, i.e. the path between two consecutive upper leaning points on a digital straight line.

Description of template class 'Pattern'

A pattern is characterized by an irreducible fraction. The choice here is to use SternBrocot::Fraction so as to compute efficiently subpatterns.

Template Parameters
TFractionthe type chosen to represent fractions, a model of CPositiveIrreducibleFraction. You may use SternBrocot::Fraction or LighterSternBrocot::Fraction for instance.
Note
LighterSternBrocot::Fraction takes much less memory than SternBrocot::Fraction and is more efficient for large integers. It is 10% slower than SternBrocot::Fraction for small integers (<1000).
See also
dgtal_digstraighness_sec2
Examples
arithmetic/pattern.cpp.

Definition at line 78 of file Pattern.h.

Member Typedef Documentation

◆ Fraction

template<typename TFraction >
typedef TFraction DGtal::Pattern< TFraction >::Fraction

Definition at line 81 of file Pattern.h.

◆ IC

template<typename TFraction >
typedef IntegerComputer<Integer> DGtal::Pattern< TFraction >::IC

Definition at line 93 of file Pattern.h.

◆ Integer

template<typename TFraction >
typedef Fraction::Integer DGtal::Pattern< TFraction >::Integer

Definition at line 85 of file Pattern.h.

◆ Point2I

template<typename TFraction >
typedef IC::Point2I DGtal::Pattern< TFraction >::Point2I

Definition at line 94 of file Pattern.h.

◆ Quotient

template<typename TFraction >
typedef Fraction::Quotient DGtal::Pattern< TFraction >::Quotient

Definition at line 86 of file Pattern.h.

◆ Self

template<typename TFraction >
typedef Pattern<TFraction> DGtal::Pattern< TFraction >::Self

Definition at line 84 of file Pattern.h.

◆ Vector2I

template<typename TFraction >
typedef IC::Vector2I DGtal::Pattern< TFraction >::Vector2I

Definition at line 95 of file Pattern.h.

Constructor & Destructor Documentation

◆ ~Pattern()

template<typename TFraction >
DGtal::Pattern< TFraction >::~Pattern ( )

Destructor.

◆ Pattern() [1/3]

template<typename TFraction >
DGtal::Pattern< TFraction >::Pattern ( Fraction f = Fraction(0))

Constructor from fraction.

Parameters
fany fraction (default is null pattern).

◆ Pattern() [2/3]

template<typename TFraction >
DGtal::Pattern< TFraction >::Pattern ( Integer p,
Integer q )

Constructor from numerator / denominator.

Parameters
pthe numerator.
qthe denominator.

◆ Pattern() [3/3]

template<typename TFraction >
DGtal::Pattern< TFraction >::Pattern ( const Pattern< TFraction > & other)

Copy constructor.

Parameters
otherthe object to clone.

Member Function Documentation

◆ bezout()

template<typename TFraction >
Vector2I DGtal::Pattern< TFraction >::bezout ( ) const
Returns
the Bezout vector for the pattern, such that bezout() is oriented in the first quadrant, slightly to the left of the slope, and shorter.

◆ BOOST_CONCEPT_ASSERT()

template<typename TFraction >
DGtal::Pattern< TFraction >::BOOST_CONCEPT_ASSERT ( (concepts::CPositiveIrreducibleFraction< Fraction >) )

◆ getGreatestIncludedSubpattern()

template<typename TFraction >
bool DGtal::Pattern< TFraction >::getGreatestIncludedSubpattern ( Pattern< TFraction > & subpattern,
Quotient & nb,
Vector2I & startPos,
Integer posA,
Integer posB,
bool reversed = false ) const

Computes the greatest subpattern that is included in the segment [A,B], a subpart of the pattern. Points A and B are defined by their position with respect to the beginning of this pattern. The subpattern has a starting position startPos and may be repeated nb times.

Parameters
subpattern(returns) the subpattern (a pattern that is some ascendant of 'this' in the Stern-Brocot tree).
nb(returns) the number of times subpattern is repeated so as to be included in [A,B]
startPos(returns) the starting position of the subpattern in this pattern.
posAthe position of A (number of steps till A).
posBthe position of B (number of steps till B), > posA.
reversedwhen 'false' assume a usual pattern, otherwise assume a reversed pattern (i.e. a path between two lower leaning points). In this case, all positions are relative to the first lower leaning point L(0). Everything returned correspond to reversed pattern(s).
Returns
'true' iff the subpattern is not null.

◆ getSmallestCoveringSubpattern()

template<typename TFraction >
bool DGtal::Pattern< TFraction >::getSmallestCoveringSubpattern ( Pattern< TFraction > & subpattern,
Quotient & nb,
Vector2I & startPos,
Integer posA,
Integer posB,
bool reversed = false ) const

Computes the smallest subpattern that contains the segment [A,B] included in the pattern. Points A and B are defined by their position with respect to the beginning of this pattern. The subpattern has a starting position startPos and may be repeated nb times.

Parameters
subpattern(returns) the subpattern (a pattern that is some ascendant of 'this' in the Stern-Brocot tree).
nb(returns) the number of times subpattern is repeated so as to cover [A,B]
startPos(returns) the starting position of the subpattern in this pattern.
posAthe position of A (number of steps till A).
posBthe position of B (number of steps till B), > posA.
reversedwhen 'false' assume a usual pattern, otherwise assume a reversed pattern (i.e. a path between two lower leaning points). In this case, all positions are relative to the first lower leaning point L(0). Everything returned correspond to reversed pattern(s).
Returns
'true' iff the subpattern is different from 'this'.

◆ isValid()

template<typename TFraction >
bool DGtal::Pattern< TFraction >::isValid ( ) const

Checks the validity/consistency of the object.

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

◆ L()

template<typename TFraction >
Point2I DGtal::Pattern< TFraction >::L ( Quotient k) const
Returns
the coordinates of the k-th lower leaning point,
Parameters
kits index ( L( 0 ) is between U( 0 ) and U( 1 ) ).

◆ length()

template<typename TFraction >
Integer DGtal::Pattern< TFraction >::length ( ) const
Returns
the digital length of the pattern, i.e. slope.p() + slope.q().

◆ operator=()

template<typename TFraction >
Pattern & DGtal::Pattern< TFraction >::operator= ( const Pattern< TFraction > & other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ posL()

template<typename TFraction >
Integer DGtal::Pattern< TFraction >::posL ( Quotient k) const
Returns
the position of the k-th lower leaning point,
Parameters
kits index ( posU( 0 ) <= posL( 0 ) < posU( 1 ) ).

◆ posU()

template<typename TFraction >
Integer DGtal::Pattern< TFraction >::posU ( Quotient k) const
Returns
the position of the k-th upper leaning point,
Parameters
kits index ( posU( 0 ) == 0 ).

◆ previousPattern()

template<typename TFraction >
Pattern DGtal::Pattern< TFraction >::previousPattern ( ) const
Returns
the pattern of slope z_{n-1} if z_n was the slope of 'this'.

Referenced by testTrivial().

◆ rE()

template<typename TFraction >
std::string DGtal::Pattern< TFraction >::rE ( ) const

The recursive mapping E, which gives the corresponding Christoffel word in {0,1}.

Referenced by testTrivial().

◆ rEs()

template<typename TFraction >
std::string DGtal::Pattern< TFraction >::rEs ( const std::string & seps = "(|)") const

The recursive mapping E, which gives the corresponding Christoffel word in {0,1}, but also shows the Berstel splits with "(|)".

Parameters
sepsthe three separators.

◆ selfDisplay()

template<typename TFraction >
void DGtal::Pattern< TFraction >::selfDisplay ( std::ostream & out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ slope()

template<typename TFraction >
Fraction DGtal::Pattern< TFraction >::slope ( ) const
Returns
the slope of this pattern, an irreducible fraction

Referenced by testTrivial().

◆ U()

template<typename TFraction >
Point2I DGtal::Pattern< TFraction >::U ( Quotient k) const
Returns
the coordinates of the k-th upper leaning point,
Parameters
kits index ( U( 0 ) == (0,0) ).

◆ v()

template<typename TFraction >
Vector2I DGtal::Pattern< TFraction >::v ( ) const
Returns
the vector for the pattern, ie ( slope().q(), slope().p() )

Field Documentation

◆ mySlope

template<typename TFraction >
Fraction DGtal::Pattern< TFraction >::mySlope
private

The fraction that characterizes the slope of the pattern.

Definition at line 265 of file Pattern.h.


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