DGtal  1.2.0
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)
35 #define DigitalConvexity_RECURSES
36 
37 #if !defined DigitalConvexity_h
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
72  template < typename TKSpace >
74  {
76 
77  public:
79  typedef TKSpace KSpace;
80  typedef typename KSpace::Integer Integer;
81  typedef typename KSpace::Point Point;
82  typedef typename KSpace::Vector Vector;
83  typedef typename KSpace::Cell Cell;
84  typedef typename KSpace::Space Space;
89  typedef std::vector<Point> PointRange;
90 
91  static const Dimension dimension = KSpace::dimension;
92 
93 
96 
100  ~DigitalConvexity() = default;
101 
105  DigitalConvexity() = default;
106 
111  DigitalConvexity ( const Self & other ) = default;
112 
118 
125 
131  Self & operator= ( const Self & other ) = default;
132 
134  const KSpace& space() const;
135 
137 
138  // ----------------------- Simplex services --------------------------------------
139  public:
142 
152  template <typename PointIterator>
153  static
154  LatticePolytope makeSimplex( PointIterator itB, PointIterator itE );
155 
163  static
164  LatticePolytope makeSimplex( std::initializer_list<Point> l );
165 
180  template <typename PointIterator>
181  static
183  PointIterator itB, PointIterator itE );
184 
195  static
196  RationalPolytope makeRationalSimplex( std::initializer_list<Point> l );
197 
207  template <typename PointIterator>
208  static
209  bool isSimplexFullDimensional( PointIterator itB, PointIterator itE );
210 
218  static
219  bool isSimplexFullDimensional( std::initializer_list<Point> l );
220 
222  enum class SimplexType{
223  INVALID,
224  DEGENERATED,
225  UNITARY,
226  COMMON
227  };
228 
239  template <typename PointIterator>
240  static
241  SimplexType simplexType( PointIterator itB, PointIterator itE );
242 
250  static
251  SimplexType simplexType( std::initializer_list<Point> l );
252 
262  template <typename PointIterator>
263  static
264  void displaySimplex( std::ostream& out, PointIterator itB, PointIterator itE );
265 
273  static
274  void displaySimplex( std::ostream& out, std::initializer_list<Point> l );
275 
277 
278  // ----------------------- Polytope services --------------------------------------
279  public:
282 
285  static
287 
290  static
292 
295  static
297 
300  static
302 
304 
305 
306  // ----------------------- Cell geometry services -----------------------------------
307  public:
310 
319  template <typename PointIterator>
320  CellGeometry makeCellCover( PointIterator itB, PointIterator itE,
321  Dimension i = 0,
322  Dimension k = KSpace::dimension ) const;
323 
332  Dimension i = 0,
333  Dimension k = KSpace::dimension ) const;
334 
343  Dimension i = 0,
344  Dimension k = KSpace::dimension ) const;
346 
347 
348  // ----------------------- Convexity services -----------------------------------
349  public:
352 
357 
365  bool isKConvex( const LatticePolytope& P, const Dimension k ) const;
366 
372 
380  bool isFullyConvex( const LatticePolytope& P ) const;
381 
387 
392  bool isKSubconvex( const LatticePolytope& P, const CellGeometry& C, const Dimension k ) const;
393 
399 
406  bool isFullySubconvex( const LatticePolytope& P, const CellGeometry& C ) const;
407 
409 
410  // ----------------------- Convexity services -----------------------------------
411  public:
414 
419 
427  bool isKConvex( const RationalPolytope& P, const Dimension k ) const;
428 
434 
442  bool isFullyConvex( const RationalPolytope& P ) const;
443 
449 
454  bool isKSubconvex( const RationalPolytope& P, const CellGeometry& C, const Dimension k ) const;
455 
461 
468  bool isFullySubconvex( const RationalPolytope& P, const CellGeometry& C ) const;
469 
471 
472  // ----------------------- Interface --------------------------------------
473  public:
476 
481  void selfDisplay ( std::ostream & out ) const;
482 
489  bool isValid() const;
490 
492 
493  // ------------------------- Protected Datas ------------------------------
494  protected:
497 
498  // ------------------------- Private Datas --------------------------------
499  private:
500 
501 
502  // ------------------------- Internals ------------------------------------
503  private:
504 
505  }; // end of class DigitalConvexity
506 
509 
516  template <typename TKSpace>
517  std::ostream&
518  operator<< ( std::ostream & out,
519  const DigitalConvexity<TKSpace> & object );
520 
522 
523 } // namespace DGtal
524 
525 
527 // Includes inline functions.
528 #include "DigitalConvexity.ih"
529 
530 // //
532 
533 #endif // !defined DigitalConvexity_h
534 
535 #undef DigitalConvexity_RECURSES
536 #endif // else defined(DigitalConvexity_RECURSES)
Aim: Represents an nD lattice polytope, i.e. a convex polyhedron bounded with vertices with integer c...
Aim: Represents an nD rational polytope, i.e. a convex polyhedron bounded by vertices with rational c...
Aim: Computes and stores sets of cells and provides methods to compute intersections of lattice and r...
Definition: CellGeometry.h:75
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:267
Aim: A helper class to build polytopes from digital sets and to check digital k-convexity.
static PointRange insidePoints(const LatticePolytope &polytope)
static RationalPolytope makeRationalSimplex(Integer d, PointIterator itB, PointIterator itE)
static bool isSimplexFullDimensional(std::initializer_list< Point > l)
bool isFullyConvex(const RationalPolytope &P) const
bool isKConvex(const LatticePolytope &P, const Dimension k) const
static bool isSimplexFullDimensional(PointIterator itB, PointIterator itE)
static LatticePolytope makeSimplex(PointIterator itB, PointIterator itE)
SimplexType
The possible types for simplices.
@ UNITARY
When its edges form a unit parallelotope (det = +/- 1)
@ INVALID
When there are not the right number of vertices.
@ DEGENERATED
When the points of the simplex are not in general position.
static SimplexType simplexType(std::initializer_list< Point > l)
static void displaySimplex(std::ostream &out, PointIterator itB, PointIterator itE)
DigitalConvexity(const Self &other)=default
static LatticePolytope makeSimplex(std::initializer_list< Point > l)
Self & operator=(const Self &other)=default
DigitalConvexity(Clone< KSpace > K)
CellGeometry makeCellCover(const RationalPolytope &P, Dimension i=0, Dimension k=KSpace::dimension) const
static RationalPolytope makeRationalSimplex(std::initializer_list< Point > l)
std::vector< Point > PointRange
DGtal::BoundedRationalPolytope< Space > RationalPolytope
bool isFullyConvex(const LatticePolytope &P) const
DGtal::CellGeometry< KSpace > CellGeometry
bool isKSubconvex(const RationalPolytope &P, const CellGeometry &C, const Dimension k) const
static PointRange interiorPoints(const RationalPolytope &polytope)
static const Dimension dimension
bool isKSubconvex(const LatticePolytope &P, const CellGeometry &C, const Dimension k) const
CellGeometry makeCellCover(const LatticePolytope &P, Dimension i=0, Dimension k=KSpace::dimension) const
static PointRange insidePoints(const RationalPolytope &polytope)
bool isFullySubconvex(const RationalPolytope &P, const CellGeometry &C) const
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
DigitalConvexity(Point lo, Point hi)
DigitalConvexity< TKSpace > Self
bool isKConvex(const RationalPolytope &P, const Dimension k) const
DGtal::BoundedLatticePolytope< Space > LatticePolytope
bool isFullySubconvex(const LatticePolytope &P, const CellGeometry &C) const
void selfDisplay(std::ostream &out) const
static void displaySimplex(std::ostream &out, std::initializer_list< Point > l)
const KSpace & space() const
KSpace myK
The cellular grid space where computations are done.
DGtal::BoundedLatticePolytope< Space > Polytope
CellGeometry makeCellCover(PointIterator itB, PointIterator itE, Dimension i=0, Dimension k=KSpace::dimension) const
static SimplexType simplexType(PointIterator itB, PointIterator itE)
static PointRange interiorPoints(const LatticePolytope &polytope)
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::uint32_t Dimension
Definition: Common.h:137
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...
KSpace K