Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] access point by id

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] access point by id


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] access point by id
  • Date: Tue, 30 Aug 2011 08:02:31 +0200

There is nothing specifically done for this.
By default, the vertices of a polyhedron are stored in a list so
direct access is not possible (except if the id is the iterator).

You can change the storage to use a vector instead of a list
(see
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/HalfedgeDS/Chapter_main.html#Subsection_26.3.3
for how to do it on the underlying HDS).
The drawback is that before inserting vertices in your polyhedron, you need to know an upper bound on the number of vertices (to avoid resizing
the vector). Once done, if your id is the order of insertion, you can
then use boost::next(P.vertices_begin(),id) to get direct access to the
vertex.

Sebastien.

On 08/29/2011 08:09 PM, Yifei Li wrote:
Hi all,

Given a polyhedron, how do you access a point by its id? I did not find
any API in the documentation.

My polyhedron is declared as follows:

template <class Refs, class P>
struct MyVertex : public CGAL::HalfedgeDS_vertex_max_base_with_id<Refs,
P, unsigned int> {
...
};

struct MyItems : public CGAL::Polyhedron_items_with_id_3 {
...
};

typedef CGAL::Polyhedron_3<Kernel, MyItems> Polyhedron

Thanks

Yifei




Archive powered by MHonArc 2.6.16.

Top of Page