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"
61int main(
int argc,
char* argv[] )
63 int nb = argc > 1 ? atoi( argv[ 1 ] ) : 100;
64 double dR = argc > 2 ? atof( argv[ 2 ] ) : 10.0;
71 std::vector< Point > V;
72 const double R2 = dR * dR;
73 const int R = (int) ceil( dR );
74 for (
int i = 0; i < nb; ) {
75 Point p( rand() % (2*R+1) - R, rand() % (2*R+1) - R, rand() % (2*R+1) - R );
76 if ( p.squaredNorm() < R2 ) { V.push_back( p ); i++; }
83 std::cout <<
"#points=" << hull.
nbPoints()
85 <<
" #facets=" << hull.
nbFacets() << std::endl;
88 double total_time = 0;
90 [&total_time] (
double t ) { total_time += t; } );
91 std::cout <<
"purge duplicates= " << round(hull.
timings[ 0 ]) <<
" ms." << std::endl;
92 std::cout <<
"init simplex = " << round(hull.
timings[ 1 ]) <<
" ms." << std::endl;
93 std::cout <<
"quickhull core = " << round(hull.
timings[ 2 ]) <<
" ms." << std::endl;
94 std::cout <<
"compute vertices= " << round(hull.
timings[ 3 ]) <<
" ms." << std::endl;
95 std::cout <<
"total time = " << round(total_time) <<
" ms." << std::endl;
99 std::vector< RealPoint > positions;
101 std::vector< std::vector< std::size_t > > facets;
104 SMesh mesh( positions.cbegin(), positions.cend(), facets.cbegin(), facets.cend() );
108 std::ofstream out(
"qhull.obj" );
SurfaceMesh< RealPoint, RealVector > SMesh
Z3i this namespace gathers the standard of types for 3D imagery.
Aim: a geometric kernel to compute the convex hull of digital points with integer-only arithmetic.
Aim: Implements the quickhull algorithm by Barber et al. , a famous arbitrary dimensional convex hull...
bool setInput(const std::vector< InputPoint > &input_points, bool remove_duplicates=true)
bool getFacetVertices(std::vector< IndexRange > &facet_vertices) const
bool getVertexPositions(std::vector< OutputPoint > &vertex_positions)
bool computeConvexHull(Status target=Status::VerticesCompleted)
std::vector< double > timings
Timings of the different phases: 0: init, 1: facets, 2: vertices.
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 ...