Subject: CGAL users discussion list
List archive
- From: Philipp Moeller <>
- To: Jason Park <>
- Cc:
- Subject: Re: [cgal-discuss] Re: Triangulation of non-convex polygon
- Date: Wed, 01 May 2013 23:14:39 +0200
- Organization: GeometryFactory
Jason Park
<>
writes:
> It's my mistake when I copy the code from VS. When it builds, it was
> vertex(j+1). I think the problem lies other place.
Yes, I just checked: Polygon_2::vertex is documented as a random access
method. From the error, it looks like you are using a Polygon_2 with a
std::list as the container, so neither vertex(), operator[], or edge are
going to work. You can use the corresponding begin iterators and
std::advance to achieve the same effect.
Technically, the member functions above can be written in a manor to
work without degrading the performance. Attached is a patch to do that,
if you want to patch CGAL.
diff --git a/Polygon/include/CGAL/Polygon_2.h
b/Polygon/include/CGAL/Polygon_2.h
index eaadb4b..fcc85a1 100644
--- a/Polygon/include/CGAL/Polygon_2.h
+++ b/Polygon/include/CGAL/Polygon_2.h
@@ -418,8 +418,11 @@ class Polygon_2 {
/// Returns a (const) reference to the `i`-th vertex.
const Point_2& vertex(std::size_t i) const
- { return *(d_container.begin() + i); }
-
+ {
+ Vertex_const_iterator it = d_container.begin();
+ std::advance(it, i);
+ return *it;
+ }
/// Returns a (const) reference to the `i`-th vertex.
const Point_2& operator[](std::size_t i) const
@@ -427,7 +430,11 @@ class Polygon_2 {
/// Returns the `i`-th edge.
Segment_2 edge(std::size_t i) const
- { return *(edges_begin() + i); }
+ {
+ Edge_const_iterator it = edges_begin();
+ std::advance(it, i);
+ return *it;
+ }
/// @}
- [cgal-discuss] Triangulation of non-convex polygon, Jason Park, 05/01/2013
- Re: [cgal-discuss] Triangulation of non-convex polygon, Philipp Moeller, 05/01/2013
- [cgal-discuss] Re: Triangulation of non-convex polygon, Jason Park, 05/01/2013
- Re: [cgal-discuss] Re: Triangulation of non-convex polygon, Philipp Moeller, 05/01/2013
- [cgal-discuss] Re: Triangulation of non-convex polygon, Jason Park, 05/02/2013
- Re: [cgal-discuss] Re: Triangulation of non-convex polygon, Philipp Moeller, 05/01/2013
- [cgal-discuss] Re: Triangulation of non-convex polygon, Jason Park, 05/01/2013
- Re: [cgal-discuss] Triangulation of non-convex polygon, Philipp Moeller, 05/01/2013
Archive powered by MHonArc 2.6.18.