mirror of https://github.com/CGAL/cgal
Example for Regular_triangulation
This commit is contained in:
parent
950978b2cf
commit
eae505f4f1
|
|
@ -1,6 +1,7 @@
|
|||
/*!
|
||||
\example barycentric_subdivision.cpp
|
||||
\example delaunay_triangulation.cpp
|
||||
\example regular_triangulation.cpp
|
||||
\example triangulation.cpp
|
||||
\example triangulation1.cpp
|
||||
\example triangulation2.cpp
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ if ( CGAL_FOUND )
|
|||
|
||||
create_single_source_cgal_program( "barycentric_subdivision.cpp" )
|
||||
create_single_source_cgal_program( "delaunay_triangulation.cpp" )
|
||||
create_single_source_cgal_program( "regular_triangulation.cpp" )
|
||||
create_single_source_cgal_program( "triangulation.cpp" )
|
||||
create_single_source_cgal_program( "triangulation_data_structure_dynamic.cpp" )
|
||||
create_single_source_cgal_program( "triangulation_data_structure_static.cpp" )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
#include <CGAL/Epick_d.h>
|
||||
#include <CGAL/point_generators_d.h>
|
||||
#include <CGAL/Regular_triangulation.h>
|
||||
#include <CGAL/Regular_triangulation_euclidean_traits.h>
|
||||
#include <CGAL/assertions.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
const int D = 5; // Dimension
|
||||
const int N = 100; // Number of points
|
||||
typedef CGAL::Epick_d< CGAL::Dimension_tag<D> > K;
|
||||
typedef CGAL::Regular_triangulation_euclidean_traits<K> Traits;
|
||||
typedef Traits::Bare_point Bare_point;
|
||||
typedef Traits::Weighted_point Weighted_point;
|
||||
typedef CGAL::Regular_triangulation<Traits> T;
|
||||
|
||||
int main()
|
||||
{
|
||||
// Instanciate a random point generator
|
||||
CGAL::Random rng(0);
|
||||
typedef CGAL::Random_points_in_cube_d<Bare_point> Random_points_iterator;
|
||||
Random_points_iterator rand_it(D, 1.0, rng);
|
||||
|
||||
// Generate N random points
|
||||
std::vector<Weighted_point> points;
|
||||
for (int i = 0; i < N; ++i)
|
||||
points.push_back(Weighted_point(*rand_it++, rng.get_double(0., 10.)));
|
||||
|
||||
T t(D);
|
||||
CGAL_assertion(t.empty());
|
||||
|
||||
// Insert the points in the triangulation
|
||||
t.insert(points.begin(), points.end());
|
||||
CGAL_assertion( t.is_valid() );
|
||||
std::cout << "Regular triangulation successfully computed: "
|
||||
<< t.number_of_vertices() << " vertices, "
|
||||
<< t.number_of_finite_full_cells() << " finite cells."
|
||||
<< std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue