diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index ca90cd4e7bd..1d82be92a6c 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -78,6 +78,7 @@ if (EIGEN3_FOUND) create_single_source_cgal_program("test_pmp_bgl_named_params.cpp") create_single_source_cgal_program("remeshing_test.cpp" ) create_single_source_cgal_program("measures_test.cpp") + create_single_source_cgal_program("triangulate_faces_test.cpp") if(NOT (${EIGEN3_VERSION} VERSION_LESS 3.2.0)) create_single_source_cgal_program("fairing_test.cpp") diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp new file mode 100644 index 00000000000..75d5150c983 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +#include + +#include + +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point; +typedef CGAL::Surface_mesh Surface_mesh; + +int main() +{ + Surface_mesh mesh; + std::ifstream input("data/elephant.off"); + + if (!input || !(input >> mesh) || mesh.is_empty()) + { + std::cerr << "Not a valid off file." << std::endl; + return 1; + } + + CGAL::Polygon_mesh_processing::triangulate_faces(mesh); + CGAL::Polygon_mesh_processing::triangulate_faces(mesh, + CGAL::Polygon_mesh_processing::parameters::all_default()); + CGAL::Polygon_mesh_processing::triangulate_faces(faces(mesh), mesh); + CGAL::Polygon_mesh_processing::triangulate_faces(faces(mesh), mesh, + CGAL::Polygon_mesh_processing::parameters::all_default()); + + + BOOST_FOREACH(boost::graph_traits::face_descriptor fit, faces(mesh)) + if (next(next(halfedge(fit, mesh), mesh), mesh) + != prev(halfedge(fit, mesh), mesh)) { + CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh); + CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh, + CGAL::Polygon_mesh_processing::parameters::all_default()); + } +}