DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
231  bool
233  Quotient & nb,
234  Vector2I & startPos,
235  Integer posA, Integer posB,
236  bool reversed = false ) const;
237 
238  // ----------------------- Interface --------------------------------------
239  public:
240 
245  void selfDisplay ( std::ostream & out ) const;
246 
251  bool isValid() const;
252 
253  // ------------------------- Protected Datas ------------------------------
254  private:
255  // ------------------------- Private Datas --------------------------------
256  private:
257 
260 
261  // ------------------------- Hidden services ------------------------------
262  protected:
263 
264  // ------------------------- Internals ------------------------------------
265  private:
266 
267  }; // end of class Pattern
268 
269 
276  template <typename TFraction>
277  std::ostream&
278  operator<< ( std::ostream & out, const Pattern<TFraction> & object );
279 
280 } // namespace DGtal
281 
282 
284 // Includes inline functions.
285 #include "DGtal/arithmetic/Pattern.ih"
286 
287 // //
289 
290 #endif // !defined Pattern_h
291 
292 #undef Pattern_RECURSES
293 #endif // else defined(Pattern_RECURSES)