I have a rectangle with a circle that is located inside the rectangle. Now I do a boolean subtract operation where the circle is subtracted from the larger rectangle using boost::polygon and the following (pseudo) code:
boost::polygon::polygon_with_holes_data<int> rect;
boost::polygon::polygon_with_holes_data<int> circle;
// fill both with data here
boost::polygon::polygon_set_data<int> result=rect-circle;
After that "result" contains a bunch of coordinate-pairs where each of them are marked with an additional value -1 or 1. Then I fetch the resulting data the following way:
std::vector<boost::polygon::polygon_data<int>> outputData;
result.get<std::vector<boost::polygon::polygon_data<int>>>(outputData);
Now "outputData" contains a list of coordinates which form the following result:
So the hole is incorporated within one complete, closed polygon coordinate array where I would have expected something like boost::polygon::polygon_with_holes_data where the outline and the holes would have been separated.
So my question: am I doing something wrong here? How do I get the outline and the hole separated so that I can get rid of this extra line which connects them? Is there a function to fetch boost::polygon::polygon_with_holes_data out of the returned boost::polygon::polygon_set_data or what else is the magic here?
Thanks :-)

I took the trouble to generate some data myself. I don't know what data you use, nor how you render it. My suspicion is something is wrong in those processes:
Let's create a polygon_data factories:
So far so good. For the circle I used your new discovery from your other question:
Now let's start out with the straight-forward:
Prints
Convert And Check
Now to see whether any of these geometries would render correctly, I know no other technique than via Boost Geometry¹
So, let's convert to a
polygon_with_holes_dataand do some checks:The asserts pass, and this prints the expected:
Which correctly matches the difference area.
Rendering SVG
Now we adapt in Boost Geometry and write a SVG:
This writes the WKT and
output.svg:Looks fine here.
What Could Be Wrong? How To Debug?
Like I mentioned in my comments, many library/tools have restrictions/invariants on the input they take. Things like the orientation of outer vs inner rings, self intersections and the presence of closing points on polygon rings.
Now, if you don't know what data is acceptable, you can hit the docs, or you can use the library API to diagnose. For example in Boost Geometry I like to make a quick-and-dirty diagnostic function:
You can add
wktprinting to debug what changes are actually applied.See e.g. boost read_wkt produced invalid polygon for examples of diagnostics and fixes.
Live Demo
As always: Live On Coliru
Prints
¹ (I don't know how to output/input any geometry data using Boost Polygon, and I don't have any WKT/DSV capable rendering tools).