Subject: CGAL users discussion list
List archive
- From: urhere <>
- To:
- Subject: [cgal-discuss] Efficient way to iterate through edges
- Date: Thu, 29 Jul 2010 11:54:29 -0700 (PDT)
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
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Efficient-way-to-iterate-through-edges-tp2306941p2306941.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Efficient way to iterate through edges, urhere, 07/29/2010
- Re: [cgal-discuss] Efficient way to iterate through edges, Sebastien Loriot (GeometryFactory), 07/30/2010
- Re: [cgal-discuss] Efficient way to iterate through edges, Sebastien Loriot (GeometryFactory), 07/30/2010
- [cgal-discuss] Re: Efficient way to iterate through edges, urhere, 07/30/2010
Archive powered by MHonArc 2.6.16.