CGAL: Identify convex hull facets when iterating over finite facets

Viewed 94

I would like to know if there is any method to identify the facets that are in the convex hull while iterating over finite facets of a Delaunay 3D triangulation

2 Answers

In CGAL, facets on the convex hull are all incident to the infinite vertex. So you simply have to look at the two vertices opposite to the facet and check if one of them is the infinite vertex.

Here is some example code to do identify faces on the convex hull from all the finite faces. Each facet it is a cell-vertex pair and the mirror_facet function provides the other cell-vertex pair that identifies the same facet. Then you can check if either cell (or either vertices) is infinite to decide if the facet is on the convex hull.

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>

#include <fstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

typedef CGAL::Delaunay_triangulation_3<K>  Triangulation;
typedef Triangulation::Point               Point;

int main( )
{
  // read some points from a file
  std::ifstream in("data/threed.cin");
  std::istream_iterator<Point> begin(in);
  std::istream_iterator<Point> end;

  // form the Delaunay triangulation of the points
  Triangulation T;
  T.insert(begin, end);

  // check each finite face to identify those on the convex hull    
  for (auto facet: T.finite_facets())
  {
    if (T.is_infinite(facet.first) ||
        T.is_infinite(T.mirror_facet(facet).first))
    {
      // this facet is on the convex hull
    }
    else
    {
      // this facet is not on the convex hull
    }
  }

  return 0;
}
Related