0

I am trying to triangulate the faces of a polyhedron using CGAL 4.13 and the following code snippet, which takes a polyhedron definition file in OFF format on stdin:

#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
using namespace std;

int main (void) {
    Polyhedron p;
    cin >> p;
    if (!CGAL::Polygon_mesh_processing::triangulate_faces(p)) 
        cerr << p << endl << "Triangulation failed!" << endl;
}

However, I observe the following warning:

CGAL warning: check violation! Expression : false File : /usr/include/CGAL/Constrained_triangulation_2.h Line : 902 Explanation: You are using an exact number type, using a Constrained_triangulation_plus_2 class would avoid cascading intersection computation and be much more efficient This message is shown only if CGAL_NO_CDT_2_WARNINGis not defined.

Refer to the bug-reporting instructions at https://www.cgal.org/bug_report.html

and the triangulation fails. The message Triangulation failed! is printed as well as the polyhedron definition, which clearly shows some faces with 5 or even 7 vertices.

Unfortunately the OFF representation of the polyhedron is 8070 lines long, and I failed to create a smaller example to reproduce the issue. So I uploaded it here. It is only available for 30 days there, if someone can suggest a better place to upload it, I will consider that.

After compiling, for example with

g++ -O3 tri.cpp -o tri -lCGAL -lgmp -lmpfr -Wall

the issue can be reproduced with

./tri < poly.off

I am not sure if the failure of the triangulation is related to the warning; how could I use the Constrained_triangulation_plus_2 class with CGAL::Polygon_mesh_processing::triangulate_faces()? Is this possible at all? Triangulation of a face is not a complicated thing, how can this fail in the first place?

Ctx
  • 18,090
  • 24
  • 36
  • 51
  • See if this is relevant: http://cgal-discuss.949826.n4.nabble.com/Issues-with-Polygon-mesh-processing-triangulate-face-td4664131.html – Zohar Levi Mar 13 '19 at 20:04

1 Answers1

0

If you don't need an exact kernel, you should use CGAL::Exact_predicates_inexact_constructions_kernel, which will silent the warning and then probably the triangulation won't fail. If you do need an exact kernel, you can use CGAL::copy_face_graph() to easily switch from Epeck to Epick, triangulate, then switch back to Epeck.

mgimeno
  • 726
  • 1
  • 4
  • 7