DGtal  1.1.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)
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
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 
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)
DGtal::Clone
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:267
DGtal::DigitalConvexity::Self
DigitalConvexity< TKSpace > Self
Definition: DigitalConvexity.h:78
DGtal::DigitalConvexity::isValid
bool isValid() const
DGtal::KhalimskySpaceND::dimension
static constexpr const Dimension dimension
Definition: KhalimskySpaceND.h:430
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:496
DGtal::DigitalConvexity::isFullySubconvex
bool isFullySubconvex(const RationalPolytope &P, const CellGeometry &C) const
DGtal::DigitalConvexity::SimplexType
SimplexType
The possible types for simplices.
Definition: DigitalConvexity.h:222
DGtal::DigitalConvexity::isFullyConvex
bool isFullyConvex(const LatticePolytope &P) const
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:164
DGtal::DigitalConvexity::PointRange
std::vector< Point > PointRange
Definition: DigitalConvexity.h:89
DGtal::DigitalConvexity::isKSubconvex
bool isKSubconvex(const RationalPolytope &P, const CellGeometry &C, const Dimension k) const
K
KSpace K
Definition: testCubicalComplex.cpp:62
DGtal::DigitalConvexity::DigitalConvexity
DigitalConvexity(Clone< KSpace > K)
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:133
DGtal::DigitalConvexity::makeCellCover
CellGeometry makeCellCover(const LatticePolytope &P, Dimension i=0, Dimension k=KSpace::dimension) const
DGtal::DigitalConvexity::makeRationalSimplex
static RationalPolytope makeRationalSimplex(Integer d, PointIterator itB, PointIterator itE)
DGtal::DigitalConvexity::isSimplexFullDimensional
static bool isSimplexFullDimensional(std::initializer_list< Point > l)
DGtal::DigitalConvexity::insidePoints
static PointRange insidePoints(const RationalPolytope &polytope)
DGtal::DigitalConvexity::insidePoints
static PointRange insidePoints(const LatticePolytope &polytope)
DGtal::SpaceND
Definition: SpaceND.h:96
DGtal::DigitalConvexity::simplexType
static SimplexType simplexType(std::initializer_list< Point > l)
DGtal::DigitalConvexity::CellGeometry
DGtal::CellGeometry< KSpace > CellGeometry
Definition: DigitalConvexity.h:88
DGtal::DigitalConvexity::SimplexType::DEGENERATED
@ DEGENERATED
When the points of the simplex are not in general position.
DGtal::DigitalConvexity::interiorPoints
static PointRange interiorPoints(const RationalPolytope &polytope)
DGtal::DigitalConvexity::DigitalConvexity
DigitalConvexity(const Self &other)=default
DGtal::DigitalConvexity::makeSimplex
static LatticePolytope makeSimplex(std::initializer_list< Point > l)
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::DigitalConvexity::operator=
Self & operator=(const Self &other)=default
DGtal::DigitalConvexity::Space
KSpace::Space Space
Definition: DigitalConvexity.h:84
DGtal::DigitalConvexity::Vector
KSpace::Vector Vector
Definition: DigitalConvexity.h:82
DGtal::DigitalConvexity::isKSubconvex
bool isKSubconvex(const LatticePolytope &P, const CellGeometry &C, const Dimension k) const
DGtal::DigitalConvexity::makeCellCover
CellGeometry makeCellCover(const RationalPolytope &P, Dimension i=0, Dimension k=KSpace::dimension) 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:87
DGtal::DigitalConvexity::LatticePolytope
DGtal::BoundedLatticePolytope< Space > LatticePolytope
Definition: DigitalConvexity.h:86
DGtal::DigitalConvexity::Integer
KSpace::Integer Integer
Definition: DigitalConvexity.h:80
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::DigitalConvexity::isKConvex
bool isKConvex(const LatticePolytope &P, const Dimension k) const
DGtal::DigitalConvexity::DigitalConvexity
DigitalConvexity(Point lo, Point hi)
DGtal::DigitalConvexity::isFullySubconvex
bool isFullySubconvex(const LatticePolytope &P, const CellGeometry &C) const
DGtal::DigitalConvexity::KSpace
TKSpace KSpace
Definition: DigitalConvexity.h:79
DGtal::DigitalConvexity::dimension
static const Dimension dimension
Definition: DigitalConvexity.h:91
DGtal::BoundedRationalPolytope
Aim: Represents an nD rational polytope, i.e. a convex polyhedron bounded by vertices with rational c...
Definition: BoundedRationalPolytope.h:75
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
Aim: Computes and stores sets of cells and provides methods to compute intersections of lattice and r...
Definition: CellGeometry.h:75
DGtal::DigitalConvexity::SimplexType::COMMON
@ COMMON
Common simplex.
DGtal::DigitalConvexity::makeRationalSimplex
static RationalPolytope makeRationalSimplex(std::initializer_list< Point > l)
DGtal::DigitalConvexity::makeCellCover
CellGeometry makeCellCover(PointIterator itB, PointIterator itE, Dimension i=0, Dimension k=KSpace::dimension) const
DGtal::PointVector< dim, Integer >
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:75
DGtal::DigitalConvexity::isKConvex
bool isKConvex(const RationalPolytope &P, const Dimension k) const
DGtal::DigitalConvexity::Polytope
DGtal::BoundedLatticePolytope< Space > Polytope
Definition: DigitalConvexity.h:85
DGtal::DigitalConvexity::interiorPoints
static PointRange interiorPoints(const LatticePolytope &polytope)
DGtal::DigitalConvexity::displaySimplex
static void displaySimplex(std::ostream &out, std::initializer_list< Point > l)
DGtal::DigitalConvexity
Aim: A helper class to build polytopes from digital sets and to check digital k-convexity.
Definition: DigitalConvexity.h:74
DGtal::DigitalConvexity::Point
KSpace::Point Point
Definition: DigitalConvexity.h:81
DGtal::DigitalConvexity::DigitalConvexity
DigitalConvexity()=default
DGtal::DigitalConvexity::isFullyConvex
bool isFullyConvex(const RationalPolytope &P) const
DGtal::DigitalConvexity::space
const KSpace & space() const
DGtal::DigitalConvexity::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
DGtal::DigitalConvexity::Cell
KSpace::Cell Cell
Definition: DigitalConvexity.h:83
DGtal::KhalimskyCell< dim, Integer >