CGAL 6.1 - 2D Polygon Repair
Loading...
Searching...
No Matches
Polygon_repair/repair_non_zero_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>
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/draw_multipolygon_with_holes_2.h>
#endif
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/winding.wkt";
std::ifstream in(filename);
Polygon_with_holes_2 pin;
Multipolygon_with_holes_2 mp = CGAL::Polygon_repair::repair(pin, CGAL::Polygon_repair::Non_zero_rule());
#ifdef CGAL_USE_BASIC_VIEWER
#endif
if (mp.number_of_polygons_with_holes() > 1) {
} else {
CGAL::IO::write_polygon_WKT(std::cout, mp.polygons_with_holes()[0]);
}
return 0;
}
void draw(const P &p, const GSOptions &gso)
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:51
bool read_polygon_WKT(std::istream &in, Polygon &polygon)
std::ostream & write_polygon_WKT(std::ostream &out, const Polygon &poly)
std::ostream & write_multi_polygon_WKT(std::ostream &out, MultiPolygon &polygons)
Tag class to select the non zero rule when calling CGAL::Polygon_repair::repair().
Definition: Non_zero_rule.h:27