CGAL 6.1.1 - 2D Polygons

Loading...
Searching...
No Matches
Polygon/draw_polygon_with_holes.cpp
#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;
}
CGAL::Exact_predicates_inexact_constructions_kernel
CGAL::Point_2
CGAL::Polygon_2
The class Polygon_2 implements polygons.
Definition: Polygon_2.h:65
CGAL::Polygon_with_holes_2
The class Polygon_with_holes_2 models the concept GeneralPolygonWithHoles_2.
Definition: Polygon_with_holes_2.h:43
CGAL::draw
void draw(const MPH &aph)
opens a new window and draws aph, an instance of the CGAL::Multipolygon_with_holes_2 class.