File: ht2_example.cpp

package info (click to toggle)
cgal 6.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 144,952 kB
  • sloc: cpp: 811,597; ansic: 208,576; sh: 493; python: 411; makefile: 286; javascript: 174
file content (64 lines) | stat: -rw-r--r-- 2,481 bytes parent folder | download | duplicates (5)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <CGAL/Hyperbolic_Delaunay_triangulation_2.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>

#include <CGAL/point_generators_2.h>
#include <CGAL/Timer.h>

#include <iostream>
#include <vector>

typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<>  Gt;
typedef Gt::Point_2                                         Point_2;
typedef Gt::Circle_2                                        Circle_2;
typedef Gt::FT                                              FT;
typedef CGAL::Hyperbolic_Delaunay_triangulation_2<Gt>       Dt;
typedef CGAL::Creator_uniform_2<FT, Point_2>                Creator;

int main(int argc, char** argv)
{
  int N;
  if(argc < 2) {
    std::cout << "usage: " << argv[0] << " [number_of_points]" << std::endl;
    std::cout << "Defaulting to 100k points..." << std::endl;
    N = 100000;
  } else {
    N = atoi(argv[1]);
  }

  CGAL::Timer timer;
  CGAL::Random_points_in_disc_2<Point_2, Creator> in_disc;
  std::vector<Point_2> pts;
  std::vector<Point_2>::iterator ip;

  for(int i=0; i<N; ++i)
    pts.push_back(*(in_disc++));

  Dt dt_during;
  std::cout << "Insertion of points one by one (hyperbolic filtering at each step)"  << std::endl;
  std::cout << "===================================================================" << std::endl;
  timer.start();
  for(ip = pts.begin(); ip != pts.end(); ++ip)
    dt_during.insert(*ip);

  timer.stop();

  std::cout << "Number of vertices:         " << dt_during.number_of_vertices() << std::endl;
  std::cout << "Number of hyperbolic faces: " << dt_during.number_of_hyperbolic_faces() << std::endl;
  std::cout << "Number of hyperbolic edges: " << dt_during.number_of_hyperbolic_edges() << std::endl;
  std::cout << "Time:                       " << timer.time() << std::endl << std::endl;

  Dt dt_end;
  std::cout << "Insertion of point set (hyperbolic filtering only once at the end)"  << std::endl;
  std::cout << "===================================================================" << std::endl;
  timer.reset();
  timer.start();
  dt_end.insert(pts.begin(),pts.end());
  timer.stop();

  std::cout << "Number of vertices:         " << dt_end.number_of_vertices() << std::endl;
  std::cout << "Number of hyperbolic faces: " << dt_end.number_of_hyperbolic_faces() << std::endl;
  std::cout << "Number of hyperbolic edges: " << dt_end.number_of_hyperbolic_edges() << std::endl;
  std::cout << "Time:                       " << timer.time() << std::endl;

  return EXIT_SUCCESS;
}