mirror of https://github.com/CGAL/cgal
Merge pull request #7230 from afabri/Polygon_2-erase_circulator-GF
Polygon: Fix erase(Vertex_circulator)
This commit is contained in:
commit
94080248e7
|
|
@ -242,8 +242,11 @@ class Polygon_2 {
|
||||||
/// Erases the vertex pointed to by `i`.
|
/// Erases the vertex pointed to by `i`.
|
||||||
Vertex_circulator erase(Vertex_circulator i)
|
Vertex_circulator erase(Vertex_circulator i)
|
||||||
{
|
{
|
||||||
return Vertex_circulator(&d_container,
|
auto it = d_container.erase(i.mod_iterator());
|
||||||
d_container.erase(i.mod_iterator()));
|
if(it == d_container.end()){
|
||||||
|
it = d_container.begin();
|
||||||
|
}
|
||||||
|
return Vertex_circulator(&d_container, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Erases the vertices in the range `[first, last)`.
|
/// Erases the vertices in the range `[first, last)`.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include <CGAL/Simple_cartesian.h>
|
||||||
|
#include <CGAL/Polygon_2.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <array>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
typedef CGAL::Simple_cartesian<double> K;
|
||||||
|
typedef K::Point_2 Point;
|
||||||
|
typedef CGAL::Polygon_2<K> Polygon_2;
|
||||||
|
typedef Polygon_2::Vertex_circulator Vertex_circulator;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::array<Point,4> points = { Point(0,0), Point(1,0), Point(1,1), Point(0,1) };
|
||||||
|
Polygon_2 poly(points.begin(), points.end());
|
||||||
|
|
||||||
|
Vertex_circulator vc = poly.vertices_circulator();
|
||||||
|
|
||||||
|
++vc;
|
||||||
|
++vc;
|
||||||
|
++vc;
|
||||||
|
|
||||||
|
vc = poly.erase(vc);
|
||||||
|
|
||||||
|
assert(*vc == Point(0,0));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue