How to draw 2D Segment Delaunay Graphs in CGAL?

46 views Asked by At

I am trying to reproduce the visualizations shown on the user manual for 2D Segment Delaunay Graphs: The segment Voronoi diagram for a set of weakly (left) and strongly (right) intersecting sites.

However, I am struggling to understand how approach this issue. Concretely, how would I draw the graph corresponding to the SDG2 object created and populated in the following snippet?

// standard includes
#include <iostream>
#include <fstream>
#include <cassert>
#include <string>

// define the kernel
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;

// typedefs for the traits and the algorithm
#include <CGAL/Segment_Delaunay_graph_traits_2.h>
#include <CGAL/Segment_Delaunay_graph_2.h>

typedef CGAL::Segment_Delaunay_graph_traits_2<Kernel>  Gt;
typedef CGAL::Segment_Delaunay_graph_2<Gt>             SDG2;

using namespace std;

int main()
{
  ifstream ifs("data/sites2.cin");
  assert( ifs );

  SDG2          sdg;
  SDG2::Site_2  site;

  // read the sites from the stream and insert them in the diagram
  while ( ifs >> site ) { sdg.insert( site ); }

  ifs.close();

  // validate the diagram
  assert( sdg.is_valid(true, 1) );
  cout << endl << endl;
  return 0;
}

I have already seen that the Segment_Delaunay_Graph_2 class exposes the function draw_dual that takes a stream and outputs the sites. When passing std::cout, the sites were simply printed to the standard output, which is nice, but far from a visualization.

Looking at other examples (e.g. CGAL-5.0/demo/interpolation/surface_voronoi.cpp), I see that one can use a CGAL::Geomview_stream and pass this to the draw_dual function, but I am unsure if the same applies to the draw_dual function defined in Segment_Delaunay_Graph_2.

0

There are 0 answers