Subject: CGAL users discussion list
List archive
- From: Jason Park <>
- To:
- Subject: [cgal-discuss] Re: Triangulation of non-convex polygon
- Date: Wed, 1 May 2013 22:22:38 -0700 (PDT)
I really appreciate your help. I just start to use this library so it feels
so strange and confusing.
Thx again.
Best Regards,
Jason Park
Philipp Moeller-2 wrote
> Jason Park <
> kopfor@
> > 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.
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
>
>
>
> 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;
> + }
>
> /// @}
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Triangulation-of-non-convex-polygon-tp4657324p4657329.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [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.