Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Suggested patch: Making polygon modification easier.

Subject: CGAL users discussion list

List archive

[cgal-discuss] Suggested patch: Making polygon modification easier.


Chronological Thread 
  • From: ax487 <>
  • To:
  • Subject: [cgal-discuss] Suggested patch: Making polygon modification easier.
  • Date: Tue, 03 Sep 2013 22:34:20 +0200

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.

ax487
diff -Naur a/Polygon_2.h b/Polygon_2.h
--- a/Polygon_2.h	2013-09-03 22:18:25.427144687 +0200
+++ b/Polygon_2.h	2013-09-03 22:08:02.605947017 +0200
@@ -212,16 +212,21 @@
       { 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)`.



Archive powered by MHonArc 2.6.18.

Top of Page