DGtal  1.3.beta
StandardDSLQ0.h
1 
17 #pragma once
18 
33 #if defined(StandardDSLQ0_RECURSES)
34 #error Recursive header files inclusion detected in StandardDSLQ0.h
35 #else // defined(StandardDSLQ0_RECURSES)
36 
37 #define StandardDSLQ0_RECURSES
38 
39 #if !defined StandardDSLQ0_h
40 
41 #define StandardDSLQ0_h
42 
44 // Inclusions
45 #include <iostream>
46 #include "DGtal/base/Common.h"
47 #include "DGtal/base/ConstAlias.h"
48 #include "DGtal/arithmetic/IntegerComputer.h"
49 #include "DGtal/arithmetic/Pattern.h"
51 
52 namespace DGtal
53 {
54 
56  // template class StandardDSLQ0
78  template <typename TFraction>
80  {
81  // ----------------------- Standard types ------------------------------
82  public:
83  typedef TFraction Fraction;
85  typedef typename Fraction::Integer Integer;
86  typedef typename Fraction::UnsignedInteger UnsignedInteger;
87  typedef typename Fraction::Quotient Quotient;
88 
89  // BOOST_CONCEPT_ASSERT(( CFraction<Fraction> ));
90 
93  typedef typename IC::Vector2I Vector2I;
94  typedef typename IC::Point2I Point2I;
95 
96  // Model of concepts::CPointPredicate
97  typedef typename IC::Point2I Point;
98 
110  struct ConstIterator {
112  typedef Point Value;
113 
114  // stl iterator types.
115  typedef std::forward_iterator_tag iterator_category;
116  typedef Point value_type;
117  typedef std::ptrdiff_t difference_type;
118  typedef const Point* pointer;
119  typedef const Point& reference;
120 
121  inline ConstIterator()
122  : myPtrDSL( 0 )
123  {}
125  const Point & p )
126  : myPtrDSL( & myDSL ), myP( p )
127  {}
128  inline ConstIterator( const Self & other )
129  : myPtrDSL( other.myPtrDSL ), myP( other.myP )
130  {}
131  inline Self& operator=( const Self & other )
132  {
133  if ( this != &other )
134  {
135  myPtrDSL = other.myPtrDSL;
136  myP = other.myP;
137  }
138  return *this;
139  }
140 
141  inline reference operator*() const
142  {
143  ASSERT( myPtrDSL != 0 );
144  return myP;
145  }
146 
147  inline pointer operator->() const
148  {
149  ASSERT( myPtrDSL != 0 );
150  return &myP;
151  }
152 
153  inline Self& operator++()
154  {
155  Integer rem = myPtrDSL->r( myP );
156  if ( rem - myPtrDSL->b() >= myPtrDSL->mu() )
157  ++myP[ 1 ]; // +y;
158  else
159  ++myP[ 0 ]; // +x;
160  return *this;
161  }
162 
163  inline
164  Self
166  {
167  Self __tmp = *this;
168  this->operator++();
169  return __tmp;
170  }
171 
172  inline
173  bool operator==( const Self & other ) const
174  {
175  ASSERT( myPtrDSL == other.myPtrDSL );
176  return myP == other.myP;
177  }
178 
179  inline
180  bool operator!=( const Self & other ) const
181  {
182  return ! ( this->operator==( other ) );
183  }
184 
185 
186  private:
189 
190  };
191  // ----------------------- Standard services ------------------------------
192  public:
193 
197  ~StandardDSLQ0();
198 
202  StandardDSLQ0();
203 
208  StandardDSLQ0 ( const StandardDSLQ0 & other );
209 
215  StandardDSLQ0 & operator= ( const StandardDSLQ0 & other );
216 
222  StandardDSLQ0( Fraction aSlope, IntegerParamType aMu );
223 
231  IntegerParamType mu1 );
232 
235  bool operator()( const Point & p ) const;
236 
238  Fraction slope() const;
239 
242  const Integer & mu() const;
243 
245  Integer mup() const;
246 
248  Integer a() const;
250  Integer b() const;
252  Vector2I v() const;
253 
256  ConstIterator begin( Point p ) const;
257 
260  ConstIterator end( Point p ) const;
261 
263  const Pattern<Fraction> & pattern() const;
264 
268  Integer r( const Point & p ) const;
269 
272  Point U() const;
275  Point L() const;
276 
279  Point lowestY( IntegerParamType x ) const;
282  Point uppermostY( IntegerParamType x ) const;
285  Point lowestX( IntegerParamType y ) const;
288  Point uppermostX( IntegerParamType y ) const;
289 
291  bool before( const Point & p1, const Point & p2 ) const;
293  bool beforeOrEqual( const Point & p1, const Point & p2 ) const;
294 
295 
309  Self reversedSmartDSS( const Point & A, const Point & B ) const;
310 
328  const Point & A, const Point & B ) const;
329 
343  const Point & A, const Point & B ) const;
344 
345 
359  Self smartDSS( const Point & A, const Point & B ) const;
360 
361  // ----------------------- Interface --------------------------------------
362  public:
363 
368  void selfDisplay ( std::ostream & out ) const;
369 
374  bool isValid() const;
375 
376  // ------------------------- Protected Datas ------------------------------
377  protected:
382 
383  // ------------------------- Private Datas --------------------------------
384  private:
387 
388  // ------------------------- Hidden services ------------------------------
389  protected:
390 
391  // ------------------------- Internals ------------------------------------
392  private:
393  static Fraction deepest( Fraction f1, Fraction f2, Fraction f3 );
394  static Fraction deepest( Fraction f1, Fraction f2 );
395  }; // end of class StandardDSLQ0
396 
397 
404  template <typename TFraction>
405  std::ostream&
406  operator<< ( std::ostream & out, const StandardDSLQ0<TFraction> & object );
407 
408 } // namespace DGtal
409 
410 
412 // Includes inline functions.
413 #include "DGtal/arithmetic/StandardDSLQ0.ih"
414 
415 // //
417 
418 #endif // !defined StandardDSLQ0_h
419 
420 #undef StandardDSLQ0_RECURSES
421 #endif // else defined(StandardDSLQ0_RECURSES)
DGtal::StandardDSLQ0::ConstIterator::difference_type
std::ptrdiff_t difference_type
Definition: StandardDSLQ0.h:117
DGtal::StandardDSLQ0::ic
IC ic
Used in some computations.
Definition: StandardDSLQ0.h:386
DGtal::StandardDSLQ0::ConstIterator::ConstIterator
ConstIterator(const Self &other)
Definition: StandardDSLQ0.h:128
DGtal::StandardDSLQ0::before
bool before(const Point &p1, const Point &p2) const
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
DGtal::StandardDSLQ0::begin
ConstIterator begin(Point p) const
DGtal::StandardDSLQ0::ConstIterator::reference
const typedef Point & reference
Definition: StandardDSLQ0.h:119
DGtal::StandardDSLQ0::beforeOrEqual
bool beforeOrEqual(const Point &p1, const Point &p2) const
DGtal::StandardDSLQ0::operator()
bool operator()(const Point &p) const
DGtal::StandardDSLQ0::ConstIterator::pointer
const typedef Point * pointer
Definition: StandardDSLQ0.h:118
DGtal::StandardDSLQ0::r
Integer r(const Point &p) const
DGtal::StandardDSLQ0::~StandardDSLQ0
~StandardDSLQ0()
DGtal::StandardDSLQ0::ConstIterator::operator=
Self & operator=(const Self &other)
Definition: StandardDSLQ0.h:131
DGtal::IntegerComputer< Integer >
DGtal::StandardDSLQ0::ConstIterator::operator*
reference operator*() const
Definition: StandardDSLQ0.h:141
DGtal::StandardDSLQ0
Aim: Represents a digital straight line with slope in the first quadrant (Q0: x >= 0,...
Definition: StandardDSLQ0.h:79
DGtal::StandardDSLQ0::pattern
const Pattern< Fraction > & pattern() const
DGtal::StandardDSLQ0::uppermostY
Point uppermostY(IntegerParamType x) const
DGtal::StandardDSLQ0::ConstIterator::operator++
Self operator++(int)
Definition: StandardDSLQ0.h:165
DGtal::StandardDSLQ0::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::StandardDSLQ0::Self
StandardDSLQ0< TFraction > Self
Definition: StandardDSLQ0.h:84
DGtal::StandardDSLQ0::DSSWithinTwoPatterns
Self DSSWithinTwoPatterns(Point U1, Point U2, const Point &A, const Point &B) const
DGtal::StandardDSLQ0::ConstIterator::ConstIterator
ConstIterator()
Definition: StandardDSLQ0.h:121
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::StandardDSLQ0::UnsignedInteger
Fraction::UnsignedInteger UnsignedInteger
Definition: StandardDSLQ0.h:86
DGtal::StandardDSLQ0::slope
Fraction slope() const
DGtal::StandardDSLQ0::L
Point L() const
DGtal::StandardDSLQ0::b
Integer b() const
DGtal::StandardDSLQ0::ConstIterator::ConstIterator
ConstIterator(ConstAlias< StandardDSLQ0< TFraction > > myDSL, const Point &p)
Definition: StandardDSLQ0.h:124
DGtal::StandardDSLQ0::IC
IntegerComputer< Integer > IC
Definition: StandardDSLQ0.h:91
DGtal::StandardDSLQ0::ConstIterator::operator++
Self & operator++()
Definition: StandardDSLQ0.h:153
DGtal::StandardDSLQ0::lowestX
Point lowestX(IntegerParamType y) const
DGtal::StandardDSLQ0::Vector2I
IC::Vector2I Vector2I
Definition: StandardDSLQ0.h:93
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::StandardDSLQ0::ConstIterator::value_type
Point value_type
Definition: StandardDSLQ0.h:116
DGtal::IntegerComputer< Integer >::Vector2I
SpaceND< 2, Integer >::Vector Vector2I
Definition: IntegerComputer.h:94
DGtal::StandardDSLQ0::end
ConstIterator end(Point p) const
DGtal::StandardDSLQ0::StandardDSLQ0
StandardDSLQ0()
DGtal::StandardDSLQ0::myPattern
Pattern< Fraction > myPattern
the characteristic pattern of this DSL.
Definition: StandardDSLQ0.h:379
DGtal::StandardDSLQ0::Quotient
Fraction::Quotient Quotient
Definition: StandardDSLQ0.h:87
DGtal::StandardDSLQ0::Fraction
TFraction Fraction
Definition: StandardDSLQ0.h:83
DGtal::StandardDSLQ0::ConstIterator::operator->
pointer operator->() const
Definition: StandardDSLQ0.h:147
DGtal::StandardDSLQ0::ConstIterator::operator==
bool operator==(const Self &other) const
Definition: StandardDSLQ0.h:173
DGtal::StandardDSLQ0::lowestY
Point lowestY(IntegerParamType x) const
DGtal::StandardDSLQ0::ConstIterator::operator!=
bool operator!=(const Self &other) const
Definition: StandardDSLQ0.h:180
DGtal::StandardDSLQ0::uppermostX
Point uppermostX(IntegerParamType y) const
DGtal::StandardDSLQ0::ConstIterator::myP
Point myP
Definition: StandardDSLQ0.h:188
DGtal::StandardDSLQ0::mup
Integer mup() const
Integer
Point::Coordinate Integer
Definition: examplePlaneProbingParallelepipedEstimator.cpp:44
DGtal::StandardDSLQ0::ConstIterator
Definition: StandardDSLQ0.h:110
DGtal::StandardDSLQ0::ConstIterator::myPtrDSL
const StandardDSLQ0< TFraction > * myPtrDSL
Definition: StandardDSLQ0.h:187
DGtal::StandardDSLQ0::ConstIterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: StandardDSLQ0.h:115
DGtal::StandardDSLQ0::myMu
Integer myMu
the shift to origin.
Definition: StandardDSLQ0.h:381
DGtal::StandardDSLQ0::ConstIterator::Value
Point Value
Definition: StandardDSLQ0.h:112
DGtal::StandardDSLQ0::IntegerParamType
IC::IntegerParamType IntegerParamType
Definition: StandardDSLQ0.h:92
DGtal::IntegerComputer< Integer >::IntegerParamType
NumberTraits< Integer >::ParamType IntegerParamType
Definition: IntegerComputer.h:88
DGtal::StandardDSLQ0::isValid
bool isValid() const
DGtal::StandardDSLQ0::Point2I
IC::Point2I Point2I
Definition: StandardDSLQ0.h:94
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::StandardDSLQ0::ConstIterator::Self
ConstIterator Self
Definition: StandardDSLQ0.h:111
DGtal::Pattern< Fraction >
DGtal::IntegerComputer< Integer >::Point2I
SpaceND< 2, Integer >::Point Point2I
Definition: IntegerComputer.h:93
DGtal::StandardDSLQ0::deepest
static Fraction deepest(Fraction f1, Fraction f2, Fraction f3)
DGtal::StandardDSLQ0::Integer
Fraction::Integer Integer
Definition: StandardDSLQ0.h:85
DGtal::StandardDSLQ0::Point
IC::Point2I Point
Definition: StandardDSLQ0.h:97
DGtal::StandardDSLQ0::reversedSmartDSS
Self reversedSmartDSS(const Point &A, const Point &B) const
DGtal::StandardDSLQ0::operator=
StandardDSLQ0 & operator=(const StandardDSLQ0 &other)
DGtal::StandardDSLQ0::smartDSS
Self smartDSS(const Point &A, const Point &B) const
DGtal::StandardDSLQ0::U
Point U() const
DGtal::StandardDSLQ0::mu
const Integer & mu() const
DGtal::StandardDSLQ0::v
Vector2I v() const
DGtal::StandardDSLQ0::a
Integer a() const