diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/acvd_remeshing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/acvd_remeshing_example.cpp index 393c1d88fe5..d6e7122e99e 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/acvd_remeshing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/acvd_remeshing_example.cpp @@ -2,9 +2,6 @@ #include #include #include -#include - -#include #include #include @@ -13,7 +10,6 @@ namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; namespace params = CGAL::parameters; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 1e442ae768f..9bda6b6c600 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -90,6 +90,9 @@ if(TARGET CGAL::Eigen3_support) target_link_libraries(test_decimation_of_planar_patches PRIVATE CGAL::Eigen3_support) create_single_source_cgal_program("remeshing_quality_test.cpp" ) target_link_libraries(remeshing_quality_test PRIVATE CGAL::Eigen3_support) + create_single_source_cgal_program("test_acvd.cpp" ) + target_link_libraries(test_acvd PRIVATE CGAL::Eigen3_support) + else() message(STATUS "NOTICE: Tests that use the Eigen library will not be compiled.") endif() diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_acvd.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_acvd.cpp new file mode 100644 index 00000000000..8ca1e8f6b67 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_acvd.cpp @@ -0,0 +1,63 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +namespace PMP = CGAL::Polygon_mesh_processing; + +using K = CGAL::Exact_predicates_inexact_constructions_kernel; +using Mesh = CGAL::Surface_mesh; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + +namespace params = CGAL::parameters; + +void run_test(std::string fname, std::size_t genus) +{ + Mesh mesh; + CGAL::IO::read_polygon_mesh(fname, mesh); + + PMP::triangulate_faces(mesh); + CGAL::Subdivision_method_3::Loop_subdivision(mesh, params::number_of_iterations(5)); + + Mesh ref=mesh; + CGAL::Bbox_3 bb_ref = PMP::bbox(ref); + + PMP::approximated_centroidal_Voronoi_diagram_remeshing(mesh, 1000); + + CGAL::Bbox_3 bb = PMP::bbox(ref); + + assert(-(vertices(mesh).size()-edges(mesh).size()+faces(mesh).size()-2)/2==genus); + assert(vertices(mesh).size()==1000); + + double dx = bb.xmax()-bb.xmin(), + dy = bb.ymax()-bb.ymin(), + dz = bb.zmax()-bb.zmin(); + + assert(std::abs(bb.xmax()-bb_ref.xmax()) < 0.01 * dx); + assert(std::abs(bb.ymax()-bb_ref.ymax()) < 0.01 * dy); + assert(std::abs(bb.zmax()-bb_ref.zmax()) < 0.01 * dz); + +std::ofstream("/tmp/out_"+std::to_string(genus)+".off") << mesh; + + PMP::approximated_centroidal_Voronoi_diagram_remeshing(mesh, 4); + assert(-(vertices(mesh).size()-edges(mesh).size()+faces(mesh).size()-2)/2==genus); + +std::ofstream("/tmp/min_out_"+std::to_string(genus)+".off") << mesh; +} + +int main() +{ + run_test(CGAL::data_file_path("meshes/tetrahedron.off"), 0); + run_test(CGAL::data_file_path("meshes/torus_quad.off"), 1); + run_test(CGAL::data_file_path("meshes/double-torus-example.off"), 2); + + return 0; +} +