39 std::vector<PointVector> &new_polys) {
41 Partition_traits_2::Polygon_2 cgal_poly;
42 for (
auto const &pt : poly) {
43 cgal_poly.push_back(Partition_traits_2::Point_2(pt.x(), pt.y()));
48 if (cgal_poly.orientation() == CGAL::CLOCKWISE) {
49 cgal_poly.reverse_orientation();
52 std::list<Partition_traits_2::Polygon_2> partition_polys;
53 CGAL::y_monotone_partition_2(cgal_poly.vertices_begin(), cgal_poly.vertices_end(),
54 std::back_inserter(partition_polys));
58 new_polys.reserve(new_polys.size() + partition_polys.size());
59 for (
auto const &p : partition_polys) {
61 new_p.reserve(p.size());
62 std::transform(p.vertices_begin(), p.vertices_end(),
63 std::back_inserter(new_p),
64 [](
CGAL_Point2 const &pt) { return CGALtoCC(pt); });
65 new_polys.push_back(new_p);
70 double const half_width,
double const world_size,
71 std::vector<PointVector> &polygons) {
73 polygons.reserve(num_polygons);
75 for (
int i = 0; i < num_polygons; ++i) {
76 int num_vertices = rand.get_int(4, max_vertices);
78 poly.reserve(num_vertices);
79 std::list<CGAL_Point2> points;
81 std::back_inserter(points));
83 CGAL::random_polygon_2(num_vertices, std::back_inserter(poly_cgal),
85 auto bbox = poly_cgal.bbox();
88 bbox.ymax() - bbox.ymin());
91 CGAL::to_double(upper_right.x())),
93 CGAL::to_double(upper_right.y())));
94 for (
auto const &pt : poly_cgal) {
98 poly.push_back(new_pt);
100 polygons.push_back(poly);
void GenerateRandomPolygons(int const num_polygons, int const max_vertices, double const half_width, double const world_size, std::vector< PointVector > &polygons)
Generate random polygons.