File: splitter_worst_cases.cpp

package info (click to toggle)
cgal 4.9-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 85,584 kB
  • sloc: cpp: 640,841; ansic: 140,696; sh: 708; fortran: 131; makefile: 114; python: 92
file content (63 lines) | stat: -rw-r--r-- 2,329 bytes parent folder | download | duplicates (2)
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
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/Search_traits_2.h>

typedef CGAL::Simple_cartesian<double>                Kernel;
typedef CGAL::Search_traits_2<Kernel>                 Traits_2;
typedef Kernel::Point_2                               Point_2;
typedef CGAL::Sliding_midpoint<Traits_2>              Sliding_midpoint;
typedef CGAL::Median_of_rectangle<Traits_2>           Median_of_rectangle;
typedef CGAL::Euclidean_distance<Traits_2>            Distance;
typedef CGAL::Orthogonal_k_neighbor_search<Traits_2,Distance,Sliding_midpoint>     Neighbor_search_sliding;
typedef CGAL::Orthogonal_k_neighbor_search<Traits_2,Distance,Median_of_rectangle>  Neighbor_search_median;
typedef Neighbor_search_sliding::Tree                 Tree_sliding;
typedef Neighbor_search_median::Tree                  Tree_median;

typedef std::vector<Point_2>                          Points;

int main()
{
  Points sliding_worst_case;
  for (int i = 0 ,j = 1; i < 10 ; ++i , j *= 2){
    sliding_worst_case.push_back(Point_2(((double)i)/10 , 0));
    sliding_worst_case.push_back(Point_2( (double)j , 0));    
  }

  Sliding_midpoint sliding(10);
  Median_of_rectangle median(10);

  Tree_sliding tree1(sliding_worst_case.begin(), sliding_worst_case.end() , sliding);
  tree1.build();

  std::cout << "Worst case tree for Sliding midpoint and Midpoint of max spread : "<<std::endl;
  tree1.statistics(std::cout);
  tree1.clear();
  std::cout<<std::endl<<"Same data with median splitter:"<<std::endl;

  Tree_median tree2(sliding_worst_case.begin(), sliding_worst_case.end() , median );
  tree2.statistics(std::cout);
  tree2.clear();

  Points median_worst_case;
  for(int i = 0 ; i < 19 ; ++i){
    median_worst_case.push_back(Point_2( 0 , i));
  }
  median_worst_case.push_back(Point_2(20,0));

 
  Tree_median tree3(median_worst_case.begin() , median_worst_case.end() , median);

  tree3.build();
  std::cout <<std::endl<< "Worst case tree for Median of rectangle, Median of max spread : "<<std::endl;
  tree3.statistics(std::cout);
  tree3.clear();

  std::cout<<std::endl<<"Same data with midpoint splitter:"<<std::endl;

  Tree_sliding tree4(median_worst_case.begin() , median_worst_case.end() , sliding);

  tree4.build();
  tree4.statistics(std::cout);
  tree4.clear();
  return 0;
}