Subject: CGAL users discussion list
List archive
- From: Philipp Moeller <(005b7a4cd6%hidden_head%005b7a4cd6)philipp.moeller(005b7a4cd6%hidden_at%005b7a4cd6)geometryfactory.com(005b7a4cd6%hidden_end%005b7a4cd6)>
- To: (005b7a4cd6%hidden_head%005b7a4cd6)cgal-discuss(005b7a4cd6%hidden_at%005b7a4cd6)lists-sop.inria.fr(005b7a4cd6%hidden_end%005b7a4cd6)
- Subject: Re: [cgal-discuss] Vertex Indices
- Date: Mon, 28 May 2012 20:04:39 +0200
- Organization: GeometryFactory
Julian Hodgson
<(005b7a4cd6%hidden_head%005b7a4cd6)julian.of.london(005b7a4cd6%hidden_at%005b7a4cd6)gmail.com(005b7a4cd6%hidden_end%005b7a4cd6)>
writes:
> I'm trying to build up an array of data per vertex on a Polyhedron e.g.
>
> vector<FT> vArray( nVertices, 0.0f);
> Halfedge_handle he_itr = polyhedron.halfedges_begin();
>
> for ( Polyhedron::Facet_iterator fitr = polyhedron.facets_begin(); fitr !=
> polyhedron.facets_end(); fitr++)
> {
> Halfedge_facet_circulator cir = fitr->facet_begin();
>
> do
> {
> // Get vertex index (as per subdivision tutorial)
> int i = (int) std::distance( he_itr, Halfedge_handle( cir.operator->()));
>
> vArray[ i] = // some Data
>
> }
> while ( ++cir != fitr->facet_begin());
> }
>
> Here I'm calculating the vertex index as the distance of the half edge
> iterator from the start half edge.
>
> Is this correct, and why?
>
> Julian
This will be rather inefficient as it requires traversal of the internal
list structure for every index calculation.
You have basically two options to store extra data in a Polyhedron:
- store indices in every vertex and use those for look-up in your
data-structure
- store the data directly in the vertex
I'd prefer the second approach. For this you need to write a new class
that fulfills the PolyhedronItems_3 [1] concept. The example on this
page shows how to do it for a Face. Doing it for a Vertex is analog.
To store indices inside a vertex, do exactly the same.
Footnotes:
[1]
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Polyhedron_ref/Class_Polyhedron_items_3.html#Cross_link_anchor_1116
HTH,
Philipp Moeller
GeometryFactory
- [cgal-discuss] Vertex Indices, Julian Hodgson, 05/28/2012
- Re: [cgal-discuss] Vertex Indices, Philipp Moeller, 05/28/2012
Archive powered by MHonArc 2.6.18.