JCash / voronoi

A C implementation for creating 2D voronoi diagrams
MIT License
632 stars 94 forks source link

How to support clip by nonconvex boundary? #50

Open manuel76413 opened 4 years ago

manuel76413 commented 4 years ago

Hi, is there any simple method to enable the library to support clip by nonconvex boundary? I tested when use concave polygon as clip polygon, the result is blank.

ehaimerl commented 2 years ago

Hi, does anybody have suggestions on this issue. I'd love to use the library in a C++ Program I wrote that's used in Dialect research (see http://www.dialectometry.com/) - but I do have concave clipping polygones (e.G. the boarders of France).

JCash commented 2 years ago

Depending on how complex your geometry is, one way to do it could be to first split your concave polygon into a list of convex polygons. Then you can use the list to clip the voronoi result several times.

However, it might just be less headache to implement something like a stencil mask, when you're rendering the result?

ehaimerl commented 1 year ago

May be something like this helps to understand the issue: Here is a simple Voronoi with concave boundary - I was drawing the poly-tiangles too. Looks like the algorithm doesn't get all intersections right? example

ehaimerl commented 1 year ago

here are the locations and the border files. I want to use this library to generate a Voronoi diagram of locations within France - cannot change the borders. clip_concave2.txt locations.txt