Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

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


Chronological Thread 
  • From: <>
  • To:
  • Subject: Re: Re: Re: [cgal-discuss] Problems drawing Delaunay Triangulation
  • Date: Tue, 8 Dec 2009 12:08:14 +0100 (CET)

Hello everybody.
I find a aswer to my problem in terrain draw. Posting the solution for others
use.

My error was to use the triangulation 3D to model the terrain. After some time
flaming my head I saw that triangulation 3D (CGAL::Delaunay_triangulation_3)
is
more applicable for modeling solids and this not the case of my application.
The solution used is the triangulation 2D but the vertex base used is with
info
(CGAL::Triangulation_vertex_base_with_info_2). This aproach gives the chance
to
include a new dimension for the height and to develop a function for query the
height using the (x , z) coordinates as parameters. The result is a cheaper
way
to draw the terrain. This is the code to draw the terrain:

void Terreno::desenharTerreno(){

Finite_faces_iterator facesIter;
Vertex_handle v1 , v2 , v3;

for(facesIter = tri->T.finite_faces_begin(); facesIter !=
tri->T.finite_faces_end(); ++facesIter){
v1 = facesIter->vertex(0);
v2 = facesIter->vertex(1);
v3 = facesIter->vertex(2);

if(!this->tri->T.is_face(v1 , v2 , v3)){
std::cout<<"Face invalida"<<std::endl;
}

glColor3f(1.0 , 1.0 , 1.0);
glPolygonMode(GL_FRONT_AND_BACK , GL_FILL);
desenharTriangulo(v1 , v2 , v3);

glColor3f(0.0 , 0.0 , 0.0);
glPolygonMode(GL_FRONT_AND_BACK , GL_LINE);
desenharTriangulo(v1 , v2 , v3);
}
}

inline
void Terreno::desenharTriangulo(Vertex_handle v1 , Vertex_handle v2 ,
Vertex_handle v3){

Point p;
double x , y , z;

glBegin( GL_TRIANGLES );
p = v1->point();
x = p.cartesian(0); z = p.cartesian(1); y = v1->info();
glVertex3d(x , y , z);

p = v2->point();
x = p.cartesian(0); z = p.cartesian(1); y = v2->info();
glVertex3d(x , y , z);

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



Archive powered by MHonArc 2.6.16.

Top of Page