DGtal  0.9.2
Pattern.h
1 
17 #pragma once
18 
31 #if defined(Pattern_RECURSES)
32 #error Recursive header files inclusion detected in Pattern.h
33 #else // defined(Pattern_RECURSES)
34 
35 #define Pattern_RECURSES
36 
37 #if !defined Pattern_h
38 
39 #define Pattern_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <string>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/arithmetic/CPositiveIrreducibleFraction.h"
47 #include "DGtal/arithmetic/IntegerComputer.h"
48 #include "DGtal/arithmetic/SternBrocot.h"
50 
51 namespace DGtal
52 {
53 
55  // template class Pattern
77  template <typename TFraction>
78  class Pattern
79  {
80  public:
81  typedef TFraction Fraction;
83 
85  typedef typename Fraction::Integer Integer;
86  typedef typename Fraction::Quotient Quotient;
87 
88  // BOOST_CONCEPT_ASSERT(( CInteger< Quotient > ));
89 
90  // ----------------------- associated types ------------------------------
91  public:
92 
94  typedef typename IC::Point2I Point2I;
95  typedef typename IC::Vector2I Vector2I;
96 
97  // ----------------------- Standard services ------------------------------
98  public:
99 
103  ~Pattern();
104 
109  Pattern( Fraction f = Fraction( 0 ) );
110 
116  Pattern( Integer p, Integer q );
117 
122  Pattern ( const Pattern & other );
123 
129  Pattern & operator= ( const Pattern & other );
130 
131  // ----------------------- Pattern services -------------------------------
132  public:
133 
136  std::string rE() const;
137 
141  std::string rEs( const std::string & seps = "(|)" ) const;
142 
144  Fraction slope() const;
145 
147  Integer length() const;
148 
151  Integer posU( Quotient k ) const;
152 
155  Integer posL( Quotient k ) const;
156 
159  Point2I U( Quotient k ) const;
160 
163  Point2I L( Quotient k ) const;
164 
168  Vector2I bezout() const;
170  Vector2I v() const;
171 
173  Pattern previousPattern() const;
174 
175 
203  bool
205  Quotient & nb,
206  Vector2I & startPos,
207  Integer posA, Integer posB,
208  bool reversed = false ) const;
209 
237  bool
239  Quotient & nb,
240  Vector2I & startPos,
241  Integer posA, Integer posB,
242  bool reversed = false ) const;
243 
244  // ----------------------- Interface --------------------------------------
245  public:
246 
251  void selfDisplay ( std::ostream & out ) const;
252 
257  bool isValid() const;
258 
259  // ------------------------- Protected Datas ------------------------------
260  private:
261  // ------------------------- Private Datas --------------------------------
262  private:
263 
265  Fraction mySlope;
266 
267  // ------------------------- Hidden services ------------------------------
268  protected:
269 
270  // ------------------------- Internals ------------------------------------
271  private:
272 
273  }; // end of class Pattern
274 
275 
282  template <typename TFraction>
283  std::ostream&
284  operator<< ( std::ostream & out, const Pattern<TFraction> & object );
285 
286 } // namespace DGtal
287 
288 
290 // Includes inline functions.
291 #include "DGtal/arithmetic/Pattern.ih"
292 
293 // //
295 
296 #endif // !defined Pattern_h
297 
298 #undef Pattern_RECURSES
299 #endif // else defined(Pattern_RECURSES)
Fraction::Quotient Quotient
Definition: Pattern.h:86
bool getSmallestCoveringSubpattern(Pattern &subpattern, Quotient &nb, Vector2I &startPos, Integer posA, Integer posB, bool reversed=false) const
Integer length() const
IC::Point2I Point2I
Definition: Pattern.h:94
Pattern< TFraction > Self
Definition: Pattern.h:84
std::string rE() const
TFraction Fraction
Definition: Pattern.h:81
Vector2I v() const
SpaceND< 2, Integer >::Point Point2I
Fraction slope() const
Aim: This class represents a pattern, i.e. the path between two consecutive upper leaning points on a...
Definition: Pattern.h:78
Pattern & operator=(const Pattern &other)
Point2I L(Quotient k) const
Fraction::Integer Integer
Definition: Pattern.h:85
bool getGreatestIncludedSubpattern(Pattern &subpattern, Quotient &nb, Vector2I &startPos, Integer posA, Integer posB, bool reversed=false) const
Aim: Defines positive irreducible fractions, i.e. fraction p/q, p and q non-negative integers...
IntegerComputer< Integer > IC
Definition: Pattern.h:93
Point2I U(Quotient k) const
Fraction mySlope
The fraction that characterizes the slope of the pattern.
Definition: Pattern.h:265
std::string rEs(const std::string &seps="(|)") const
Integer posL(Quotient k) const
BOOST_CONCEPT_ASSERT((concepts::CPositiveIrreducibleFraction< Fraction >))
IC::Vector2I Vector2I
Definition: Pattern.h:95
DGtal is the top-level namespace which contains all DGtal functions and types.
Integer posU(Quotient k) const
Vector2I bezout() const
Pattern(Fraction f=Fraction(0))
void selfDisplay(std::ostream &out) const
bool isValid() const
Pattern previousPattern() const
SpaceND< 2, Integer >::Vector Vector2I