DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
exampleGenericLatticeConvexHull.cpp
Go to the documentation of this file.
1
16
29
45
46
#include <iostream>
47
#include <format>
48
#include <vector>
50
#include "DGtal/base/Common.h"
51
#include "DGtal/kernel/SpaceND.h"
52
#include "DGtal/geometry/tools/GenericLatticeConvexHull.h"
53
int
main
()
54
{
55
using namespace
DGtal
;
56
// point coordinates are int (32 bits), computation with int64_t
57
typedef
GenericLatticeConvexHull< 3, int, int64_t >
QHull;
58
typedef
SpaceND< 3, int >
Space
;
59
typedef
Space::Point
Point
;
60
61
std::size_t nb_ok [ 4 ] = { 0, 0, 0, 0 };
62
std::size_t nb_per_dim [ 4 ] = { 0, 0, 0, 0 };
63
std::size_t nb_vertices[ 4 ] = { 0, 0, 0, 0 };
64
std::size_t nb_facets [ 4 ] = { 0, 0, 0, 0 };
65
const
std::size_t nb = 100000;
66
for
( std::size_t n = 0; n < nb; ++n )
67
{
68
// Create a random set of points
69
std::vector< Point > X;
70
int
m = 2 + rand() % 9;
//< number of points
71
for
(
int
i = 0; i < m; i++ )
72
X.push_back(
Point
{ rand() % 8, rand() % 8, rand() % 8 } );
73
// Compute convex hull
74
QHull hull;
75
bool
ok = hull.compute( X );
76
auto
k = hull.affine_dimension;
// affine dimension of X
77
// Compute statistics
78
nb_per_dim [ k ] += 1;
79
nb_vertices[ k ] += hull.positions.size();
// positions of vertices
80
nb_facets [ k ] += hull.facets.size();
// facets
81
nb_ok [ k ] += ok ? 1 : 0;
82
}
83
for
(
auto
k = 0; k < 4; k++ )
84
std::cout << std::setprecision(3) << ( 100.0 * nb_per_dim[ k ] ) / nb
85
<<
"% are "
<< k <<
"-dimensional"
86
<<
" #V="
<<
double
( nb_vertices[ k ] ) / nb_per_dim[ k ]
87
<<
" #F="
<< double( nb_facets[ k ] ) / nb_per_dim[ k ]
88
<<
" ("
<< nb_ok[ k ] <<
"/"
<< nb_per_dim[ k ] <<
")\n"
;
89
return
0;
90
}
91
DGtal::SpaceND
Definition
SpaceND.h:96
DGtal::SpaceND< 3, Integer >::Point
PointVector< dim, Integer > Point
Definition
SpaceND.h:110
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::GenericLatticeConvexHull
Aim: Implements the quickhull algorithm by Barber et al. barber1996, a famous arbitrary dimensional c...
Definition
GenericLatticeConvexHull.h:522
Point
MyPointD Point
Definition
testClone2.cpp:381
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
Space
SpaceND< 2 > Space
Definition
testSimpleRandomAccessRangeFromPoint.cpp:42
examples
geometry
tools
exampleGenericLatticeConvexHull.cpp
Generated on
for DGtal by
1.18.0