Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Triangulation_2 face circulator stange behavior

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Triangulation_2 face circulator stange behavior


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Triangulation_2 face circulator stange behavior
  • Date: Fri, 29 Oct 2010 09:17:01 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=ch3eqRkZreHrF2Abe+1qaIi1+yYFaOX467QA+RkXDYpPBTeV6dt/Shwzod32BTRgrw HZFvcfxNuzcaalbtTGhLzNKMluSrXQ0SQoElOpTx2MBcqkyYeoUUtShqUvauJnJ/l+tB 7Pz7NQNUmc6YKQ7IuZ1G4CjnVZjnujnHs0tiI=

Michele wrote:
Dear all, I have implemented a code that prints the points and the vertices of the
faces of a triangulation, the code is attacted, with using three different
methods: vertex circulator, face circulator and face iterator. Both vertex circulator and face iterator show the good result, but it is not
true for the face circulator, why? Could someone explain me the reasons? Thank you.
I am not sure to understand what you want to do with your code.
A FOO_circulator does not print all FOO of the triangulation but
only incident FOO to a vertex.

In your case
Face_circulator fc = t.incident_faces(t.infinite_vertex())
takes all faces incident to the infinite_vertex and consider
all facets incident to the infinite_vertex. Thus, one of the
vertex of each such faces is the infinite vertex
(the one with strange coordinates). Adding a
if (!t.is_infinite(fc)) before printing would avoid this illegal use of
point() of the infinite_vertex.

If you want to iterate over all the finite faces of the triangulation
use Finite_faces_iterator and finite_faces_begin/finite_faces_end
(same for vertices and edges)
as documented here:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Triangulation_2_ref/Class_Triangulation_2.html#Cross_link_anchor_1296

Also remember that an edge is a std::pair<Face_handle,int> (the edge of a face f which is opposed to the vertex indexed i) as documented here:

http://www.cgal.org/Manual/latest/doc_html/cgal_manual/TDS_2_ref/Concept_TriangulationDataStructure_2.html#Cross_link_anchor_1307

S.


Michele Quinto
This is the output of my code.
print the points belong to triangulation 2 2 2 1 2 0 1 0 0 0 0 1 0 2 1 2 print the faces belong to triangulation (face circulator) triangle: 6.93721e-310 3.45846e-323 2 2 2 1 triangle: 6.93721e-310 3.45846e-323 2 1 2 0 triangle: 6.93721e-310 3.45846e-323 2 0 1 0 triangle: 0 0 6.93721e-310 3.45846e-323 1 0 triangle: 0 0 0 1 6.93721e-310 3.45846e-323 triangle: 0 1 0 2 6.93721e-310 3.45846e-323 triangle: 6.93721e-310 3.45846e-323 0 2 1 2 triangle: 6.93721e-310 3.45846e-323 1 2 2 2 print the faces belong to triangulation (faces iterator) triangle: 0 2 0 1 1 0 triangle: 0 1 0 0 1 0 triangle: 1 1 0 2 1 0 triangle: 1 2 0 2 1 1 triangle: 2 0 1 2 1 1 triangle: 1 0 2 0 1 1 triangle: 2 1 1 2 2 0 triangle: 2 2 1 2 2 1


#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Triangulation_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_2<K> Triangulation; typedef Triangulation::Vertex_circulator Vertex_circulator; typedef Triangulation::Face_circulator Face_circulator; typedef Triangulation::Vertex_iterator Vertex_iterator; typedef Triangulation::Face_iterator Face_iterator; typedef Triangulation::Point Point;
int main(int argc, char *argv[]) { int i, j; Triangulation t; for(i=0; i<3; i++) for(j=0;j<3;j++) t.insert(Point((double)i,(double)j)); std::cout<<"print the points belong to triangulation"<<std::endl; Vertex_circulator vc = t.incident_vertices(t.infinite_vertex()),
done(vc); if(vc!=0) { do{ std::cout<< vc->point() <<std::endl; }while(++vc!=done); } std::cout<<"print the faces belong to triangulation (face
circulator)"<<std::endl; Face_circulator fc = t.incident_faces(t.infinite_vertex()),
done2(fc); if(fc!=0) { do{ std::cout<<"triangle: " <<fc->vertex(0)->point()<<"\t"
<<fc->vertex(1)->point()<<"\t"<<fc->vertex(2)->point()<<std::endl; }while(++fc!=done2); } std::cout<<"print the faces belong to triangulation (faces
iterator)"<<std::endl; Face_iterator fi=t.finite_faces_begin(); for(;fi!=t.finite_faces_end();fi++) { std::cout<<"triangle: " <<fi->vertex(0)->point()<<"\t"
<<fi->vertex(1)->point()<<"\t"<<fi->vertex(2)->point()<<std::endl; } return 0; }




Archive powered by MHonArc 2.6.16.

Top of Page