From eefe2012c01a5d1c364b20ce5746f7e9285a37b8 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 2 Oct 2014 16:59:19 +0200 Subject: [PATCH 1/3] Bug-fix in Mesh_3 with time stamps The implementation of the class template Protect_edges_sizing_field was not correct when time stamps are used for Vertex_handle. The issue is that the time stamp of a vertex change when one do: tr.remove(v); v = tr.insert(point); The vertex pointed by 'v' is re-used by the TDS, but the time stamp of the vertex does change. --- .../CGAL/Mesh_3/Protect_edges_sizing_field.h | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index f133491b31a..b3837a48c07 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -1194,6 +1194,7 @@ change_ball_size(const Vertex_handle& v, const FT size, const bool special_ball) c3t3_.remove_from_complex(v); } + unchecked_vertices_.erase(v); // Change v size c3t3_.triangulation().remove(v); @@ -1235,11 +1236,25 @@ change_ball_size(const Vertex_handle& v, const FT size, const bool special_ball) } // Update unchecked vertices - unchecked_vertices_.erase(v); unchecked_vertices_.insert(new_v); return new_v; } +namespace details { + // Functor used by Protect_edges_sizing_field::check_and_repopulate_edges, below + template + class Erase_element_from_set { + Set& set; + public: + Erase_element_from_set(Set& set) : set(set) {} + + void operator()(const typename Set::key_type& x) + { + set.erase(x); + } + }; // end class Erase_element_from_set + +} // end namespace details template void @@ -1249,7 +1264,8 @@ check_and_repopulate_edges() #ifdef CGAL_MESH_3_PROTECTION_DEBUG std::cerr << "check_and_repopulate_edges()\n"; #endif - std::set vertices; + typedef std::set Vertices; + Vertices vertices; std::copy( unchecked_vertices_.begin(), unchecked_vertices_.end(), std::inserter(vertices,vertices.begin()) ); @@ -1260,15 +1276,11 @@ check_and_repopulate_edges() { Vertex_handle v = *vertices.begin(); vertices.erase(vertices.begin()); - - Vertex_vector erased_vertices; - check_and_fix_vertex_along_edge(v, std::back_inserter(erased_vertices)); - - for ( typename Vertex_vector::iterator vit = erased_vertices.begin(), - vend = erased_vertices.end() ; vit != vend ; ++vit ) - { - vertices.erase(*vit); - } + + details::Erase_element_from_set erase_from_vertices(vertices); + + check_and_fix_vertex_along_edge(v, + boost::make_function_output_iterator(erase_from_vertices)); } } From 99462e7faaf41d58300844766ae1faa5a3f0e789 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 3 Oct 2014 16:26:33 +0200 Subject: [PATCH 2/3] Fix missing header --- Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index b3837a48c07..215eea3fb26 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -33,6 +33,7 @@ #ifndef CGAL_NO_ASSERTIONS # include // for float_prior #endif +#include namespace CGAL { namespace Mesh_3 { From 798db08a113763a98fc67519b9ad2c5f1d81d803 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 3 Oct 2014 16:26:43 +0200 Subject: [PATCH 3/3] Make sure the functor is Assignable A boost::function_output_iterator requires that its template argument is Assignable. See: http://www.boost.org/doc/libs/1_56_0/libs/iterator/doc/function_output_iterator.html#function-output-iterator-requirements If one stores a non-const reference, then the class is not Assignable. Store a pointer instead. --- Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index 215eea3fb26..fac4a50bdaf 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -1245,13 +1245,13 @@ namespace details { // Functor used by Protect_edges_sizing_field::check_and_repopulate_edges, below template class Erase_element_from_set { - Set& set; + Set* set_ptr; public: - Erase_element_from_set(Set& set) : set(set) {} + Erase_element_from_set(Set& set) : set_ptr(&set) {} void operator()(const typename Set::key_type& x) { - set.erase(x); + set_ptr->erase(x); } }; // end class Erase_element_from_set