CGAL 6.2 - 2D Polygon Repair

Loading...
Searching...
No Matches
Polygon_repair/repair_polygon_2.cpp
#include <iostream>
#include <fstream>
#include <string>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_repair/repair.h>
#include <CGAL/IO/WKT.h>
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using Point_2 = Kernel::Point_2;
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(int argc, char* argv[]) {
const char* filename = (argc > 1) ? argv[1] : "data/bridge-edge.wkt";
std::ifstream in(filename);
Polygon_with_holes_2 pin;
CGAL::IO::read_polygon_WKT(in, pin);
Multipolygon_with_holes_2 mp = CGAL::Polygon_repair::repair(pin);
if (mp.number_of_polygons_with_holes() > 1) {
CGAL::IO::write_multi_polygon_WKT(std::cout, mp);
} else {
CGAL::IO::write_polygon_WKT(std::cout, mp.polygons_with_holes()[0]);
}
return 0;
}
CGAL::Exact_predicates_inexact_constructions_kernel
CGAL::Multipolygon_with_holes_2
CGAL::Polygon_2
CGAL::Polygon_with_holes_2
Kernel::Point_2
CGAL::Polygon_repair::repair
Multipolygon_with_holes_2< Kernel, Container > repair(const Polygon_2< Kernel, Container > &p, Rule=Rule())
repairs polygon p using the given rule
Definition: repair.h:52
CGAL::IO::read_polygon_WKT
bool read_polygon_WKT(std::istream &in, Polygon &polygon)
CGAL::IO::write_polygon_WKT
std::ostream & write_polygon_WKT(std::ostream &out, const Polygon &poly)
CGAL::IO::write_multi_polygon_WKT
std::ostream & write_multi_polygon_WKT(std::ostream &out, const MultiPolygon &polygons)
Kernel