From 9f955e322fe89e451708dd9d01d12f51503edfea Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 25 Sep 2013 15:24:07 +0200 Subject: [PATCH] Making polygon modification easier A contribution from a user: | Date: Tue, 03 Sep 2013 22:34:20 +0200 | From: ax487 | To: cgal-discuss@inria.fr | Subject: [cgal-discuss] Suggested patch: Making polygon modification | easier. | | Hello all, | | I have been working with polygons now for a while and i noticed that | there are some inconveniences regarding the removal of vertices of a | polygon: If I remove an iterator from a normal C++ container modeling | an ordered sequence, then the method returns an iterator pointing to | the next element. This should (?) also be true for the container used | in the polygon (at least it is in the case of a std::vector or a | std::list). The attached patch turns this iterator into a | Vertex_iterator which can be used in subsequent operations. This change | should be downward compatible, so I hope it is possible to include the | patch in CGAL. --- Polygon/include/CGAL/Polygon_2.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Polygon/include/CGAL/Polygon_2.h b/Polygon/include/CGAL/Polygon_2.h index 014930c07f2..46615498896 100644 --- a/Polygon/include/CGAL/Polygon_2.h +++ b/Polygon/include/CGAL/Polygon_2.h @@ -212,16 +212,21 @@ class Polygon_2 { { d_container.insert(d_container.end(), x); } /// Erases the vertex pointed to by `i`. - void erase(Vertex_iterator i) - { d_container.erase(i); } + Vertex_iterator erase(Vertex_iterator i) + { + return d_container.erase(i); + } - void erase(Vertex_circulator i) - { d_container.erase(i.mod_iterator()); } + Vertex_circulator erase(Vertex_circulator i) + { + return Vertex_circulator(&d_container, + d_container.erase(i.mod_iterator())); + } /// Erases the vertices in the range `[first, last)`. - void erase(Vertex_iterator first, Vertex_iterator last) + Vertex_iterator erase(Vertex_iterator first, Vertex_iterator last) { - d_container.erase(first, last); + return d_container.erase(first, last); } /// Erases the vertices in the range `[first, last)`.