File: draw_polygon_with_holes.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 (37 lines) | stat: -rw-r--r-- 1,439 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
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/draw_polygon_with_holes_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Polygon_with_holes_2<K>                       Polygon_with_holes_2;
typedef CGAL::Polygon_2<K>                                  Polygon_2;
typedef CGAL::Point_2<K>                                    Point;

int main()
{
  // create a polygon with three holes
  Polygon_2 outer_polygon;
  outer_polygon.push_back(Point(0,0)); outer_polygon.push_back(Point(9,0));
  outer_polygon.push_back(Point(6,8)); outer_polygon.push_back(Point(5,3));
  outer_polygon.push_back(Point(2,8)); outer_polygon.push_back(Point(0,8));

  std::vector<Polygon_2> holes(3);
  holes[0].push_back(Point(6,2)); holes[0].push_back(Point(7,1));
  holes[0].push_back(Point(7,3)); holes[0].push_back(Point(6,3));
  holes[0].push_back(Point(5,2));

  holes[1].push_back(Point(2,1)); holes[1].push_back(Point(3,1));
  holes[1].push_back(Point(3,3)); holes[1].push_back(Point(2,2));
  holes[1].push_back(Point(1,2));

  holes[2].push_back(Point(1,4)); holes[2].push_back(Point(2,4));
  holes[2].push_back(Point(2,5)); holes[2].push_back(Point(3,5));
  holes[2].push_back(Point(3,6)); holes[2].push_back(Point(1,6));

  Polygon_with_holes_2 p(outer_polygon, holes.begin(), holes.end());

  // And draw it.
  CGAL::draw(p);

  return EXIT_SUCCESS;
}