diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index ce6d22ab46a..705ba2adc58 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -303,6 +304,8 @@ namespace internal { { tag_halfedges_status(face_range); //called first + constrain_patch_corners(face_range); + BOOST_FOREACH(face_descriptor f, face_range) { input_triangles_.push_back(triangle(f)); @@ -1372,6 +1375,43 @@ private: return PMP::compute_face_normal(f, mesh_); } + template + void constrain_patch_corners(const FaceRange& face_range) + { + boost::container::flat_set visited; + + BOOST_FOREACH(face_descriptor f, face_range) + { + BOOST_FOREACH(halfedge_descriptor h, + halfedges_around_face(halfedge(f, mesh_), mesh_)) + { + vertex_descriptor vt = target(h, mesh_); + //treat target(h, mesh_) + if (visited.find(vt) != visited.end()) + continue;//already treated + + if (status(h) == PATCH)//h not on patch boundary + continue; //so neither is target(h, mesh_) + + //count incident MESH_BORDER edges + unsigned int nb_incident_borders = 0; + BOOST_FOREACH(halfedge_descriptor hv, + halfedges_around_target(h, mesh_)) + { + CGAL_assertion(vt == target(hv, mesh_)); + if ( (status(hv) == PATCH_BORDER && status(opposite(hv, mesh_)) == MESH_BORDER) + || (status(hv) == MESH_BORDER && status(opposite(hv, mesh_)) == PATCH_BORDER)) + nb_incident_borders++; + } + + if (nb_incident_borders == 1) //this is a special corner + set_constrained(vt, true); + + visited.insert(vt); + } + } + } + template void tag_halfedges_status(const FaceRange& face_range) {