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?