I find that in the boost library, for the voronoi diagram, some edge data is infinite. According to the instruction, it has to be clipped. But I cant find how to do it. Could anybody can give me a example code, please?
Thx
I find that in the boost library, for the voronoi diagram, some edge data is infinite. According to the instruction, it has to be clipped. But I cant find how to do it. Could anybody can give me a example code, please?
Thx
This is a rather stale question, but I found it when trying to solve the exact same problem. It's only fair to share the solution I hit upon so the next poor sap doesn't have to figure it out themselves.
I have no idea if this is a particularly good way to do things, and I suspect it would struggle if you started using curved cells, but it worked OK for my purposes.
The basic problem is that you only have one vertex for the infinite edges, so you have to calculate the direction vector yourself. The direction to use is perpendicular to the vector between the two points separated by the edge.
I wrote a program to clip the infinite edges in Voronoi cells so the edges are confined inside a rectangular bounding box. The code is in https://github.com/datajaguar/jaguardb/blob/master/src/JagCGAL.cc
getIntersectionPointWithBox() method basically checks each side ( total 4 sides) of the bounding box and gets the intersection point if there is one. fillInCorners() method checks missing points around the bounding box and add the corner coordinates to the edges. To make a polygon for each cell, it adds the first point at the end to make the polygon closed.
I found this code segment here: http://www.boost.org/doc/libs/1_55_0/libs/polygon/example/voronoi_visualizer.cpp
It might be missing some class variables or methods, but the logic is what is important here.