I'm currently using boost::polygon::detail::resize() function to enlarge or shrink the outline of a polygon by a specific size. This is working well and gives proper results.
Now in some cases, depending on the input shape, the resulting polygon (red) contains vector lines which are very close to each other (black line):
What I want to do is to have a minimum distance over all neighbouring lines of such a polygon. For this example this means, the resulting polygon needs to be modified and a vector line (blue) has to be added, replacing the red lines below of it. This of course would change the shape of the polygon but would keep it conform to the minimum-distance-rule. In this example picture given above, the new, blue line would have the length of the required minimum distance.
My questions: are there any boost-functions available which could do that job? If yes: which ones and how have they to be used?
Thanks!

Converted your image into code using:
That's:
Using
Let's reproduce the angle measurements:
Live On Coliru
Prints
With the side-effect of writing
output.svgcontainingPerforming a cut-off
Detecting a sharp angle, we can check the cutoff length that would be required for the distance between the legs to grow beyond
min_distance:Let's create a helper to manually interpolate the cutoff points:
Now we can use it to get new mid-points instead of P2:
Now there's the degenerate case where both legs are too short for the cutoff, meaning the mid-point will disappear:
Next up, there might be one leg that disappears:
So far so good. If none of the legs disappear, we need to cut-off the sharp point by introducing an extra point (and updating the original mid-point):
Live Demo
Live On Coliru
Prints
And the resulting
output.svg:Conclusion
Hopefully that helps.
Note that the code has limitations as written, because for simplicity I used
segment_iterator.Due to the segment-iterator loop, currently only the first sharp corner might be treated, unless they can be treated without invalidating the iterators. You'd either have to repeat the loop or rewrite the loop in terms of indices instead of using the
segment_iterators.Also due to the segment iterators, I resorted to an ugly
const_castto update existing points, instead of going throught the geometry interface. This would not pass my own code review :)Finally, nothing is decided when even the distance P1-P3 directly exceeded the
min_distance(you didn't specify anything about this potentiality in the question).