File: largest_empty_rectangle.cpp

package info (click to toggle)
cgal 4.0-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 65,068 kB
  • sloc: cpp: 500,870; ansic: 102,544; sh: 321; python: 92; makefile: 75; xml: 2
file content (40 lines) | stat: -rw-r--r-- 1,219 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
#include <CGAL/Cartesian.h>
#include <CGAL/Iso_rectangle_2.h>
#include <CGAL/Largest_empty_iso_rectangle_2.h>

#include <fstream>

typedef double                                 Number_Type;
typedef CGAL::Cartesian<Number_Type>           K;
typedef CGAL::Largest_empty_iso_rectangle_2<K> Largest_empty_iso_rect_2;
typedef K::Iso_rectangle_2                     Iso_rectangle_2;
typedef K::Point_2                             Point_2;

int main()
{
  Iso_rectangle_2 bounding_box(Point_2(0, 0), Point_2(10, 10));

  Largest_empty_iso_rect_2 leir(bounding_box);
  leir.insert(Point_2(6,1));
  leir.insert(Point_2(1,8));
  leir.insert(Point_2(9,5));
  leir.insert(Point_2(5,9));

  std::cout << "The input bounding box is " << bounding_box << std::endl;

  std::cout << "The input point set is:" << std::endl;
  for(Largest_empty_iso_rect_2::const_iterator it = leir.begin();
      it != leir.end();
      ++it){
    const Point_2& p = *it;
    std::cout << "   " << p << std::endl;
  }

  Iso_rectangle_2 b = leir.get_largest_empty_iso_rectangle();

  std::cout << std::endl << "The largest empty iso rectangle is " <<
               b << std::endl;
  std::cout << "Its area is " << b.area() << std::endl;

  return 0;
}