The Polygon Mesh Processing package provides the function CGAL::Polygon_mesh_processing::triangulate_faces
with multiple overloads. The simplest thing to do would be
typedef CGAL::Simple_cartesian<float> Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;
Polyhedron_3 polyhedron = load_my_polyhedron();
CGAL::Polygon_mesh_processing::triangulate_faces(polyhedron);
After that, all faces in polyhedron
are triangles.
The function modifies the model in-place, so one has to use a HalfedgeDS
that supports removal. This is the default, but, for example, HalfedgeDS_vector
won't do.
See also an official example that uses Surface_mesh
instead of Polyhedron_3
:
Polygon_mesh_processing/triangulate_faces_example.cpp