DGtal  1.4.beta
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)
35 #define Pattern_RECURSES
36 
37 #if !defined Pattern_h
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 
104 
109  Pattern( Fraction f = Fraction( 0 ) );
110 
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 
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 
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)
SpaceND< 2, Integer >::Vector Vector2I
SpaceND< 2, Integer >::Point Point2I
Aim: This class represents a pattern, i.e. the path between two consecutive upper leaning points on a...
Definition: Pattern.h:79
Integer posL(Quotient k) const
Integer length() const
Fraction mySlope
The fraction that characterizes the slope of the pattern.
Definition: Pattern.h:265
Fraction slope() const
Pattern previousPattern() const
TFraction Fraction
Definition: Pattern.h:81
Fraction::Quotient Quotient
Definition: Pattern.h:86
bool isValid() const
IC::Point2I Point2I
Definition: Pattern.h:94
Vector2I v() const
Pattern & operator=(const Pattern &other)
BOOST_CONCEPT_ASSERT((concepts::CPositiveIrreducibleFraction< Fraction >))
Fraction::Integer Integer
Definition: Pattern.h:85
std::string rE() const
Point2I U(Quotient k) const
Pattern(Fraction f=Fraction(0))
void selfDisplay(std::ostream &out) const
bool getGreatestIncludedSubpattern(Pattern &subpattern, Quotient &nb, Vector2I &startPos, Integer posA, Integer posB, bool reversed=false) const
Vector2I bezout() const
IC::Vector2I Vector2I
Definition: Pattern.h:95
std::string rEs(const std::string &seps="(|)") const
IntegerComputer< Integer > IC
Definition: Pattern.h:93
Pattern(const Pattern &other)
Integer posU(Quotient k) const
Point2I L(Quotient k) const
bool getSmallestCoveringSubpattern(Pattern &subpattern, Quotient &nb, Vector2I &startPos, Integer posA, Integer posB, bool reversed=false) const
Pattern< TFraction > Self
Definition: Pattern.h:84
Pattern(Integer p, Integer q)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
Aim: Defines positive irreducible fractions, i.e. fraction p/q, p and q non-negative integers,...