Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Problems drawing Delaunay Triangulation

Subject: CGAL users discussion list

List archive

[cgal-discuss] Problems drawing Delaunay Triangulation


Chronological Thread 
  • From: <>
  • To:
  • Subject: [cgal-discuss] Problems drawing Delaunay Triangulation
  • Date: Sat, 5 Dec 2009 04:07:58 +0100 (CET)

Hello, people.
I have a problem drawing the triangulation with OpenGL. After OpenGL draws the
triangulation I can see many triangles intercepting the others in some weird
ways. The interception is not ocurring in the edges of the polygons what
whould
be happen. I want to know if the method that Im using to draw the
triangulation
is correct or the input data is messing with polygons. The creation of the
triangulation is below.

void Triangulacao3D::inicializar(string caminhoArquivo)
{

FILE *arquivoPontos;
arquivoPontos = fopen(caminhoArquivo.c_str() , "r");

if(arquivoPontos == NULL){
fprintf(stderr, "Arquivo inexistente: %s\n" , caminhoArquivo.c_str());
exit(1);
}

//Vertex_handle vh;

double x , y , z;

std::vector<Point3> P;

while(!feof(arquivoPontos)){
fscanf(arquivoPontos , "%lf" ,&x);
fscanf(arquivoPontos , "%lf" ,&z);
fscanf(arquivoPontos , "%lf" ,&y);

P.push_back(Point3(x,y,z));
}

fclose(arquivoPontos);

T.insert (P.begin(), P.end());

assert( T.is_valid() );

assert( T.dimension() == 3 );
}

The draw of the triangulation:

void Terreno::desenharTerreno(){

Finite_facets_iterator3 facetsIter;
Vertex_handle3 v , vertices[3];
Cell_handle3 cell;
Point3 p;
double x , y , z;
int i , j , k , v1 , v2 , v3;

for(facetsIter = tri->T.finite_facets_begin(); facetsIter !=
tri->T.finite_facets_end(); ++facetsIter){
cell = facetsIter->first;
i = facetsIter->second;
k = 0;
for(j = 0 ; j < 4 ; j++){
if(i != j){
vertices[k++] = cell->vertex(j);
}
}
//Validando faces
if(!tri->T.is_facet(vertices[0] , vertices[1] , vertices[2] , cell ,
v1
, v2 , v3)){
std::cout<<"Face invalida"<<std::endl;
}

glColor3f(1.0 , 1.0 , 1.0);
glPolygonMode(GL_FRONT_AND_BACK , GL_FILL);
glBegin( GL_TRIANGLES );
for(j = 0 ; j < 3 ; j++){
v = vertices[j];
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);
glBegin( GL_TRIANGLES );
for(j = 0 ; j < 3 ; j++){
v = vertices[j];
p = v->point();
x = p.cartesian(0);
y = p.cartesian(1);
z = p.cartesian(2);
glVertex3d(x , y , z);
}
glEnd();

}
}

Thanks.
Vinícius da Silva.


Archive powered by MHonArc 2.6.16.

Top of Page