Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Efficient way to iterate through edges
- Date: Fri, 30 Jul 2010 11:56:47 +0200
Monique makes me notice that you may be talking about
Delaunay_2 (in that case why do you have _3 in code?)
If this is the case, the doc is here:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/TDS_2_ref/Concept_TriangulationDataStructure_2.html#Cross_link_anchor_1302
typedef std::pair<Face_handle,int> Edge; The edge type. The Edge(f,i) is edge common to faces f and f.neighbor(i). It is also the edge joining the vertices vertex(cw(i)) and vertex(ccw(i)) of f.
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
- [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.