Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Efficient way to iterate through edges

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Efficient way to iterate through edges


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Efficient way to iterate through edges
  • Date: Fri, 30 Jul 2010 08:19:17 +0200

The edge type is documented here:

http://www.cgal.org/Manual/latest/doc_html/cgal_manual/TriangulationDS_3_ref/Concept_TriangulationDataStructure_3.html#Cross_link_anchor_1333

typedef Triple<Cell_handle, int, int> Edge;

This is a triple that contains a pointer to a cell and the two indices
of the vertices corresponding to the edge.

S.


urhere wrote:
I have just started using CGAL for a project that works with tessellations
from NURBS surfaces (using OpenGL). I have been able to write out the
vertices from a tessellation, triangulate them with
Delaunay_triangulation_2, compute and store normals for the faces, and do
some basic face and vertex iteration. All has gone well and I'm pretty
thrilled with the results so far. Right now I need to:

--look at all edges in the triangulation and
--compare the visibility of the adjacent faces (determined by the
orientation of the normals relative to a viewpoint).
Although the method in the code below does what I need, it's probably
visiting edges more than once. It seems like I ought to be able to do this
pretty simply with an Edge_iterator but I have been baffled by the indexing
needed to look up the faces bordering an edge (I can find the endpoints ok).
I would greatly appreciate any snippets of code or pointers to appropriate
places in the manuals for information on navigating with Edge_iterators.

Here's the code (everything is written out explicitly so I could figure out
the indexing):


for (Delaunay::Vertex_iterator vit=dt.finite_vertices_begin(); vit != dt.finite_vertices_end(); ++vit) {
// Get the face associated with the current vertex
Face_handle currentFh = vit->face();
// Get the counter clockwise neighbor of this face
Face_handle ccwFh = vit->face()->neighbor(currentFh->ccw(currentFh->index ( vit) ));
// Get the clockwise neighbor of this face
Face_handle cwFh = vit->face()->neighbor(currentFh->cw(currentFh->index ( vit) ));
// Get the normals for both faces (previously stored)
Vector_3 faceNormalNormalizedCurrent = currentFh->info();
Vector_3 faceNormalNormalizedCCW = ccwFh->info(); Vector_3 faceNormalNormalizedCW = cwFh->info(); // Get the vertex indices and handles
int currentVertexIndex = currentFh->index ( vit);
int ccwVertexIndex = currentFh->ccw(currentFh->index ( vit)); int cwVertexIndex = currentFh->cw(currentFh->index ( vit)); Vertex_handle ccwVh = currentFh->vertex(ccwVertexIndex);
Vertex_handle cwVh = currentFh->vertex(cwVertexIndex);
// Get the coordinates
Point_3 currentPoint = vit->point();
Point_3 ccwPoint = ccwVh->point();
Point_3 cwPoint = cwVh->point();
// The rest of the code is irrelevant but I use
currentPoint, ccwPoint, and
// cwPoint to draw edges, if necessary
}
Thanks for any insights.
Jim




Archive powered by MHonArc 2.6.16.

Top of Page