File: regular_triangulation.cpp

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (41 lines) | stat: -rw-r--r-- 1,236 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Regular_triangulation.h>
#include <cassert>

#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<K>                  T;
typedef K::Point_d                                      Bare_point;
typedef K::Weighted_point_d                             Weighted_point;

int main()
{
  // Instantiate 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);
  assert(t.empty());

  // Insert the points in the triangulation
  t.insert(points.begin(), points.end());
  assert( 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;
}