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 42899124ad4..5cae2289215 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 @@ -443,6 +443,7 @@ bool decimate_impl(const TriangleMesh& tm, do { std::vector< std::vector > face_boundaries(nb_corners_and_nb_cc.second); + std::vector face_boundaries_valid(nb_corners_and_nb_cc.second, true); // collect maximal constrained edges per cc for(halfedge_descriptor h : halfedges(tm)) { @@ -485,6 +486,9 @@ bool decimate_impl(const TriangleMesh& tm, triangles.clear(); const std::vector< Id_pair >& csts = face_boundaries[cc_id]; + + if (!face_boundaries_valid[cc_id]) continue; + if (csts.size()==3) { triangles.push_back( make_array(csts[0].first, @@ -529,7 +533,11 @@ bool decimate_impl(const TriangleMesh& tm, for (halfedge_descriptor h : halfedges_around_target(halfedge(v, tm), tm)) { if (!is_border(h, tm)) - cc_to_handle.set(get(face_cc_ids, face(h, tm)), 1); + { + std::size_t other_cc_id = get(face_cc_ids, face(h, tm)); + cc_to_handle.set(other_cc_id, 1); + face_boundaries_valid[ other_cc_id ]=false; + } } } cc_to_handle.set(cc_id, 0); 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 5a38039d389..29d4c6d6ba9 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 @@ -36,10 +36,7 @@ int main() // call the decimation function if (!PMP::remesh_planar_patches(sm)) - { std::cerr << "ERROR: decimate cannot be done correctly\n"; - continue; - } ss=std::stringstream(); ss << "out" << i << ".off"; std::ofstream out(ss.str().c_str()); @@ -59,10 +56,7 @@ int main() // call the decimation function if (!PMP::remesh_planar_patches(sm, CGAL::parameters::cosinus_threshold(-0.99))) - { std::cerr << "ERROR: decimate cannot be done correctly\n"; - continue; - } ss=std::stringstream(); ss << "out_a" << i << ".off"; std::ofstream out(ss.str().c_str()); @@ -140,10 +134,7 @@ int main() // call the decimation function if (!PMP::decimate_with_pca_for_coplanarity(sm, 1e-5, -0.99)) - { std::cerr << "ERROR: decimate cannot be done correctly\n"; - continue; - } ss=std::stringstream(); ss << "out_a_pca" << i << ".off"; std::ofstream out(ss.str().c_str());