void GDALParceling::splitePoly(Polygon_with_holes_2 &p) { //Convex Hull (GDAL algorithm doesn't work without) Polygon_2 p_c; CGAL::convex_hull_2(p.outer_boundary().vertices_begin(), p.outer_boundary().vertices_end(), std::back_inserter(p_c)); //Cacluate Minimal Rect Polygon_2 p_m; CGAL::min_rectangle_2(p_c.vertices_begin(), p_c.vertices_end(), std::back_inserter(p_m)); Pwh_list_2 splitters(this->splitter(p_m)); if (splitters.size() == 0) { SFCGAL::Polygon split_geo(p); addToSystem(split_geo); return; } foreach (Polygon_with_holes_2 pwh, splitters) { Pwh_list_2 split_ress; CGAL::intersection(p, pwh, std::back_inserter(split_ress)); foreach(Polygon_with_holes_2 pwh_split, split_ress) { if (!pwh_split.outer_boundary().is_simple()) { DM::Logger(DM::Error) << "NOT SIMPLE"; } splitePoly(pwh_split); } }
void ParcelSplitWorker::splitePoly(Polygon_with_holes_2 &p) { //Convex Hull (GDAL algorithm doesn't work without) Polygon_2 p_c; CGAL::convex_hull_2(p.outer_boundary().vertices_begin(), p.outer_boundary().vertices_end(), std::back_inserter(p_c)); //Cacluate Minimal Rect Polygon_2 p_m; CGAL::min_rectangle_2(p_c.vertices_begin(), p_c.vertices_end(), std::back_inserter(p_m)); Pwh_list_2 splitters(this->splitter(p_m)); foreach (Polygon_with_holes_2 pwh, splitters) { Pwh_list_2 split_ress; CGAL::intersection(p, pwh, std::back_inserter(split_ress)); foreach(Polygon_with_holes_2 pwh_split, split_ress) { SFCGAL::Polygon split_geo(pwh_split); QString wkt = QString(split_geo.asText(16).c_str()); module->addToSystem(wkt); //emit resultPolygon(wkt); }