DGtal  1.3.beta
DigitalConvexity.h
1 
17 #pragma once
18 
31 #if defined(DigitalConvexity_RECURSES)
32 #error Recursive header files inclusion detected in DigitalConvexity.h
33 #else // defined(DigitalConvexity_RECURSES)
34 
35 #define DigitalConvexity_RECURSES
36 
37 #if !defined DigitalConvexity_h
38 
39 #define DigitalConvexity_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <list>
45 #include <vector>
46 #include <string>
47 #include <unordered_set>
48 #include "DGtal/base/Common.h"
49 #include "DGtal/base/Clone.h"
50 #include "DGtal/topology/CCellularGridSpaceND.h"
51 #include "DGtal/topology/KhalimskySpaceND.h"
52 #include "DGtal/geometry/volumes/BoundedLatticePolytope.h"
53 #include "DGtal/geometry/volumes/BoundedRationalPolytope.h"
54 #include "DGtal/geometry/volumes/CellGeometry.h"
56 
57 namespace DGtal
58 {
59 
61  // template class DigitalConvexity
74  template < typename TKSpace >
76  {
78 
79  public:
81  typedef TKSpace KSpace;
82  typedef typename KSpace::Integer Integer;
83  typedef typename KSpace::Point Point;
84  typedef typename KSpace::Vector Vector;
85  typedef typename KSpace::Cell Cell;
86  typedef typename KSpace::Space Space;
91  typedef std::vector<Point> PointRange;
92  typedef std::unordered_set<Point> PointSet;
93 
95 
96 
99 
103  ~DigitalConvexity() = default;
104 
108  DigitalConvexity() = default;
109 
114  DigitalConvexity ( const Self & other ) = default;
115 
121 
127  DigitalConvexity( Point lo, Point hi );
128 
134  Self & operator= ( const Self & other ) = default;
135 
137  const KSpace& space() const;
138 
140 
141  // ----------------------- Simplex services --------------------------------------
142  public:
145 
155  template <typename PointIterator>
156  static
157  LatticePolytope makeSimplex( PointIterator itB, PointIterator itE );
158 
166  static
167  LatticePolytope makeSimplex( std::initializer_list<Point> l );
168 
183  template <typename PointIterator>
184  static
186  PointIterator itB, PointIterator itE );
187 
198  static
199  RationalPolytope makeRationalSimplex( std::initializer_list<Point> l );
200 
210  template <typename PointIterator>
211  static
212  bool isSimplexFullDimensional( PointIterator itB, PointIterator itE );
213 
221  static
222  bool isSimplexFullDimensional( std::initializer_list<Point> l );
223 
225  enum class SimplexType{
226  INVALID,
227  DEGENERATED,
228  UNITARY,
229  COMMON
230  };
231 
242  template <typename PointIterator>
243  static
244  SimplexType simplexType( PointIterator itB, PointIterator itE );
245 
253  static
254  SimplexType simplexType( std::initializer_list<Point> l );
255 
265  template <typename PointIterator>
266  static
267  void displaySimplex( std::ostream& out, PointIterator itB, PointIterator itE );
268 
276  static
277  void displaySimplex( std::ostream& out, std::initializer_list<Point> l );
278 
280 
281  // ----------------------- Polytope services --------------------------------------
282  public:
285 
288  static
289  PointRange insidePoints( const LatticePolytope& polytope );
290 
293  static
294  PointRange interiorPoints( const LatticePolytope& polytope );
295 
298  static
299  PointRange insidePoints( const RationalPolytope& polytope );
300 
303  static
304  PointRange interiorPoints( const RationalPolytope& polytope );
305 
307 
308 
309  // ----------------------- Cell geometry services -----------------------------------
310  public:
313 
322  template <typename PointIterator>
323  CellGeometry makeCellCover( PointIterator itB, PointIterator itE,
324  Dimension i = 0,
325  Dimension k = KSpace::dimension ) const;
326 
335  Dimension i = 0,
336  Dimension k = KSpace::dimension ) const;
337 
346  Dimension i = 0,
347  Dimension k = KSpace::dimension ) const;
349 
350  // ----------------------- Morphological services -----------------------------------
351  public:
354 
366  LatticePolytope makePolytope( const PointRange& X, bool safe = false ) const;
367 
374  PointRange U( Dimension i, const PointRange& X ) const;
375 
387  bool is0Convex( const PointRange& X, bool safe = false ) const;
388 
405  bool isFullyConvex( const PointRange& X, bool convex0 = false,
406  bool safe = false ) const;
407 
409 
410  // ----------------------- Convexity services for lattice polytopes -----------------
411  public:
414 
419 
427  bool isKConvex( const LatticePolytope& P, const Dimension k ) const;
428 
434 
442  bool isFullyConvex( const LatticePolytope& P ) const;
443 
449 
454  bool isKSubconvex( const LatticePolytope& P, const CellGeometry& C, const Dimension k ) const;
455 
461 
468  bool isFullySubconvex( const LatticePolytope& P, const CellGeometry& C ) const;
469 
487  bool isKSubconvex( const Point& a, const Point& b,
488  const CellGeometry& C, const Dimension k ) const;
489 
506  bool isFullySubconvex( const Point& a, const Point& b,
507  const CellGeometry& C ) const;
508 
510 
511  // ----------------------- Convexity services for rational polytopes ----------------
512  public:
515 
520 
528  bool isKConvex( const RationalPolytope& P, const Dimension k ) const;
529 
535 
543  bool isFullyConvex( const RationalPolytope& P ) const;
544 
550 
555  bool isKSubconvex( const RationalPolytope& P, const CellGeometry& C, const Dimension k ) const;
556 
562 
569  bool isFullySubconvex( const RationalPolytope& P, const CellGeometry& C ) const;
570 
572 
573  // ----------------------- Interface --------------------------------------
574  public:
577 
582  void selfDisplay ( std::ostream & out ) const;
583 
590  bool isValid() const;
591 
593 
594  // ------------------------- Protected Datas ------------------------------
595  protected:
598 
599  // ------------------------- Private Datas --------------------------------
600  private:
601 
602 
603  // ------------------------- Internals ------------------------------------
604  private:
605 
606  }; // end of class DigitalConvexity
607 
610 
617  template <typename TKSpace>
618  std::ostream&
619  operator<< ( std::ostream & out,
620  const DigitalConvexity<TKSpace> & object );
621 
623 
624 } // namespace DGtal
625 
626 
628 // Includes inline functions.
629 #include "DigitalConvexity.ih"
630 
631 // //
633 
634 #endif // !defined DigitalConvexity_h
635 
636 #undef DigitalConvexity_RECURSES
637 #endif // else defined(DigitalConvexity_RECURSES)
DGtal::Clone
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:266
DGtal::DigitalConvexity::Self
DigitalConvexity< TKSpace > Self
Definition: DigitalConvexity.h:80
DGtal::DigitalConvexity::isValid
bool isValid() const
DGtal::DigitalConvexity::makeSimplex
static LatticePolytope makeSimplex(PointIterator itB, PointIterator itE)
DGtal::DigitalConvexity::myK
KSpace myK
The cellular grid space where computations are done.
Definition: DigitalConvexity.h:597
DGtal::DigitalConvexity< KSpace >::SimplexType
SimplexType
The possible types for simplices.
Definition: DigitalConvexity.h:225
DGtal::DigitalConvexity::displaySimplex
static void displaySimplex(std::ostream &out, PointIterator itB, PointIterator itE)
DGtal::DigitalConvexity::simplexType
static SimplexType simplexType(PointIterator itB, PointIterator itE)
DGtal::DigitalConvexity::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::concepts::CCellularGridSpaceND
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...
Definition: CCellularGridSpaceND.h:162
DGtal::DigitalConvexity::PointRange
std::vector< Point > PointRange
Definition: DigitalConvexity.h:91
DGtal::DigitalConvexity::is0Convex
bool is0Convex(const PointRange &X, bool safe=false) const
K
KSpace K
Definition: testCubicalComplex.cpp:62
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:137
DGtal::DigitalConvexity::makeRationalSimplex
static RationalPolytope makeRationalSimplex(Integer d, PointIterator itB, PointIterator itE)
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::DigitalConvexity::insidePoints
static PointRange insidePoints(const LatticePolytope &polytope)
DGtal::SpaceND
Definition: SpaceND.h:95
DGtal::DigitalConvexity::PointSet
std::unordered_set< Point > PointSet
Definition: DigitalConvexity.h:92
DGtal::KhalimskySpaceND::dimension
static const constexpr Dimension dimension
Definition: KhalimskySpaceND.h:430
DGtal::DigitalConvexity::CellGeometry
DGtal::CellGeometry< KSpace > CellGeometry
Definition: DigitalConvexity.h:90
DGtal::DigitalConvexity::SimplexType::DEGENERATED
@ DEGENERATED
When the points of the simplex are not in general position.
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::DigitalConvexity::operator=
Self & operator=(const Self &other)=default
DGtal::DigitalConvexity::Space
KSpace::Space Space
Definition: DigitalConvexity.h:86
DGtal::DigitalConvexity::Vector
KSpace::Vector Vector
Definition: DigitalConvexity.h:84
DGtal::DigitalConvexity::isKSubconvex
bool isKSubconvex(const LatticePolytope &P, const CellGeometry &C, const Dimension k) const
DGtal::DigitalConvexity::SimplexType::UNITARY
@ UNITARY
When its edges form a unit parallelotope (det = +/- 1)
DGtal::DigitalConvexity::RationalPolytope
DGtal::BoundedRationalPolytope< Space > RationalPolytope
Definition: DigitalConvexity.h:89
DGtal::DigitalConvexity::LatticePolytope
DGtal::BoundedLatticePolytope< Space > LatticePolytope
Definition: DigitalConvexity.h:88
DGtal::DigitalConvexity::Integer
KSpace::Integer Integer
Definition: DigitalConvexity.h:82
DGtal::DigitalConvexity::isKConvex
bool isKConvex(const LatticePolytope &P, const Dimension k) const
DGtal::DigitalConvexity::isFullySubconvex
bool isFullySubconvex(const LatticePolytope &P, const CellGeometry &C) const
DGtal::DigitalConvexity::KSpace
TKSpace KSpace
Definition: DigitalConvexity.h:81
DGtal::DigitalConvexity::makePolytope
LatticePolytope makePolytope(const PointRange &X, bool safe=false) const
DGtal::DigitalConvexity::dimension
static const Dimension dimension
Definition: DigitalConvexity.h:94
DGtal::BoundedRationalPolytope
Aim: Represents an nD rational polytope, i.e. a convex polyhedron bounded by vertices with rational c...
Definition: BoundedRationalPolytope.h:74
DGtal::DigitalConvexity::isSimplexFullDimensional
static bool isSimplexFullDimensional(PointIterator itB, PointIterator itE)
DGtal::DigitalConvexity::SimplexType::INVALID
@ INVALID
When there are not the right number of vertices.
DGtal::DigitalConvexity::~DigitalConvexity
~DigitalConvexity()=default
DGtal::CellGeometry< KSpace >
DGtal::DigitalConvexity::SimplexType::COMMON
@ COMMON
Common simplex.
DGtal::DigitalConvexity::makeCellCover
CellGeometry makeCellCover(PointIterator itB, PointIterator itE, Dimension i=0, Dimension k=KSpace::dimension) const
DGtal::PointVector< dim, Integer >
DGtal::DigitalConvexity::U
PointRange U(Dimension i, const PointRange &X) const
DGtal::KhalimskySpaceND::Integer
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
Definition: KhalimskySpaceND.h:404
DGtal::BoundedLatticePolytope
Aim: Represents an nD lattice polytope, i.e. a convex polyhedron bounded with vertices with integer c...
Definition: BoundedLatticePolytope.h:74
DGtal::DigitalConvexity::Polytope
DGtal::BoundedLatticePolytope< Space > Polytope
Definition: DigitalConvexity.h:87
DGtal::DigitalConvexity::interiorPoints
static PointRange interiorPoints(const LatticePolytope &polytope)
DGtal::DigitalConvexity
Aim: A helper class to build polytopes from digital sets and to check digital k-convexity and full co...
Definition: DigitalConvexity.h:75
DGtal::DigitalConvexity::Point
KSpace::Point Point
Definition: DigitalConvexity.h:83
DGtal::DigitalConvexity::DigitalConvexity
DigitalConvexity()=default
DGtal::DigitalConvexity::isFullyConvex
bool isFullyConvex(const PointRange &X, bool convex0=false, bool safe=false) const
DGtal::DigitalConvexity::space
const KSpace & space() const
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::DigitalConvexity::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
DGtal::DigitalConvexity::Cell
KSpace::Cell Cell
Definition: DigitalConvexity.h:85
DGtal::KhalimskyCell< dim, Integer >