52#include "DGtal/base/Common.h"
53#include "DGtal/kernel/PointVector.h"
54#include "DGtal/shapes/SurfaceMesh.h"
55#include "DGtal/io/writers/SurfaceMeshWriter.h"
56#include "DGtal/geometry/volumes/ConvexityHelper.h"
60int main(
int argc,
char* argv[] )
62 int nb = argc > 1 ? atoi( argv[ 1 ] ) : 100;
63 double dR = argc > 2 ? atof( argv[ 2 ] ) : 10.;
64 double eps = argc > 3 ? atof( argv[ 3 ] ) : 0.1;
68 std::vector< Point > V;
69 const auto R2 = dR * dR;
70 const int R = ceil( dR );
71 for (
int i = 0; i < nb; ) {
72 Point p( rand() % (2*R+1) - R, rand() % (2*R+1) - R, rand() % (2*R+1) - R );
73 if ( p.squaredNorm() <= R2 ) { V.push_back( p ); i++; }
80 trace.
error() <<
"Input set of points is not full dimensional." << std::endl;
84 std::cout << dcomplex << std::endl;
86 std::vector< RealPoint > positions;
87 std::vector< std::vector< Index > > facets;
89 for (
auto c = 0; c < dcomplex.
nbCells(); ++c )
93 std::map< Index, Index > v2v;
94 for (
auto v : c_vtcs ) {
97 positions.push_back( b + ( x - b ) * ( 1.0 - eps ) );
99 for (
const auto& f : dcomplex.
cellFaces( c ) ) {
101 for (
auto& vertex : f_vtcs )
102 vertex = v2v[ vertex ];
103 facets.push_back( f_vtcs );
107 SMesh mesh( positions.cbegin(), positions.cend(),
108 facets.cbegin(), facets.cend() );
110 std::ofstream out(
"delaunay3d.obj" );
SurfaceMesh< RealPoint, RealVector > SMesh
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...
const VertexRange & cellVertices(const Cell c) const
Point position(const Vertex v) const
VertexRange faceVertices(const Face f) const
RealPoint toReal(const Point p) const
RealPoint cellBarycenter(const Cell c) const
void requireFaceGeometry()
Forces the computation of face geometry.
const FaceRange & cellFaces(const Cell c) const
static bool computeDelaunayCellComplex(ConvexCellComplex< Point > &cell_complex, const PointRange &input_points, bool remove_duplicates=true)
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 ...