Subject: Re: [geometry] Issues with difference
From: Barend Gehrels (barend_at_[hidden])
Date: 2019-03-07 21:09:57
Nice use case! Thanks for your message, I give some suggestions inline.
Op 7-3-2019 om 11:44 schreef Matthieu Beghin via Geometry:
> Hi there,
> I'm trying to solve my geometry problems with boost::geometry. I
> really enjoy the API but I'm facing a few issues. Maybe the solutions
> are simple, but I can't find my way. My context is: users are drawing
> shapes that are combined using union / intersection / difference, I
> use "buffer" to have a feathering effect around the shapes and in the
> end I triangulate the result and render with OpenGL.
> Situation 1: if I do a difference between two (valid) geometries that
> share a common segment, the result is invalid (bg::is_valid return
> false, it find some "turns"):
> Â Example:
Are you sure the input is closed and has the right (clockwise)
orientation? If not, please call bg::correct(poly1) and
bg::correct(poly2) before, such that you are sure they are right.
Indeed, if the input geometries are valid,Â then the result should be
valid. We currently have some issues with some floating point input, and
maybe this is the problem for you.
Can you try to define BOOST_GEOMETRY_NO_ROBUSTNESS and see if that
helps? This removes the rescaling (that we do internally). In a future
release, this (applying overlays without rescaling) will be the default.
I'm currently working on it.
> Situation 2: the difference between two valid geometries that have no
> common edge is invalid. The subtracted geometry has an inner hole but
> I suppose that should be supported...
> On this picture poly1 is in green, poly2 is in red (the red triangle is poly2 inner hole).
Indeed holes are supported. This is probably not a Floating Point issue,
so I guess this might be the orientation, could you try also here to
correct the input before calling difference?
If this all doesn't help, I will try to reproduce the problem.
Geometry list run by mateusz at loskot.net