How to work with cgal circulators?
Asked Answered
T

1

6

I'm trying to make delaunay triangulation of point set, find nearest point to input point, and get it's incident vertices, but somehow following code doesn't work.

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Point Point;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Vertex_circulator Vertex_circulator;
int main( )
{
  std::ifstream in("data.txt");
  assert(in);
  std::istream_iterator<Point> begin(in);
  std::istream_iterator<Point> end;
  Triangulation T;
  T.insert(begin, end);
  std::cout << T.number_of_vertices() <<std::endl;
  Vertex_handle handle = T.nearest_vertex(Point(1, 1));
  std::cout << handle->point() << std::endl;
  std::cout<<"incidents: \n" << std::endl;
  Vertex_circulator circulator = T.incident_vertices(handle), done(circulator);
  do
    {
      std::cout << circulator->point() << std::endl;
    } while(++circulator != done);
  return 0;
}

For example if data.txt is

2 3
1 1
1 0

output is

3
1 1
incidents:

1 0
2 3
2.02461e-307 6.94896e-308

Why do I have last line?

Tailored answered 2/4, 2014 at 10:57 Comment(0)
V
7

The 2D triangulations of CGAL have an infinite vertex connected to all the vertices of the convex hull (see the user manual for details).

You can use the is_infinite function to test if a simplex is infinite.

Valenzuela answered 2/4, 2014 at 11:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.