Search code examples
cgal

Get the index of Voronoi sites corresponding to input vertices


I am using the code found on github, in order to generate a Voronoi diagram using a set of input vertices and a rectangle.

I want to implement manually the weighted CVT algorithm. The problem is that when the Voronoi diagram is created, the order of vertices/sites is not the same as the input vertices. The result is actually a Half-edge data structure. So when I use the following code:

for (VD::Face_iterator fit = vd.faces_begin(),
  fit_end = vd.faces_end();
  fit != fit_end; ++fit)
  {
      std::cout << fit->dual()->point() << std::endl;

 }

The resulting vertices printed are in a different order than the input vertices. Is there a way to somehow get the new indices now faster. The only way I thought I could do this is to compare distances, but this will be really slow!


Solution

  • You can use the Triangulation_vertex_base_wih_info_2 in order to store the index in the vertices.