From 74b5d0569860b2d4ee361a2a7cb75b0e317dbd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 13 Feb 2023 19:27:59 +0100 Subject: [PATCH] fix test --- .../remesh_planar_patches.h | 25 +++--- .../test_decimation_of_planar_patches.cpp | 76 ++++++++----------- 2 files changed, 48 insertions(+), 53 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h index 247762f083e..1fb7407b8b0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h @@ -1100,15 +1100,19 @@ bool decimate_meshes_with_common_interfaces_impl(TriangleMeshRange& meshes, } std::size_t ncid=corners.size(); + typedef internal_np::Param_not_found PNF; + PNF pnf; + Triangle_index_tracker tracker(pnf, pnf); bool all_patches_successfully_remeshed = - decimate_impl(tm, - nb_corners_and_nb_cc_all[mesh_id], - vertex_corner_id_maps[mesh_id], - edge_is_constrained_maps[mesh_id], - face_cc_ids_maps[mesh_id], - vpms[mesh_id], - corners, - all_triangles[mesh_id]) && + decimate_impl(tm, + nb_corners_and_nb_cc_all[mesh_id], + vertex_corner_id_maps[mesh_id], + edge_is_constrained_maps[mesh_id], + face_cc_ids_maps[mesh_id], + vpms[mesh_id], + corners, + all_triangles[mesh_id], + tracker) && is_polygon_soup_a_polygon_mesh(all_triangles[mesh_id]); #ifdef CGAL_DEBUG_DECIMATION std::cout << "all_patches_successfully_remeshed? " << all_patches_successfully_remeshed << "\n"; @@ -1466,6 +1470,9 @@ bool decimate_meshes_with_common_interfaces(TriangleMeshRange& meshes, double co CGAL_assertion(coplanar_cos_threshold<0); typedef typename boost::property_traits::value_type Triangle_mesh; typedef typename std::iterator_traits::value_type Mesh_descriptor; + typedef typename boost::property_map::type VPM; + typedef typename boost::property_traits::value_type Point_3; + typedef typename Kernel_traits::type Kernel; /// @TODO turn into a range of named parameter std::vector::type > vpms; @@ -1473,7 +1480,7 @@ bool decimate_meshes_with_common_interfaces(TriangleMeshRange& meshes, double co for(Mesh_descriptor& md : meshes) vpms.push_back( get(boost::vertex_point, mesh_map[md]) ); - return Planar_segmentation::decimate_meshes_with_common_interfaces_impl(meshes, mesh_map, coplanar_cos_threshold, vpms); + return Planar_segmentation::decimate_meshes_with_common_interfaces_impl(meshes, mesh_map, coplanar_cos_threshold, vpms); } template diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_decimation_of_planar_patches.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_decimation_of_planar_patches.cpp index 719c3a8811f..ba60e5222c3 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_decimation_of_planar_patches.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_decimation_of_planar_patches.cpp @@ -38,18 +38,14 @@ int main() in >> sm; // call the decimation function - Surface_mesh out; - if (!PMP::remesh_planar_patches(sm, out)) - { - std::cerr << "ERROR: decimate failed to remesh some patches\n"; - OK=false; - } + Surface_mesh sm_out; + PMP::remesh_planar_patches(sm, sm_out); ss=std::stringstream(); ss << "out" << i << ".off"; std::ofstream out(ss.str().c_str()); - out << out; + out << sm_out; std::cout << " output written to out" << i << ".off\n"; - assert(is_valid_polygon_mesh(out)); + assert(CGAL::is_valid_polygon_mesh(sm_out)); } // testing border non-manifold vertex: not working for now, test kept /* @@ -68,7 +64,7 @@ int main() std::cerr << "ERROR: decimate failed to remesh some patches\n"; } std::ofstream("nm_m1.off") << std::setprecision(17) << sm; - assert(is_valid_polygon_mesh(sm)); + assert(CGAL::is_valid_polygon_mesh(sm)); } */ // test duplicated vertex @@ -82,12 +78,11 @@ int main() CGAL::Euler::remove_face(halfedge(f2, sm), sm); PMP::duplicate_non_manifold_vertices(sm); std::size_t nbv_before = vertices(sm).size(); - Surface_mesh out; - if (!PMP::remesh_planar_patches(sm, out)) - std::cerr << "decimate failed to remesh some patches (expected)\n"; - assert(vertices(out).size()> sm; // call the decimation function - Surface_mesh out; - if (!PMP::remesh_planar_patches(sm, out, CGAL::parameters::cosinus_threshold(-0.99))) - { - OK=false; - std::cerr << "ERROR: decimate failed to remesh some patches\n"; - } + Surface_mesh sm_out; + PMP::remesh_planar_patches(sm, sm_out, CGAL::parameters::cosinus_threshold(-0.99)); ss=std::stringstream(); ss << "out_a" << i << ".off"; std::ofstream out(ss.str().c_str()); - out << out; + out << sm_out; std::cout << " output written to out_a" << i << ".off\n"; - assert(is_valid_polygon_mesh(out)); + assert(CGAL::is_valid_polygon_mesh(sm_out)); } //testing decimation of meshes, preserving common interface @@ -162,7 +152,7 @@ int main() } std::cout << "\n"; for (int i=0; i> sm; - Surface_mesh out; - if (!PMP::remesh_planar_patches(sm, out, CGAL::parameters::cosinus_threshold(-0.99))) - std::cerr << "decimate failed to remesh some patches\n"; + Surface_mesh sm_out; + PMP::remesh_planar_patches(sm, sm_out, CGAL::parameters::cosinus_threshold(-0.99)); } { Surface_mesh sm; std::cout << "decimate of data/decimation/sphere_selection.off using approximate predicates\n"; std::ifstream in("data/decimation/sphere_selection.off"); in >> sm; - Surface_mesh out; - if (!PMP::remesh_planar_patches(sm, out, CGAL::parameters::cosinus_threshold(-0.99))) - std::cout << "decimate failed to remesh some patches (this is the expected behavior)\n"; + Surface_mesh sm_out; + PMP::remesh_planar_patches(sm, sm_out, CGAL::parameters::cosinus_threshold(-0.99)); std::ofstream out("sphere_selection_app.off"); - out << out; + out << sm_out; std::cout << "output written to sphere_selection_app.off\n"; - assert(is_valid_polygon_mesh(out)); + assert(CGAL::is_valid_polygon_mesh(sm_out)); } assert(OK);