Computation of the convex hull of a list of 3D points by Quick Hull algorithm.
#include "DGtal/base/Common.h"
#include "DGtal/geometry/volumes/ConvexityHelper.h"
#include "DGtal/shapes/SurfaceMesh.h"
#include "DGtal/io/writers/SurfaceMeshWriter.h"
#include "ConfigExamples.h"
double rand01() {
return (
double) rand() / (double) RAND_MAX; }
int main(
int argc,
char* argv[] )
{
int precision = argc > 1 ? atoi( argv[ 1 ] ) : 100;
std::string inputFilename = argc > 2
? std::string( argv[ 2 ] )
: examplesPath + "samples/bunny.dat" ;
std::vector< RealPoint > points;
std::ifstream finput( inputFilename.c_str() );
std::string linestr;
while ( std::getline( finput, linestr ) )
{
std::istringstream iss( linestr );
double a, b, c;
if ( ! (iss >> a >> b >> c) ) break;
}
trace.
info() <<
"Read " << points.size() <<
" 3D points." << std::endl;
const auto polytope
= Helper::computeRationalPolytope( points, precision );
bool ok = Helper::computeConvexHullBoundary( mesh, points, precision );
std::ofstream out( "qhull-mesh.obj" );
out.close();
bool ok2 = Helper::computeConvexHullBoundary( polysurf, points, precision );
bool ok3 = Helper::computeConvexHullCellComplex( cvx_complex, points, precision );
return ( ok && ok2 && ok3 ) ? 0 : 1;
}
Aim: Represents a polygon mesh, i.e. a 2-dimensional combinatorial surface whose faces are (topologic...
double rand01()
[QuickHull3D-Includes]
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: represents a d-dimensional complex in a d-dimensional space with the following properties and re...
Aim: Provides a set of functions to facilitate the computation of convex hulls and polytopes,...
Aim: An helper class for writing mesh file formats (Waverfront OBJ at this point) and creating a Surf...
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
PointVector< 3, double > RealPoint