| 271 | } |
| 272 | |
| 273 | void set_point_inside(const Polygon_wh_2& inpoly, svgfill::polygon_2& outpoly) |
| 274 | { |
| 275 | /* |
| 276 | std::cout << std::endl; |
| 277 | for (auto& p : inpoly.outer_boundary()) { |
| 278 | std::cout << " " << p; |
| 279 | } |
| 280 | std::cout << std::endl; |
| 281 | */ |
| 282 | // create Delaunay triangulation and return the centroid of the largest triangle. |
| 283 | CGAL::Polygon_triangulation_decomposition_2<Kernel> decompositor; |
| 284 | std::list<Polygon_2> decom_polies; |
| 285 | decompositor(inpoly, std::back_inserter(decom_polies)); |
| 286 | decom_polies.sort([](const Polygon_2& a, const Polygon_2& b) { |
| 287 | return a.area() > b.area(); |
| 288 | }); |
| 289 | if (!decom_polies.empty()) { |
| 290 | const Polygon_2& largest = decom_polies.front(); |
| 291 | auto triangle = poly_to_triangle(largest); |
| 292 | /* |
| 293 | for (auto& p : decom_polies) { |
| 294 | std::cout << "a " << CGAL::to_double(poly_to_triangle(largest).area()) << std::endl; |
| 295 | } |
| 296 | std::cout << "triangle area " << CGAL::to_double(triangle.area()) << std::endl; |
| 297 | */ |
| 298 | outpoly.point_inside = create_point(CGAL::centroid(triangle)); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | Arrangement_2 arr; |
| 303 | float total, i; |