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>
|
| BOOST_CONCEPT_ASSERT ((concepts::CPositiveIrreducibleFraction< Fraction >)) |
|
| ~Pattern () |
|
| Pattern (Fraction f=Fraction(0)) |
|
| Pattern (Integer p, Integer q) |
|
| Pattern (const Pattern &other) |
|
Pattern & | operator= (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 |
|
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
-
- 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.
◆ Fraction
template<typename TFraction >
◆ IC
template<typename TFraction >
◆ Integer
template<typename TFraction >
◆ Point2I
template<typename TFraction >
◆ Quotient
template<typename TFraction >
◆ Self
template<typename TFraction >
◆ Vector2I
template<typename TFraction >
◆ ~Pattern()
template<typename TFraction >
◆ Pattern() [1/3]
template<typename TFraction >
Constructor from fraction.
- Parameters
-
f | any fraction (default is null pattern). |
◆ Pattern() [2/3]
template<typename TFraction >
Constructor from numerator / denominator.
- Parameters
-
p | the numerator. |
q | the denominator. |
◆ Pattern() [3/3]
template<typename TFraction >
Copy constructor.
- Parameters
-
other | the object to clone. |
◆ bezout()
template<typename TFraction >
- 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 >
◆ getGreatestIncludedSubpattern()
template<typename TFraction >
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. |
posA | the position of A (number of steps till A). |
posB | the position of B (number of steps till B), > posA. |
reversed | when '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 >
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. |
posA | the position of A (number of steps till A). |
posB | the position of B (number of steps till B), > posA. |
reversed | when '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 >
Checks the validity/consistency of the object.
- Returns
- 'true' if the object is valid, 'false' otherwise.
◆ L()
template<typename TFraction >
- Returns
- the coordinates of the k-th lower leaning point,
- Parameters
-
k | its index ( L( 0 ) is between U( 0 ) and U( 1 ) ). |
◆ length()
template<typename TFraction >
- Returns
- the digital length of the pattern, i.e. slope.p() + slope.q().
◆ operator=()
template<typename TFraction >
Assignment.
- Parameters
-
- Returns
- a reference on 'this'.
◆ posL()
template<typename TFraction >
- Returns
- the position of the k-th lower leaning point,
- Parameters
-
k | its index ( posU( 0 ) <= posL( 0 ) < posU( 1 ) ). |
◆ posU()
template<typename TFraction >
- Returns
- the position of the k-th upper leaning point,
- Parameters
-
k | its index ( posU( 0 ) == 0 ). |
◆ previousPattern()
template<typename TFraction >
- Returns
- the pattern of slope z_{n-1} if z_n was the slope of 'this'.
Referenced by testTrivial().
◆ rE()
template<typename TFraction >
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
-
seps | the three separators. |
◆ selfDisplay()
template<typename TFraction >
void DGtal::Pattern< TFraction >::selfDisplay |
( |
std::ostream & | out | ) |
const |
Writes/Displays the object on an output stream.
- Parameters
-
out | the output stream where the object is written. |
◆ slope()
template<typename TFraction >
- Returns
- the slope of this pattern, an irreducible fraction
Referenced by testTrivial().
◆ U()
template<typename TFraction >
- Returns
- the coordinates of the k-th upper leaning point,
- Parameters
-
k | its index ( U( 0 ) == (0,0) ). |
◆ v()
template<typename TFraction >
◆ mySlope
template<typename TFraction >
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: