DGtal 2.1.0
Loading...
Searching...
No Matches
DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger > Struct Template Reference

Aim: Implements the quickhull algorithm by Barber et al. [9], a famous arbitrary dimensional convex hull computation algorithm. It relies on dedicated geometric kernels for computing and comparing facet geometries. More...

#include <DGtal/geometry/tools/GenericLatticeConvexHull.h>

Public Types

typedef ConvexHullIntegralKernel< dim, TCoordinateInteger, TInternalInteger > Kernel
 
typedef Kernel::CoordinatePoint Point
 
typedef Kernel::CoordinateScalar Integer
 
typedef Kernel::InternalScalar InternalInteger
 
typedef Point OutputPoint
 
typedef std::size_t Index
 
typedef std::size_t Size
 
typedef std::vector< IndexIndexRange
 
typedef detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, dimGenericComputers
 

Public Member Functions

Standard services (construction, initialization, accessors)
 GenericLatticeConvexHull (const Kernel &K_=Kernel(), int dbg=0)
 
void clear ()
 Clears the object as if no computations have been made.
 
convex hull services
template<typename InputPoint >
bool compute (const std::vector< InputPoint > &input_points)
 
Integer count ()
 
Integer countInterior ()
 
Integer countBoundary ()
 
Integer countUpTo (Integer max)
 
Interface
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Data Fields

public datas
Kernel kernel
 The main quickhull kernel that is used for convex hull computations.
 
int debug_level
 debug_level from 0:no to 2:verbose
 
GenericComputers generic_computers
 
std::vector< OutputPointpoints
 the set of input points, indexed as in the input
 
std::vector< OutputPointprojected_points
 the set of projected input points, indexed as in the input
 
int64_t affine_dimension
 The affine dimension of the input set.
 
std::vector< OutputPointpositions
 The positions of the vertices (a subset of the input points).
 
std::vector< IndexRangefacets
 The range giving for each facet the indices of its vertices.
 
IndexRange vertex2point
 The indices of the vertices of the convex hull in the original set.
 
Integer projected_dilation
 The factor of dilation d applied on every projected point coordinates.
 
AffineBasis< OutputPointaffine_basis
 
bool polytope_computed { false }
 When 'true', the polytope has been computed.
 

Static Public Attributes

static const Size dimension = Point::dimension
 

Detailed Description

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
struct DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >

Aim: Implements the quickhull algorithm by Barber et al. [9], a famous arbitrary dimensional convex hull computation algorithm. It relies on dedicated geometric kernels for computing and comparing facet geometries.

Description of template class 'GenericLatticeConvexHull'

Template Parameters
dimthe dimension of the space of processed points.
TCoordinateIntegerthe integer type that represents coordinates of lattice points, a model of concepts::CInteger.
TInternalIntegerthe integer type that is used for internal computations of above/below plane tests, a model of concepts::CInteger. Must be at least as precise as TCoordinateInteger.
Examples
examples/io/external-viewers/polyscope/exampleGenericLatticeConvexHull3D.cpp, examples/io/external-viewers/polyscope/exampleGenericLatticeConvexHull4D.cpp, and geometry/tools/exampleGenericLatticeConvexHull.cpp.

Definition at line 521 of file GenericLatticeConvexHull.h.

Member Typedef Documentation

◆ GenericComputers

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, dim > DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::GenericComputers

Definition at line 534 of file GenericLatticeConvexHull.h.

◆ Index

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef std::size_t DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::Index

Definition at line 530 of file GenericLatticeConvexHull.h.

◆ IndexRange

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef std::vector< Index > DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::IndexRange

Definition at line 532 of file GenericLatticeConvexHull.h.

◆ Integer

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef Kernel::CoordinateScalar DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::Integer

Definition at line 527 of file GenericLatticeConvexHull.h.

◆ InternalInteger

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef Kernel::InternalScalar DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::InternalInteger

Definition at line 528 of file GenericLatticeConvexHull.h.

◆ Kernel

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef ConvexHullIntegralKernel< dim, TCoordinateInteger, TInternalInteger > DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::Kernel

Definition at line 525 of file GenericLatticeConvexHull.h.

◆ OutputPoint

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef Point DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::OutputPoint

Definition at line 529 of file GenericLatticeConvexHull.h.

◆ Point

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef Kernel::CoordinatePoint DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::Point

Definition at line 526 of file GenericLatticeConvexHull.h.

◆ Size

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
typedef std::size_t DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::Size

Definition at line 531 of file GenericLatticeConvexHull.h.

Constructor & Destructor Documentation

◆ GenericLatticeConvexHull()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::GenericLatticeConvexHull ( const Kernel K_ = Kernel(),
int  dbg = 0 
)
inline

Default constructor

Parameters
[in]K_a kernel for computing facet geometries.
[in]dbgthe trace level, from 0 (no) to 3 (very verbose).

Definition at line 547 of file GenericLatticeConvexHull.h.

548 : kernel( K_ ), debug_level( dbg ), generic_computers( this )
549 {
550 clear();
551 }
void clear()
Clears the object as if no computations have been made.
int debug_level
debug_level from 0:no to 2:verbose
Kernel kernel
The main quickhull kernel that is used for convex hull computations.

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::clear().

Member Function Documentation

◆ clear()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
void DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::clear ( )
inline

Clears the object as if no computations have been made.

Definition at line 554 of file GenericLatticeConvexHull.h.

555 {
557 points.clear();
558 projected_points.clear();
559 affine_dimension = -1;
560 positions.clear();
561 facets.clear();
562 vertex2point.clear();
565 polytope_computed = false;
566 }
bool polytope_computed
When 'true', the polytope has been computed.
int64_t affine_dimension
The affine dimension of the input set.
AffineBasis< OutputPoint > affine_basis
std::vector< OutputPoint > points
the set of input points, indexed as in the input
std::vector< OutputPoint > positions
The positions of the vertices (a subset of the input points).
IndexRange vertex2point
The indices of the vertices of the convex hull in the original set.
Integer projected_dilation
The factor of dilation d applied on every projected point coordinates.
std::vector< OutputPoint > projected_points
the set of projected input points, indexed as in the input
std::vector< IndexRange > facets
The range giving for each facet the indices of its vertices.
void clear()
Clears the object as if no computations have been made.

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_basis, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_dimension, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::clear(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::facets, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::generic_computers, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::points, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::polytope_computed, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::positions, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::projected_dilation, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::projected_points, and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::vertex2point.

Referenced by DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::GenericLatticeConvexHull().

◆ compute()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
template<typename InputPoint >
bool DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::compute ( const std::vector< InputPoint > &  input_points)
inline

Sets the input data for the QuickHull convex hull algorithm, which is a range of points.

Template Parameters
InputPointa model of point that is convertible to Point datatype.
Parameters
[in]input_pointsthe range of input points.
Returns
'true' if the object is successfully initialized, status must be Status::InputInitialized, 'false' otherwise.

Definition at line 586 of file GenericLatticeConvexHull.h.

587 {
588 // Determine affine dimension of set of input points.
589 typedef AffineGeometry< InputPoint > Affine;
590 std::vector< Size > indices = Affine::affineSubset( input_points );
591 bool ok = generic_computers.compute( indices, input_points );
592 if ( ( ! ok ) || ( debug_level >= 1 ) )
593 {
594 std::cout << "Generic Convex hull #V=" << positions.size()
595 << " #F=" << facets.size() << "\n";
596 for ( Size i = 0; i < facets.size(); i++ )
597 {
598 std::cout << "F_" << i << " = (";
599 for ( auto v : facets[ i ] ) std::cout << " " << v;
600 std::cout << " )\n";
601 }
602 for ( Size i = 0; i < positions.size(); i++ )
603 std::cout << "V_" << i
604 << " pi(x)=" << projected_points[ vertex2point[ i ] ]
605 << " -> x=" << positions[ i ] << "\n";
606 }
607 return ok;
608 }
STL namespace.
bool compute(const std::vector< Size > &I, const std::vector< TInputPoint > &X)
HalfEdgeDataStructure::Size Size

References DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::compute(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::debug_level, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::facets, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::generic_computers, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::positions, DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::projected_points, and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::vertex2point.

◆ count()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
Integer DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::count ( )
inline

Computes the number of integer points lying within the polytope.

Returns
the number of integer points lying within the polytope, or -1 if their was a problem when computing the polytope.
Warning
The result is valid only if GenericLatticeConvexHull::projected_dilation is equal to 1 (i.e. the affine basis for the projection was obtained through an unimodular transformation). Otherwise the result is greater or equal to the expected number.
Note
Quite fast: obtained by line intersection, see BoundedLatticePolytopeCounter

Definition at line 623 of file GenericLatticeConvexHull.h.

References DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::count(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::generic_computers, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::makePolytope(), and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::polytope_computed.

◆ countBoundary()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
Integer DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countBoundary ( )
inline

Computes the number of integer points lying on the boundary of the polytope.

Returns
the number of integer points lying on the boundary of the polytope.
Warning
The result is valid only if GenericLatticeConvexHull::projected_dilation is equal to 1 (i.e. the affine basis for the projection was obtained through an unimodular transformation). Otherwise the result is greater or equal to the expected number.
Note
Quite fast: obtained by line intersection, see BoundedLatticePolytopeCounter
count() <= countInterior() + countBoundary() with equality when the polytope is closed.

Definition at line 669 of file GenericLatticeConvexHull.h.

References DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countBoundary(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::generic_computers, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::makePolytope(), and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::polytope_computed.

◆ countInterior()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
Integer DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countInterior ( )
inline

Computes the number of integer points lying within the interior of the polytope.

Returns
the number of integer points lying within the interior of the polytope.
Warning
The result is valid only if GenericLatticeConvexHull::projected_dilation is equal to 1 (i.e. the affine basis for the projection was obtained through an unimodular transformation). Otherwise the result is greater or equal to the expected number.
Note
Quite fast: obtained by line intersection, see BoundedLatticePolytopeCounter
count() <= countInterior() + countBoundary() with equality when the polytope is closed.

Definition at line 646 of file GenericLatticeConvexHull.h.

References DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countInterior(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::generic_computers, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::makePolytope(), and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::polytope_computed.

◆ countUpTo()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
Integer DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::countUpTo ( Integer  max)
inline

Computes the number of integer points within the polytope up to some maximum number max.

Note
For instance, a d-dimensional simplex that contains no integer points in its interior contains only d+1 points. If there is more, you know that the simplex has a non empty interior.
Parameters
[in]maxthe maximum number of points that are counted, the method exists when this number of reached.
Returns
the number of integer points within the polytope up to .
Warning
The result is valid only if GenericLatticeConvexHull::projected_dilation is equal to 1 (i.e. the affine basis for the projection was obtained through an unimodular transformation). Otherwise the result is greater or equal to the expected number.
Note
Quite fast: obtained by line intersection, see BoundedLatticePolytopeCounter

Definition at line 698 of file GenericLatticeConvexHull.h.

699 {
700 if ( ! polytope_computed )
702 if ( ! polytope_computed ) return -1;
704 }
int max(int a, int b)

References DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::countUpTo(), DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::generic_computers, DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::makePolytope(), max(), and DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::polytope_computed.

◆ isValid()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
bool DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object has made a convex hull computation, 'false' otherwise.

Definition at line 729 of file GenericLatticeConvexHull.h.

730 {
731 return affine_dimension >= 0;
732 }

References DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_dimension.

◆ selfDisplay()

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
void DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::selfDisplay ( std::ostream &  out) const
inline

Field Documentation

◆ affine_basis

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
AffineBasis< OutputPoint > DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::affine_basis

◆ affine_dimension

◆ debug_level

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
int DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::debug_level

debug_level from 0:no to 2:verbose

Definition at line 744 of file GenericLatticeConvexHull.h.

Referenced by DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::compute().

◆ dimension

◆ facets

◆ generic_computers

◆ kernel

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
Kernel DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::kernel

The main quickhull kernel that is used for convex hull computations.

Definition at line 742 of file GenericLatticeConvexHull.h.

◆ points

◆ polytope_computed

◆ positions

◆ projected_dilation

template<Dimension dim, typename TCoordinateInteger = DGtal::int64_t, typename TInternalInteger = DGtal::int64_t>
Integer DGtal::GenericLatticeConvexHull< dim, TCoordinateInteger, TInternalInteger >::projected_dilation

◆ projected_points

◆ vertex2point


The documentation for this struct was generated from the following file: