From 266fee1c4c4292638ac49c2600477b2fdf90cac4 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 12 Dec 2018 11:54:18 +0100 Subject: [PATCH 1/4] Check for uniqueness of the vertices in add_face --- BGL/include/CGAL/boost/graph/Euler_operations.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BGL/include/CGAL/boost/graph/Euler_operations.h b/BGL/include/CGAL/boost/graph/Euler_operations.h index 56d92e979ee..f7d8e2f9dcb 100644 --- a/BGL/include/CGAL/boost/graph/Euler_operations.h +++ b/BGL/include/CGAL/boost/graph/Euler_operations.h @@ -585,6 +585,12 @@ add_face(const VertexRange& vr, Graph& g) std::vector vertices(vr.begin(), vr.end()); // quick and dirty copy unsigned int n = (unsigned int)vertices.size(); + //check that every vertex is unique + std::sort(vertices.begin(), vertices.end()); + if(std::unique(vertices.begin(), vertices.end()) != vertices.end()) + return boost::graph_traits::null_face(); + vertices.clear(); + vertices=std::vector(vr.begin(), vr.end()); // don't allow degenerated faces CGAL_assertion(n > 2); From 31b68de8b2290d19facec25fb84a4ad7b8506638 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 12 Dec 2018 14:53:01 +0100 Subject: [PATCH 2/4] use std::copy and adjacent_find --- BGL/include/CGAL/boost/graph/Euler_operations.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/Euler_operations.h b/BGL/include/CGAL/boost/graph/Euler_operations.h index f7d8e2f9dcb..1375e41c68a 100644 --- a/BGL/include/CGAL/boost/graph/Euler_operations.h +++ b/BGL/include/CGAL/boost/graph/Euler_operations.h @@ -587,10 +587,9 @@ add_face(const VertexRange& vr, Graph& g) unsigned int n = (unsigned int)vertices.size(); //check that every vertex is unique std::sort(vertices.begin(), vertices.end()); - if(std::unique(vertices.begin(), vertices.end()) != vertices.end()) + if(std::adjacent_find(vertices.begin(), vertices.end()) != vertices.end()) return boost::graph_traits::null_face(); - vertices.clear(); - vertices=std::vector(vr.begin(), vr.end()); + std::copy(vr.begin(), vr.end(), vertices.begin()); // don't allow degenerated faces CGAL_assertion(n > 2); From 51f8877e60f5f37bd1c70bd4ce6b851f8ecf1c1a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 13 Dec 2018 09:17:46 +0100 Subject: [PATCH 3/4] Replace the assertion about n>2 by a if --- BGL/include/CGAL/boost/graph/Euler_operations.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/Euler_operations.h b/BGL/include/CGAL/boost/graph/Euler_operations.h index 1375e41c68a..04b415b207c 100644 --- a/BGL/include/CGAL/boost/graph/Euler_operations.h +++ b/BGL/include/CGAL/boost/graph/Euler_operations.h @@ -587,11 +587,14 @@ add_face(const VertexRange& vr, Graph& g) unsigned int n = (unsigned int)vertices.size(); //check that every vertex is unique std::sort(vertices.begin(), vertices.end()); - if(std::adjacent_find(vertices.begin(), vertices.end()) != vertices.end()) + if(std::adjacent_find(vertices.begin(), vertices.end()) != vertices.end()){ return boost::graph_traits::null_face(); + } std::copy(vr.begin(), vr.end(), vertices.begin()); // don't allow degenerated faces - CGAL_assertion(n > 2); + if(n <= 2){ + return boost::graph_traits::null_face(); + } std::vector halfedges(n); std::vector is_new(n); From c51852f8a1dfcba2a9ef06f7f54bd4bac88cb69f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 13 Dec 2018 09:34:05 +0100 Subject: [PATCH 4/4] Add check in collect_garbage() --- Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index ce5490de872..004831a2ac0 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -2482,6 +2482,11 @@ void Surface_mesh

:: collect_garbage() { + if (!has_garbage()) + { + return; + } + int i, i0, i1, nV(num_vertices()), nE(num_edges()),