File: fast_location_3.cpp

package info (click to toggle)
cgal 3.6.1-2
  • links: PTS
  • area: non-free
  • in suites: squeeze
  • size: 62,184 kB
  • ctags: 95,782
  • sloc: cpp: 453,758; ansic: 96,821; sh: 226; makefile: 120; xml: 2
file content (35 lines) | stat: -rw-r--r-- 1,001 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
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Random.h>

#include <vector>
#include <cassert>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_3<K, CGAL::Fast_location> Delaunay;
typedef Delaunay::Point Point;

int main()
{
  // generating points on a grid.
  std::vector<Point> P;

  for (int z=0 ; z<20 ; z++)
    for (int y=0 ; y<20 ; y++)
      for (int x=0 ; x<20 ; x++)
	  P.push_back(Point(x,y,z));

  // building their Delaunay triangulation.
  Delaunay T(P.begin(), P.end());

  assert( T.number_of_vertices() == 8000 );

  // performing nearest vertex queries to a series of random points,
  // which is a case where the Fast_location policy is beneficial.
  for (int i=0; i<10000; ++i)
    T.nearest_vertex(Point(CGAL::default_random.get_double(0, 20),
			   CGAL::default_random.get_double(0, 20),
			   CGAL::default_random.get_double(0, 20)));

  return 0;
}