DGtal  1.5.beta
ArithmeticalDSS.h
1 
17 #pragma once
18 
31 #if defined(ArithmeticalDSS_RECURSES)
32 #error Recursive header files inclusion detected in ArithmeticalDSS.h
33 #else // defined(ArithmeticalDSS_RECURSES)
35 #define ArithmeticalDSS_RECURSES
36 
37 #if !defined ArithmeticalDSS_h
39 #define ArithmeticalDSS_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/Exceptions.h"
46 
47 #include "DGtal/geometry/curves/ArithmeticalDSL.h"
48 #include "DGtal/geometry/curves/ArithmeticalDSSCheck.h"
49 #include "DGtal/geometry/curves/ArithmeticalDSSFactory.h"
50 #include "DGtal/geometry/curves/ArithmeticalDSSConvexHull.h"
51 #include "DGtal/arithmetic/SternBrocot.h"
52 #include "DGtal/math/linalg/SimpleMatrix.h"
54 
55 namespace DGtal
56 {
57 
59  // template class ArithmeticalDSS
92  template <typename TCoordinate,
93  typename TInteger = TCoordinate,
94  unsigned short adjacency = 8>
96  {
97  friend class ArithmeticalDSSFactory<TCoordinate, TInteger, adjacency>;
98 
99  // ----------------------- static members -----------------------------------
100  public:
104  static const unsigned short foregroundAdjacency = adjacency;
105 
106  // ----------------------- Inner types -----------------------------------
107  public:
108 
113  typedef TCoordinate Coordinate;
118  typedef TInteger Integer;
120 
128  typedef typename DSL::Space Space;
132  typedef typename DSL::Point Point;
136  typedef typename DSL::Vector Vector;
140  typedef typename DSL::Steps Steps;
153 
159 
160  // ----------------------- Standard services ------------------------------
161  public:
162 
169 
190  ArithmeticalDSS(const Coordinate& aA, const Coordinate& aB,
191  const Integer& aLowerBound, const Integer& aUpperBound,
192  const Point& aF, const Point& aL,
193  const Point& aUf, const Point& aUl,
194  const Point& aLf, const Point& aLl,
195  const Steps& aSteps, const Vector& aShift);
196 
212  ArithmeticalDSS(const DSL& aDSL,
213  const Point& aF, const Point& aL,
214  const Point& aUf, const Point& aUl,
215  const Point& aLf, const Point& aLl);
216 
238  ArithmeticalDSS(const Coordinate& aA, const Coordinate& aB,
239  const Point& aF, const Point& aL,
240  const Point& aUf, const Point& aUl,
241  const Point& aLf, const Point& aLl);
242 
243 
244 
245 
259  ArithmeticalDSS(const Point& aF, const Point& aL,
260  const bool& areOnTheUpperLine = true);
261 
273  ArithmeticalDSS(const DSL& aDSL, const Point& aF, const Point& aL);
274 
286  ArithmeticalDSS(const ArithmeticalDSS& aDSS, const Point& aF, const Point& aL);
287 
297  template <typename Iterator>
298  ArithmeticalDSS(const Iterator& aItb, const Iterator& aIte);
299 
304  ArithmeticalDSS ( const ArithmeticalDSS & aOther );
305 
312 
320 
327  bool equalsTo ( const ArithmeticalDSS & aOther ) const;
328 
336  bool operator== ( const ArithmeticalDSS & aOther ) const;
337 
344  bool operator!= ( const ArithmeticalDSS & aOther ) const;
345 
350 
351  // ----------------------- Interface --------------------------------------
352  public:
353 
358  void selfDisplay ( std::ostream & out ) const;
359 
366  bool isValid() const;
367 
374  const DSL& dsl() const;
375 
379  Coordinate a() const;
380 
384  Coordinate b() const;
385 
390  Integer mu() const;
391 
396  Integer omega() const;
397 
401  Vector shift() const;
406  Steps steps() const;
407 
412  Point back() const;
413 
418  Point front() const;
419 
423  Point Uf() const;
424 
428  Point Ul() const;
429 
433  Point Lf() const;
434 
438  Point Ll() const;
439 
446  Integer remainder(const Point& aPoint) const;
447 
457 
465  Position position(const Point& aPoint) const;
466 
477  bool before (const Point& aP1, const Point& aP2) const;
478 
489  bool beforeOrEqual (const Point& aP1, const Point& aP2) const;
490 
497  bool isInDSL(const Point& aPoint) const;
498 
504  bool isInDSS(const Point& aPoint) const;
505 
506  bool operator()(const Point& aPoint) const;
507 
508 
515  bool isInDSL(const DSL& aDSL) const;
516 
517 
529  bool isInDSL(const DSL& aDSL, std::vector<Point> &Ulp, std::vector<Point> &Llp, Point& outP) const;
530 
531 
532 
548 
549 
550  // ----------------------- Iterator services -------------------------------
556 
561  ConstIterator end() const;
562 
568 
574 
575  // ----------------------- Dynamic methods --------------------------------
576 
599  unsigned short int isExtendableFront( const Point& aNewPoint ) const;
600 
623  unsigned short int isExtendableBack( const Point& aNewPoint ) const;
624 
637  bool extendFront( const Point& aNewPoint );
650  bool extendBack( const Point& aNewPoint );
651 
661  bool retractFront();
662 
672  bool retractBack();
673 
674  // ------------------------- Display services ------------------------------
684  PointD project( const Point& aM, double aR ) const;
685 
694  PointD project( const Point & aM, const Point & aP ) const;
695 
699  std::string className() const;
700 
701  // ------------------------- Hidden services ------------------------------
702  protected:
703 
729  bool retractUpdateLeaningPoints( const Vector& aDirection,
730  const Point& aFirst,
731  const Point& aLast,
732  const Point& aBezout,
733  const Point& aFirstAtOppositeSide,
734  Point& aLastAtOppositeSide,
735  Point& aFirstAtRemovalSide,
736  const Point& aLastAtRemovalSide);
737 
745  void retractUpdateParameters( const Vector& aNewDirection );
746 
747 
748  // ------------------------- Protected Datas ------------------------------
749  protected:
750 
751  // -------------------- first and last point, leaning points ---------------
776 
777  //------------------------ DSL ---------------------------------------------
782 
783  }; // end of class ArithmeticalDSS
784 
785 
792  template <typename TCoordinate, typename TInteger, unsigned short adjacency>
793  std::ostream&
794  operator<< ( std::ostream & out, const ArithmeticalDSS<TCoordinate, TInteger, adjacency> & object );
795 
796 } // namespace DGtal
797 
798 
800 // Aliases
801 namespace DGtal
802 {
828  template <typename TCoordinate, typename TInteger = TCoordinate>
829  class StandardDSS4:
830  public ArithmeticalDSS<TCoordinate, TInteger, 4>
831  {
832  public:
834  typedef typename Super::Point Point;
835  typedef typename Super::Coordinate Coordinate;
836  typedef typename Super::DSL DSL;
837 
838  public:
839 
857  StandardDSS4(const Coordinate& aA, const Coordinate& aB,
858  const Point& aF, const Point& aL,
859  const Point& aUf, const Point& aUl,
860  const Point& aLf, const Point& aLl);
861 
875  StandardDSS4(const Point& aF, const Point& aL,
876  const bool& isOnTheUpperLine = true);
877 
888  StandardDSS4(const DSL& aDSL,
889  const Point& aF, const Point& aL);
890 
903  const Point& aF, const Point& aL);
904 
914  template <typename Iterator>
915  StandardDSS4(const Iterator& aItb, const Iterator& aIte);
916 
921  StandardDSS4 ( const StandardDSS4 & aOther );
922 
928  StandardDSS4 & operator= ( const StandardDSS4 & aOther );
929 
930  };
931 
967  template <typename TCoordinate, typename TInteger = TCoordinate>
968  class NaiveDSS8:
969  public ArithmeticalDSS<TCoordinate, TInteger, 8>
970  {
971  public:
973  typedef typename Super::Point Point;
974  typedef typename Super::Coordinate Coordinate;
975  typedef typename Super::DSL DSL;
976 
977  public:
995  NaiveDSS8(const Coordinate& aA, const Coordinate& aB,
996  const Point& aF, const Point& aL,
997  const Point& aUf, const Point& aUl,
998  const Point& aLf, const Point& aLl);
999 
1000 
1014  NaiveDSS8(const Point& aF, const Point& aL,
1015  const bool& isOnTheUpperLine = true);
1016 
1027  NaiveDSS8(const DSL& aDSL,
1028  const Point& aF, const Point& aL);
1029 
1041  NaiveDSS8(const NaiveDSS8& aDSS,
1042  const Point& aF, const Point& aL);
1043 
1053  template <typename Iterator>
1054  NaiveDSS8(const Iterator& aItb, const Iterator& aIte);
1055 
1060  NaiveDSS8 ( const NaiveDSS8 & aOther );
1061 
1067  NaiveDSS8 & operator= ( const NaiveDSS8 & aOther );
1068 
1069  };
1070 } // namespace DGtal
1071 
1072 
1074 // Includes inline functions.
1075 #include "DGtal/geometry/curves/ArithmeticalDSS.ih"
1076 // //
1078 
1080 #endif // !defined ArithmeticalDSS_h
1081 
1082 #undef ArithmeticalDSS_RECURSES
1083 #endif // else defined(ArithmeticalDSS_RECURSES)
Aim: This class aims at representing an iterator that provides a way to scan the points of a DSL....
Aim: This class represents a naive (resp. standard) digital straight line (DSL), ie....
std::pair< Vector, Vector > Steps
Aim: Set of static methods that create digital straight segments (DSS) from some input parameters,...
Aim: This class represents a naive (resp. standard) digital straight segment (DSS),...
std::string className() const
Integer omega() const
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
ArithmeticalDSS negate() const
unsigned short int isExtendableBack(const Point &aNewPoint) const
Integer orthogonalPosition(const Point &aPoint) const
bool isInDSL(const DSL &aDSL) const
bool before(const Point &aP1, const Point &aP2) const
ArithmeticalDSS(const Point &aPoint)
static const unsigned short foregroundAdjacency
bool beforeOrEqual(const Point &aP1, const Point &aP2) const
void retractUpdateParameters(const Vector &aNewDirection)
bool isInDSL(const DSL &aDSL, std::vector< Point > &Ulp, std::vector< Point > &Llp, Point &outP) const
ArithmeticalDSS & operator=(const ArithmeticalDSS &aOther)
ArithmeticalDSS computeUnion(const ArithmeticalDSS &aOther) const
Vector shift() const
bool retractUpdateLeaningPoints(const Vector &aDirection, const Point &aFirst, const Point &aLast, const Point &aBezout, const Point &aFirstAtOppositeSide, Point &aLastAtOppositeSide, Point &aFirstAtRemovalSide, const Point &aLastAtRemovalSide)
BOOST_CONCEPT_ASSERT((concepts::CInteger< Coordinate >))
ArithmeticalDSS(const DSL &aDSL, const Point &aF, const Point &aL)
Coordinate a() const
PointD project(const Point &aM, const Point &aP) const
bool equalsTo(const ArithmeticalDSS &aOther) const
const DSL & dsl() const
Position position(const Point &aPoint) const
unsigned short int isExtendableFront(const Point &aNewPoint) const
ArithmeticalDSS(const ArithmeticalDSS &aDSS, const Point &aF, const Point &aL)
bool operator()(const Point &aPoint) const
bool operator==(const ArithmeticalDSS &aOther) const
Integer remainder(const Point &aPoint) const
void selfDisplay(std::ostream &out) const
ArithmeticalDSS(const Point &aF, const Point &aL, const bool &areOnTheUpperLine=true)
ArithmeticalDSS(const DSL &aDSL, const Point &aF, const Point &aL, const Point &aUf, const Point &aUl, const Point &aLf, const Point &aLl)
bool extendBack(const Point &aNewPoint)
ConstIterator begin() const
ArithmeticalDSS(const Iterator &aItb, const Iterator &aIte)
DSL::ConstIterator ConstIterator
bool operator!=(const ArithmeticalDSS &aOther) const
DSL::ConstReverseIterator ConstReverseIterator
bool isInDSS(const Point &aPoint) const
DGtal::PointVector< 2, double > PointD
Integer mu() const
ArithmeticalDSS(const Coordinate &aA, const Coordinate &aB, const Integer &aLowerBound, const Integer &aUpperBound, const Point &aF, const Point &aL, const Point &aUf, const Point &aUl, const Point &aLf, const Point &aLl, const Steps &aSteps, const Vector &aShift)
ArithmeticalDSS(const ArithmeticalDSS &aOther)
ConstReverseIterator rbegin() const
bool isInDSL(const Point &aPoint) const
ArithmeticalDSL< Coordinate, Integer, adjacency > DSL
bool extendFront(const Point &aNewPoint)
Coordinate b() const
ArithmeticalDSS(const Coordinate &aA, const Coordinate &aB, const Point &aF, const Point &aL, const Point &aUf, const Point &aUl, const Point &aLf, const Point &aLl)
ConstReverseIterator rend() const
PointD project(const Point &aM, double aR) const
ConstIterator end() const
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 8-co...
NaiveDSS8(const Point &aF, const Point &aL, const bool &isOnTheUpperLine=true)
NaiveDSS8 & operator=(const NaiveDSS8 &aOther)
NaiveDSS8(const Coordinate &aA, const Coordinate &aB, const Point &aF, const Point &aL, const Point &aUf, const Point &aUl, const Point &aLf, const Point &aLl)
NaiveDSS8(const NaiveDSS8 &aDSS, const Point &aF, const Point &aL)
Super::Point Point
NaiveDSS8(const NaiveDSS8 &aOther)
Super::Coordinate Coordinate
ArithmeticalDSS< TCoordinate, TInteger, 8 > Super
NaiveDSS8(const Iterator &aItb, const Iterator &aIte)
NaiveDSS8(const DSL &aDSL, const Point &aF, const Point &aL)
This class adapts any bidirectional iterator so that operator++ calls operator-- and vice versa.
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 4-co...
StandardDSS4 & operator=(const StandardDSS4 &aOther)
StandardDSS4(const Iterator &aItb, const Iterator &aIte)
StandardDSS4(const Point &aF, const Point &aL, const bool &isOnTheUpperLine=true)
StandardDSS4(const StandardDSS4 &aDSS, const Point &aF, const Point &aL)
Super::Coordinate Coordinate
StandardDSS4(const DSL &aDSL, const Point &aF, const Point &aL)
ArithmeticalDSS< TCoordinate, TInteger, 4 > Super
StandardDSS4(const StandardDSS4 &aOther)
StandardDSS4(const Coordinate &aA, const Coordinate &aB, const Point &aF, const Point &aL, const Point &aUf, const Point &aUl, const Point &aLf, const Point &aLl)
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: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
const Point aPoint(3, 4)