|
Boost Users : |
Subject: Re: [Boost-users] [Boost.Polygon] Union filling holes
From: Julien Nicoulaud (julien.nicoulaud_at_[hidden])
Date: 2014-10-27 11:56:56
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 <julien.nicoulaud_at_[hidden]>:
> 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<polygon_with_holes_data<long> > 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<polygon_with_holes_data<long> > 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
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net