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 index 5f239c7dfaa..61546684005 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp @@ -1,13 +1,14 @@ #include #include - #include +#include + #include #include #include #include -#include +#include #include @@ -117,21 +118,17 @@ test_triangulate_face() return false; } - unsigned int nb = 0; for(typename boost::graph_traits::face_descriptor fit : faces(mesh)) { - if (nb > 4) - break; - else if (next(next(halfedge(fit, mesh), mesh), mesh) - != prev(halfedge(fit, mesh), mesh)) + if (next(next(halfedge(fit, mesh), mesh), mesh) != prev(halfedge(fit, mesh), mesh)) { - if(CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh)) - ++nb; - else + if(!CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh)) assert(false); } } + assert(CGAL::is_triangle_mesh(mesh)); + return true; } @@ -156,6 +153,9 @@ test_triangulate_triangle_face() if(!CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh, CGAL::parameters::geom_traits(K()))) assert(false); } + + assert(CGAL::is_triangle_mesh(mesh)); + return true; } @@ -238,9 +238,54 @@ test_dual_with_various_faces() if(!CGAL::Polygon_mesh_processing::triangulate_face(fit, sm_dual)) assert(false); } + + assert(CGAL::is_triangle_mesh(sm_dual)); + return true; } +template +bool +test_triangulate_soup() +{ + typedef typename K::Point_3 Point; + typedef CGAL::Surface_mesh Surface_mesh; + + Surface_mesh mesh; + std::ifstream input(CGAL::data_file_path("meshes/elephant.off")); + + if (!input || !(input >> mesh) || mesh.is_empty()) + { + std::cerr << "Not a valid off file." << std::endl; + return false; + } + + typedef typename boost::property_map::type Pmap; + Pmap vpmap = get_property_map(boost::vertex_point, mesh); + + CGAL::Dual dual(mesh); + // copy dual to a sm + Surface_mesh sm_dual; + CGAL::copy_face_graph(dual, sm_dual, + CGAL::parameters::vertex_point_map( + Dual_vpm(mesh, vpmap))); + + std::vector points; + std::vector > polygons; + CGAL::Polygon_mesh_processing::polygon_mesh_to_polygon_soup(sm_dual, points, polygons); + + bool success = CGAL::Polygon_mesh_processing::triangulate_polygons(points, polygons); + for(std::size_t i = 0; i < polygons.size(); ++i) + { + assert(polygons[i].size() == 3); + } + + // For compilation + success = CGAL::Polygon_mesh_processing::triangulate_polygons(points, polygons, CGAL::parameters::geom_traits(K())); + + return success; +} + int main() { assert(test_triangulate_faces()); @@ -249,6 +294,7 @@ int main() assert(test_triangulate_face()); assert(test_triangulate_triangle_face()); assert(test_dual_with_various_faces()); + assert(test_triangulate_soup()); assert(test_triangulate_faces()); assert(test_triangulate_faces_with_named_parameters()); @@ -256,6 +302,8 @@ int main() assert(test_triangulate_face()); assert(test_triangulate_triangle_face()); assert(test_dual_with_various_faces()); + assert(test_triangulate_soup()); + std::cout << "Done" << std::endl; return EXIT_SUCCESS; }