DGtal  1.1.0
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)
34
35 #define ArithmeticalDSS_RECURSES
36
37 #if !defined ArithmeticalDSS_h
38
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)
DGtal::StandardDSS4::operator=
StandardDSS4 & operator=(const StandardDSS4 &aOther)
DGtal::ArithmeticalDSS::orthogonalPosition
Integer orthogonalPosition(const Point &aPoint) const
DGtal::ArithmeticalDSS::rend
ConstReverseIterator rend() const
ConstIterator
MyDigitalSurface::ConstIterator ConstIterator
Definition: greedy-plane-segmentation-ex2.cpp:93
DGtal::ArithmeticalDSS::ConstReverseIterator
DSL::ConstReverseIterator ConstReverseIterator
Definition: ArithmeticalDSS.h:152
DGtal::ArithmeticalDSS::retractUpdateParameters
void retractUpdateParameters(const Vector &aNewDirection)
DGtal::NaiveDSS8::NaiveDSS8
NaiveDSS8(const Point &aF, const Point &aL, const bool &isOnTheUpperLine=true)
DGtal::ArithmeticalDSS::DSL
ArithmeticalDSL< Coordinate, Integer, adjacency > DSL
Definition: ArithmeticalDSS.h:124
DGtal::ArithmeticalDSS::remainder
Integer remainder(const Point &aPoint) const
DGtal::ArithmeticalDSS::rbegin
ConstReverseIterator rbegin() const
DGtal::ArithmeticalDSS::Uf
Point Uf() const
DGtal::concepts::CInteger
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
DGtal::ArithmeticalDSS::beforeOrEqual
bool beforeOrEqual(const Point &aP1, const Point &aP2) const
DGtal::ArithmeticalDSS::className
std::string className() const
DGtal::ArithmeticalDSS::equalsTo
bool equalsTo(const ArithmeticalDSS &aOther) const
DGtal::ArithmeticalDSS::position
Position position(const Point &aPoint) const
DGtal::ArithmeticalDSS::Position
Coordinate Position
Definition: ArithmeticalDSS.h:144
DGtal::NaiveDSS8::NaiveDSS8
NaiveDSS8(const NaiveDSS8 &aOther)
DGtal::ArithmeticalDSL< Coordinate, Integer, adjacency >::Steps
std::pair< Vector, Vector > Steps
Definition: ArithmeticalDSL.h:149
DGtal::ArithmeticalDSS::Lf
Point Lf() const
DGtal::ArithmeticalDSS::myUl
Point myUl
Definition: ArithmeticalDSS.h:767
DGtal::ArithmeticalDSS::~ArithmeticalDSS
~ArithmeticalDSS()
DGtal::ArithmeticalDSS::operator=
ArithmeticalDSS & operator=(const ArithmeticalDSS &aOther)
aPoint
const Point aPoint(3, 4)
DGtal::ArithmeticalDSS::myLl
Point myLl
Definition: ArithmeticalDSS.h:775
DGtal::NaiveDSS8::Point
Super::Point Point
Definition: ArithmeticalDSS.h:973
DGtal::NaiveDSS8::DSL
Super::DSL DSL
Definition: ArithmeticalDSS.h:975
DGtal::ArithmeticalDSS::ArithmeticalDSS
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)
DGtal::ReverseIterator
This class adapts any bidirectional iterator so that operator++ calls operator-- and vice versa.
Definition: ReverseIterator.h:70
DGtal::NaiveDSS8
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 8-co...
Definition: ArithmeticalDSS.h:970
DGtal::ArithmeticalDSS::Coordinate
TCoordinate Coordinate
Definition: ArithmeticalDSS.h:113
DGtal::ArithmeticalDSS::project
PointD project(const Point &aM, double aR) const
DGtal::ArithmeticalDSS::ArithmeticalDSS
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)
DGtal::NaiveDSS8::Super
ArithmeticalDSS< TCoordinate, TInteger, 8 > Super
Definition: ArithmeticalDSS.h:972
DGtal::ArithmeticalDSS::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CInteger< Coordinate >))
DGtal::ArithmeticalDSS::negate
ArithmeticalDSS negate() const
DGtal::ArithmeticalDSS::dsl
const DSL & dsl() const
DGtal::NaiveDSS8::NaiveDSS8
NaiveDSS8(const NaiveDSS8 &aDSS, const Point &aF, const Point &aL)
DGtal::ArithmeticalDSS::myUf
Point myUf
Definition: ArithmeticalDSS.h:763
DGtal::NaiveDSS8::Coordinate
Super::Coordinate Coordinate
Definition: ArithmeticalDSS.h:974
DGtal::NaiveDSS8::NaiveDSS8
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)
DGtal::ArithmeticalDSS::operator()
bool operator()(const Point &aPoint) const
DGtal::StandardDSS4::StandardDSS4
StandardDSS4(const StandardDSS4 &aDSS, const Point &aF, const Point &aL)
DGtal::ArithmeticalDSS::ArithmeticalDSS
ArithmeticalDSS(const DSL &aDSL, const Point &aF, const Point &aL)
DGtal::SpaceND
Definition: SpaceND.h:96
DGtal::ArithmeticalDSS::project
PointD project(const Point &aM, const Point &aP) const
DGtal::ArithmeticalDSS::back
Point back() const
DGtal::ArithmeticalDSS::retractBack
bool retractBack()
DGtal::ArithmeticalDSS::PointD
DGtal::PointVector< 2, double > PointD
Definition: ArithmeticalDSS.h:158
DGtal::ArithmeticalDSS::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
DGtal::ArithmeticalDSS::ConstIterator
DSL::ConstIterator ConstIterator
Definition: ArithmeticalDSS.h:148
DGtal::ArithmeticalDSS::omega
Integer omega() const
DGtal::ArithmeticalDSS::ArithmeticalDSS
ArithmeticalDSS(const Point &aF, const Point &aL, const bool &areOnTheUpperLine=true)
DGtal::ArithmeticalDSS::extendFront
bool extendFront(const Point &aNewPoint)
DGtal::ArithmeticalDSS::Integer
TInteger Integer
Definition: ArithmeticalDSS.h:118
DGtal::ArithmeticalDSS::before
bool before(const Point &aP1, const Point &aP2) const
DGtal::ArithmeticalDSS::operator!=
bool operator!=(const ArithmeticalDSS &aOther) const
DGtal::ArithmeticalDSS::isInDSL
bool isInDSL(const Point &aPoint) const
DGtal::NaiveDSS8::operator=
NaiveDSS8 & operator=(const NaiveDSS8 &aOther)
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::ArithmeticalDSS::steps
Steps steps() const
DGtal::ArithmeticalDSS
Aim: This class represents a naive (resp. standard) digital straight segment (DSS),...
Definition: ArithmeticalDSS.h:96
DGtal::ArithmeticalDSS::Steps
DSL::Steps Steps
Definition: ArithmeticalDSS.h:140
DGtal::ArithmeticalDSS::isExtendableBack
unsigned short int isExtendableBack(const Point &aNewPoint) const
DGtal::ArithmeticalDSS::ArithmeticalDSS
ArithmeticalDSS(const Iterator &aItb, const Iterator &aIte)
DGtal::ArithmeticalDSS::end
ConstIterator end() const
DGtal::NaiveDSS8::NaiveDSS8
NaiveDSS8(const DSL &aDSL, const Point &aF, const Point &aL)
DGtal::ArithmeticalDSS::myF
Point myF
Definition: ArithmeticalDSS.h:755
DGtal::ArithmeticalDSS::myL
Point myL
Definition: ArithmeticalDSS.h:759
DGtal::ArithmeticalDSS::isInDSL
bool isInDSL(const DSL &aDSL) const
DGtal::ArithmeticalDSS::isExtendableFront
unsigned short int isExtendableFront(const Point &aNewPoint) const
DGtal::ArithmeticalDSS::ArithmeticalDSS
ArithmeticalDSS(const ArithmeticalDSS &aDSS, const Point &aF, const Point &aL)
DGtal::ArithmeticalDSS::computeUnion
ArithmeticalDSS computeUnion(const ArithmeticalDSS &aOther) const
DGtal::StandardDSS4::Point
Super::Point Point
Definition: ArithmeticalDSS.h:834
DGtal::ArithmeticalDSS::isInDSL
bool isInDSL(const DSL &aDSL, std::vector< Point > &Ulp, std::vector< Point > &Llp, Point &outP) const
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::StandardDSS4::Coordinate
Super::Coordinate Coordinate
Definition: ArithmeticalDSS.h:835
DGtal::ArithmeticalDSL< Coordinate, Integer, adjacency >
DGtal::ArithmeticalDSS::foregroundAdjacency
static const unsigned short foregroundAdjacency
Definition: ArithmeticalDSS.h:104
DGtal::StandardDSS4
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 4-co...
Definition: ArithmeticalDSS.h:831
DGtal::ArithmeticalDSS::Ul
Point Ul() const
DGtal::NaiveDSS8::NaiveDSS8
NaiveDSS8(const Iterator &aItb, const Iterator &aIte)
DGtal::ArithmeticalDSS::extendBack
bool extendBack(const Point &aNewPoint)
DGtal::ArithmeticalDSS::isInDSS
bool isInDSS(const Point &aPoint) const
DGtal::ArithmeticalDSS::ArithmeticalDSS
ArithmeticalDSS(const ArithmeticalDSS &aOther)
DGtal::ArithmeticalDSS::operator==
bool operator==(const ArithmeticalDSS &aOther) const
DGtal::ArithmeticalDSS::retractFront
bool retractFront()
DGtal::ArithmeticalDSS::retractUpdateLeaningPoints
bool retractUpdateLeaningPoints(const Vector &aDirection, const Point &aFirst, const Point &aLast, const Point &aBezout, const Point &aFirstAtOppositeSide, Point &aLastAtOppositeSide, Point &aFirstAtRemovalSide, const Point &aLastAtRemovalSide)
DGtal::StandardDSS4::StandardDSS4
StandardDSS4(const StandardDSS4 &aOther)
DGtal::ArithmeticalDSS::ArithmeticalDSS
ArithmeticalDSS(const Point &aPoint)
DGtal::StandardDSS4::DSL
Super::DSL DSL
Definition: ArithmeticalDSS.h:836
DGtal::ArithmeticalDSS::Vector
DSL::Vector Vector
Definition: ArithmeticalDSS.h:136
DGtal::PointVector< dim, Integer >
DGtal::ArithmeticalDSS::b
Coordinate b() const
DGtal::ArithmeticalDSS::front
Point front() const
DGtal::StandardDSS4::StandardDSS4
StandardDSS4(const Point &aF, const Point &aL, const bool &isOnTheUpperLine=true)
DGtal::StandardDSS4::Super
ArithmeticalDSS< TCoordinate, TInteger, 4 > Super
Definition: ArithmeticalDSS.h:833
DGtal::StandardDSS4::StandardDSS4
StandardDSS4(const DSL &aDSL, const Point &aF, const Point &aL)
DGtal::ArithmeticalDSS::begin
ConstIterator begin() const
DGtal::ArithmeticalDSSFactory
Aim: Set of static methods that create digital straight segments (DSS) from some input parameters,...
Definition: ArithmeticalDSSFactory.h:74
DGtal::ArithmeticalDSS::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::StandardDSS4::StandardDSS4
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::ArithmeticalDSS::Point
DSL::Point Point
Definition: ArithmeticalDSS.h:132
DGtal::ArithmeticalDSS::Space
DSL::Space Space
Definition: ArithmeticalDSS.h:128
DGtal::ArithmeticalDSS::myDSL
DSL myDSL
Definition: ArithmeticalDSS.h:781
DGtal::ArithmeticalDSS::isValid
bool isValid() const
DGtal::ArithmeticalDSS::mu
Integer mu() const
DGtal::ArithmeticalDSS::a
Coordinate a() const
DGtal::ArithmeticalDSS::shift
Vector shift() const
DGtal::ArithmeticalDSS::myLf
Point myLf
Definition: ArithmeticalDSS.h:771
DGtal::StandardDSS4::StandardDSS4
StandardDSS4(const Iterator &aItb, const Iterator &aIte)
DGtal::ArithmeticalDSS::Ll
Point Ll() const
DGtal::ArithmeticalDSS::ArithmeticalDSS
ArithmeticalDSS(const DSL &aDSL, const Point &aF, const Point &aL, const Point &aUf, const Point &aUl, const Point &aLf, const Point &aLl)