[Boost.Polygon] Union filling holes

Hi all,
I am using boost/polygon to do unions of multiple polygons, and I lose
holes that were in the input after the assign() operation. Here is code
that demonstrates the issue:
// Create outer contour
Point outer[] = {gtl::construct<Point>(0, 0),
gtl::construct<Point>(0, 10),
gtl::construct<Point>(10, 10),
gtl::construct<Point>(10, 0)};
// Create inner contour
Point inner[] = {gtl::construct<Point>(2, 2),
gtl::construct<Point>(8, 2),
gtl::construct<Point>(8, 8),
gtl::construct<Point>(2, 8)};
// Define inner contour as a polygon
polygon_with_holes_data<long> input_poly_inner;
gtl::set_points(input_poly_inner, inner, inner+4);
// Put inner polygon in a list
vector

Answering myself: for some reason,
polygon_set_data.insert_vertex_sequence() ignores the is_bool parameter.
Attached patch for quick and dirty fix.
Regards,
Julien
2014-10-09 17:56 GMT+02:00 Julien Nicoulaud
Hi all,
I am using boost/polygon to do unions of multiple polygons, and I lose holes that were in the input after the assign() operation. Here is code that demonstrates the issue:
// Create outer contour Point outer[] = {gtl::construct<Point>(0, 0), gtl::construct<Point>(0, 10), gtl::construct<Point>(10, 10), gtl::construct<Point>(10, 0)}; // Create inner contour Point inner[] = {gtl::construct<Point>(2, 2), gtl::construct<Point>(8, 2), gtl::construct<Point>(8, 8), gtl::construct<Point>(2, 8)}; // Define inner contour as a polygon polygon_with_holes_data<long> input_poly_inner; gtl::set_points(input_poly_inner, inner, inner+4); // Put inner polygon in a list vector
inners; inners.push_back(input_poly_inner); // Create input polygon as outer contour + inner polygon list polygon_with_holes_data<long> input_poly; gtl::set_points(input_poly, outer, outer+4); gtl::set_holes(input_poly, inners.begin(), inners.end()); // Create input polygon set, insert input polygon polygon_set_data<long> input_poly_set; input_poly_set.insert(input_poly); // Create output polygon set, assign input polygon set vector output_poly_set; assign(output_poly_set, input_poly_set); // Print result std::cout << output_poly_set.size() << " polys" << std::endl; std::cout << output_poly_set[0].size_holes() << " holes" << std::endl; This prints:
1 polys 0 holes
Any idea what I am doing wrong ?
Kind regards, Julien Nicoulaud

Hi Julien, Julien Nicoulaud wrote:
Answering myself: for some reason, polygon_set_data.insert_vertex_sequence() ignores the is_bool parameter. Attached patch for quick and dirty fix.
I don't know how active are Boost.Polygon maintainers but I think that you'd have better chances of fixing the bug if you created a pull request on GitHub either by modifying the file: https://github.com/boostorg/polygon/blob/develop/include/boost/polygon/polyg... directly on GitHub or checking out the repository of Boost, forking manually, running tests to be sure that everything works, etc., similar to the way described here: https://github.com/boostorg/geometry/wiki/Contribution-Tutorial If your fix wasn't merged in a long time you could then ask the CMT (https://svn.boost.org/trac/boost/wiki/CommunityMaintenance) for help. Regards, Adam
participants (2)
-
Adam Wulkiewicz
-
Julien Nicoulaud