Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] infinite facet in finite_facets_iterator?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] infinite facet in finite_facets_iterator?


Chronological Thread 
  • From: Stephane Tayeb <>
  • To:
  • Subject: Re: [cgal-discuss] infinite facet in finite_facets_iterator?
  • Date: Fri, 04 Dec 2009 17:36:05 +0100

Hi Vinicius,


wrote:
Hello everybody.
I'm Vinícius and this is my first post in this list. I'm using CGAL and OpenGL
to draw terrain as Delaunay Triangulation for my graduation project. Im trying
to draw all the triangles using the finite_facets_iterator but when the OpenGL
renders the terrain there are some facets that are going to a point which is
not in the data input and this point is very far away from the others. This
event is ocurring independent of the data input because I tested it with some
different cases. I think that point is the infinite vertex but this is not
possyble. Can someone give me a hand in this situation? The code is below.

void Terreno::desenharTerreno(){

Finite_facets_iterator3 facetsIter;
Vertex_handle3 v;
Cell_handle3 cell;
Point3 p;
double x , y , z;
int i;

glColor3f(1.0 , 1.0 , 1.0);
glPolygonMode(GL_FRONT_AND_BACK , GL_FILL);

for(facetsIter = tri->T.finite_facets_begin(); facetsIter !=
tri->T.finite_facets_end(); ++facetsIter){
cell = facetsIter->first;
i = facetsIter->second;

glBegin( GL_TRIANGLES );
for(int j = i + 1 ; j <= i + 3 ; j++){
v = cell->vertex(j % 3);

I suppose you want to get vertices of the facet. Then

v = cell->vertex(j&3); // or v= cell->vertex(j%4);
(x&3 keeps the two last bits of integer x, if you are not familiar with this operator)

would probably be better. Actually there are 4 vertices in a cell, so you should take the index modulo 4 and not 3.

p = v->point();
x = p.cartesian(0); y = p.cartesian(1); z = p.cartesian(2);
glVertex3d(x , y , z);
}
glEnd();
}

glColor3f(0.0 , 0.0 , 0.0);
glPolygonMode(GL_FRONT_AND_BACK , GL_LINE);

for(facetsIter = tri->T.finite_facets_begin(); facetsIter !=
tri->T.finite_facets_end(); ++facetsIter){
cell = facetsIter->first;
i = facetsIter->second;

glBegin( GL_TRIANGLES );
for(int j = i + 1 ; j <= i + 3 ; j++){
v = cell->vertex(j % 3);
p = v->point();
x = p.cartesian(0); y = p.cartesian(1); z = p.cartesian(2);
glVertex3d(x , y , z);
}
glEnd();
}
}


Best regards,
Vinícius da Silva.

Best,

--
Stephane Tayeb
Software engineer - INRIA Sophia Antipolis
Geometrica Project-Team



Archive powered by MHonArc 2.6.16.

Top of Page