CGAL 6.0 - 2D Polygons
Loading...
Searching...
No Matches
Polygon/multipolygon.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Multipolygon_with_holes_2.h>
using Polygon_2 = CGAL::Polygon_2<Kernel>;
using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2<Kernel>;
using Multipolygon_with_holes_2 = CGAL::Multipolygon_with_holes_2<Kernel>;
int main() {
Point_2 p1_outer[] = {Point_2(0,0), Point_2(1,0), Point_2(1,1), Point_2(0,1)};
Point_2 p1_inner[] = {Point_2(0.2,0.2), Point_2(0.8,0.2), Point_2(0.8,0.8), Point_2(0.2,0.8)};
Polygon_with_holes_2 p1(Polygon_2(p1_outer, p1_outer+4));
Polygon_2 h(p1_inner, p1_inner+4);
p1.add_hole(h);
Point_2 p2_outer[] = {Point_2(0.4,0.4), Point_2(0.6,0.4), Point_2(0.6,0.6), Point_2(0.4,0.6)};
Polygon_with_holes_2 p2(Polygon_2(p2_outer, p2_outer+4));
Multipolygon_with_holes_2 mp;
mp.add_polygon_with_holes(p1);
mp.add_polygon_with_holes(p2);
for (auto const& p: mp.polygons_with_holes()) {
std::cout << p << std::endl;
}
return 0;
}
The class Multipolygon_with_holes_2 models the concept MultipolygonWithHoles_2.
Definition: Multipolygon_with_holes_2.h:35
The class Polygon_2 implements polygons.
Definition: Polygon_2.h:65
The class Polygon_with_holes_2 models the concept GeneralPolygonWithHoles_2.
Definition: Polygon_with_holes_2.h:43