53 #include "DGtal/base/Common.h"
55 #include "DGtal/geometry/tools/QuickHull.h"
57 #include "DGtal/shapes/SurfaceMesh.h"
58 #include "DGtal/io/writers/SurfaceMeshWriter.h"
60 double rand01() {
return (
double) rand() / (double) RAND_MAX; }
63 int main(
int argc,
char* argv[] )
65 int nb = argc > 1 ? atoi( argv[ 1 ] ) : 100;
66 double R = argc > 2 ? atof( argv[ 2 ] ) : 10.0;
67 double precision = argc > 3 ? atof( argv[ 3 ] ) : 1024.0;
74 std::vector< RealPoint > V;
75 const double R2 = R * R;
76 for (
int i = 0; i < nb; ) {
78 if ( p.squaredNorm() < R2 ) { V.push_back( p ); i++; }
82 Kernel3D kernel( precision );
83 QuickHull3D hull( kernel );
85 hull.computeConvexHull();
86 std::cout <<
"#points=" << hull.nbPoints()
87 <<
" #vertices=" << hull.nbVertices()
88 <<
" #facets=" << hull.nbFacets() << std::endl;
91 double total_time = 0;
92 std::for_each( hull.timings.cbegin(), hull.timings.cend(),
93 [&total_time] (
double t ) { total_time += t; } );
94 std::cout <<
"purge duplicates= " << round(hull.timings[ 0 ]) <<
" ms." << std::endl;
95 std::cout <<
"init simplex = " << round(hull.timings[ 1 ]) <<
" ms." << std::endl;
96 std::cout <<
"quickhull core = " << round(hull.timings[ 2 ]) <<
" ms." << std::endl;
97 std::cout <<
"compute vertices= " << round(hull.timings[ 3 ]) <<
" ms." << std::endl;
98 std::cout <<
"total time = " << round(total_time) <<
" ms." << std::endl;
102 std::vector< RealPoint > positions;
103 hull.getVertexPositions( positions );
104 std::vector< std::vector< std::size_t > > facets;
105 hull.getFacetVertices( facets );
107 SMesh mesh( positions.cbegin(), positions.cend(), facets.cbegin(), facets.cend() );
111 std::ofstream out(
"qhull.obj" );
Aim: Implements basic operations that will be used in Point and Vector classes.
int main(int argc, char *argv[])
double rand01()
[QuickHull3D-Includes]
Z3i this namespace gathers the standard of types for 3D imagery.
Aim: a geometric kernel to compute the convex hull of floating points with integer-only arithmetic....
Aim: Implements the quickhull algorithm by Barber et al. , a famous arbitrary dimensional convex hull...
static bool writeOBJ(std::ostream &output, const SurfaceMesh &smesh)
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...