proj home

Files   Classes   Functions   Hierarchy  

delaunaysimpleD2test Class Reference

Test the simples Delaunay triangulation algorithm in 2D implementation. More...

#include <delaunaysimpleD2test.h>

Collaboration diagram for delaunaysimpleD2test:

List of all members.

Public Types

typedef point2< double > pt2

Public Member Functions

void test01 (int argc, char **argv)
 Display a 2D DT.
void test02 (int argc, char **argv)
 DT in 2D.

Static Public Member Functions

static void keyboard01 (unsigned char key, int x, int y)
 Keyboard handler for test01.
static void keyboard02 (unsigned char key, int x, int y)
 Keyboard handler for test02.
static void display01 ()
 Displays gobj::global .

Static Public Attributes

static boolhelp = 0
 Toggle the help menu.
static menusystemmessages = 0
 Output window.
static delaunaysimpleD2< pt2,
double, uint > * 
tessptr = 0
 Access the tessellation in static functions.
static tessD2disp02
< delaunaysimpleD2< pt2,
double, uint >, pt2, uint > * 
tessD2disp02ptr = 0
 test02 uses this tessellation class to display properties.
static uint disppoints = 0
 Index to points switch.
static uint dispmesh = 0
 Index to mesh switch.
static uint dispsimplexindex = 0
 Index to displaying the simplexes indexes.
static uint dispmulticolor = 0
 Index to displaying the simplexes in multicolors.
static uint dispcircles = 0
 Index to displaying the simplexes circles through its points.


Detailed Description

Test the simples Delaunay triangulation algorithm in 2D implementation.

Definition at line 14 of file delaunaysimpleD2test.h.


Member Typedef Documentation

Definition at line 20 of file delaunaysimpleD2test.h.


Member Function Documentation

void delaunaysimpleD2test::display01 (  )  [static]

Displays gobj::global .

Definition at line 117 of file delaunaysimpleD2test.cpp.

References gobjContainer::draw(), glerrordisplay(), and gobj::global.

Referenced by test01(), and test02().

00118 { 
00119   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00120 
00121   gobj::global->draw();
00122 
00123 
00124   glerrordisplay();
00125   
00126   glutSwapBuffers();
00127 }

void delaunaysimpleD2test::keyboard01 ( unsigned char  key,
int  x,
int  y 
) [static]

Keyboard handler for test01.

Definition at line 105 of file delaunaysimpleD2test.cpp.

Referenced by test01().

00110 {
00111   switch (key)
00112   {
00113     case 27: exit(0); break;
00114   }
00115 }

void delaunaysimpleD2test::keyboard02 ( unsigned char  key,
int  x,
int  y 
) [static]

Keyboard handler for test02.

Definition at line 133 of file delaunaysimpleD2test.cpp.

References help().

Referenced by test02().

00138 {
00139   assert(messages!=0);
00140   assert(tessD2disp02ptr!=0);
00141   assert(tessptr!=0);
00142 
00143   switch (key)
00144   {
00145     case 27: exit(0); break;
00146 
00147     case 'h': if (help!=0) *help = !*help; break;
00148     case 'u': messages->scrollup(); break;
00149     case ' ': messages->scrolldown(); break;
00150 
00151     case '1': tessD2disp02ptr->gswitches[disppoints]->toggle(); break;
00152     case '2': tessD2disp02ptr->gswitches[dispmesh]->toggle(); break;
00153     case '3': tessD2disp02ptr->gswitches[dispsimplexindex]->toggle(); break;
00154     case '4': tessD2disp02ptr->gswitches[dispmulticolor]->toggle(); break;
00155     case '5': tessD2disp02ptr->gswitches[dispcircles]->toggle(); break;
00156 
00157 
00158     case 's': 
00159     {
00160       stringstream ss;
00161 //      ss << tessptr->vi.size()-1 << endl;
00162 //      ss << print(tessptr->vi.begin()+1,tessptr->vi.end(),"\n") << endl;
00163 
00164       for (uint i=1; i<tessptr->vi.size(); ++i)
00165         ss << i << ":   " << tessptr->vi[i] << endl;
00166 
00167       messages->addfont10blockstart(ss.str(),1); 
00168     }
00169     break;
00170 
00171     case 'p':
00172     {
00173       stringstream ss;
00174 //      ss << tessptr->pts.size()-1 << endl;
00175 //      ss << print(tessptr->pts.begin()+1,tessptr->pts.end(),"\n") << endl;
00176 
00177       for (uint i=1; i<tessptr->pts.size(); ++i)
00178         ss << i << ":   " << tessptr->pts[i] << endl;
00179 
00180       messages->addfont10blockstart(ss.str(),1); 
00181     }
00182     break;
00183 
00184     case 'c':  messages->clear(); break;
00185 
00186   }
00187 
00188   glutPostRedisplay();
00189 }

void delaunaysimpleD2test::test01 ( int  argc,
char **  argv 
)

Display a 2D DT.

Options include <circles=1> <multicolored=0> <n=50>/<file=filename>.

Definition at line 31 of file delaunaysimpleD2test.cpp.

References tessD2disp01< PT >::circles, display01(), tessD2disp01< PT >::eval(), delaunaysimpleD2< PT, PD, INDX >::eval(), gobj::global, keyboard01(), commandline::mapvar(), tessD2disp01< PT >::multicolored, delaunaysimpleD2< PT, PD, INDX >::pts, r, gobjContainer::set(), and delaunaysimpleD2< PT, PD, INDX >::vi.

00032 {
00033   glutInit(&argc,argv);
00034   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00035   glutInitWindowSize(800,600);
00036   glutCreateWindow("");
00037   glutDisplayFunc(display01);
00038   glutKeyboardFunc(keyboard01);
00039 
00040   OpenGLinitialisation();
00041 
00042   glEnable(GL_DEPTH_TEST);
00043   glEnable(GL_CULL_FACE);
00044   glEnable(GL_NORMALIZE);
00045 
00046   xGraphics.set();
00047 
00048   commandline cmd(argc,argv);
00049 
00050   string file;
00051   cmd.mapvar(file,"file");
00052 
00053   delaunaysimpleD2<pt2,double,uint> tess;
00054 
00055   if (file.empty())
00056   {
00057     uint n=5;
00058     cmd.mapvar(n,"n");
00059 
00060     random11<double> r;
00061     for (uint i=0; i<n; ++i)
00062       tess.pts.push_back( pt2(r(),r()) );
00063   }
00064   else
00065   {
00066     ifstream targ(file.c_str());
00067 
00068     pt2 w;
00069 
00070     for ( ; targ.eof()==false; )
00071     {
00072       targ >> w.x;
00073       if (targ.eof()==true)
00074         continue;
00075 
00076       targ >> w.y;
00077       tess.pts.push_back(w);
00078     }
00079   }
00080 
00081   tess.eval();
00082 
00083   tessD2disp01<pt2> tessdisp(&tess.pts[0]);
00084 
00085   cmd.mapvar(tessdisp.circles,"circles");
00086   cmd.mapvar(tessdisp.multicolored,"multicolored");
00087 
00088   tessdisp.eval
00089   (
00090     *gobj::global,
00091     &tess.vi[0],
00092     &tess.vi[tess.vi.size()-1]
00093   );
00094 
00095   glDisable(GL_DEPTH_TEST);
00096   glEnable(GL_BLEND);
00097   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00098 
00099   zpr zz;
00100   glutMainLoop();
00101 }

void delaunaysimpleD2test::test02 ( int  argc,
char **  argv 
)

DT in 2D.

eg ./main prog=2 n=40

Definition at line 193 of file delaunaysimpleD2test.cpp.

References dispcircles, display01(), tessD2disp02< TESS, PT, INDX >::displaycircles(), tessD2disp02< TESS, PT, INDX >::displaymesh(), tessD2disp02< TESS, PT, INDX >::displaymulticolor(), tessD2disp02< TESS, PT, INDX >::displaypoints(), tessD2disp02< TESS, PT, INDX >::displaysimplexindex(), dispmesh, dispmulticolor, disppoints, dispsimplexindex, delaunaysimpleD2< PT, PD, INDX >::eval(), menusystem::fontcolor, gobjpush, help, gobjSwitch< BOOL >::isdrawn, keyboard02(), textoverlay::lightingdisable(), commandline::mapvar(), messages, delaunaysimpleD2< PT, PD, INDX >::pts, gobjContainer::push(), r, gobjContainer::set(), tessD2disp02ptr, tessptr, and graphicsImmediateDeferred::update().

00194 {
00195   glutInit(&argc,argv);
00196   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00197   glutInitWindowSize(800,600);
00198   glutCreateWindow("");
00199   glutDisplayFunc(display01);
00200   glutKeyboardFunc(keyboard02);
00201 
00202   OpenGLinitialisation();
00203 
00204   glEnable(GL_DEPTH_TEST);
00205   glEnable(GL_CULL_FACE);
00206   glEnable(GL_NORMALIZE);
00207 
00208   xGraphics.set();
00209 
00210   commandline cmd(argc,argv);
00211 
00212   string file;
00213   cmd.mapvar(file,"file");
00214 
00215   typedef point2<double> pt2;
00216 
00217   delaunaysimpleD2<pt2,double,uint> tess;
00218   tessptr = & tess;
00219 
00220   if (file.empty())
00221   {
00222     uint n=5;
00223     cmd.mapvar(n,"n");
00224 
00225     random11<double> r;
00226     for (uint i=0; i<n; ++i)
00227       tess.pts.push_back( pt2(r(),r()) );
00228   }
00229   else
00230   {
00231     ifstream targ(file.c_str());
00232 
00233     pt2 w;
00234 
00235     for ( ; targ.eof()==false; )
00236     {
00237       targ >> w.x;
00238       if (targ.eof()==true)
00239         continue;
00240 
00241       targ >> w.y;
00242       tess.pts.push_back(w);
00243     }
00244   }
00245 
00246   tess.eval();
00247 
00248   tessD2misc
00249   <
00250     delaunaysimpleD2<pt2,double,uint>,
00251     pt2,
00252     uint
00253   > tm(tess);
00254   tm.windinganticlockwise();
00255 
00256 
00257   tessD2disp02<delaunaysimpleD2<pt2,double,uint>,pt2,uint> 
00258     tessdisp(tess);
00259 
00260   tessD2disp02ptr = & tessdisp;
00261 
00262   tessdisp.displaypoints(disppoints);
00263   tessdisp.displaymesh(dispmesh);
00264   tessdisp.displaysimplexindex(dispsimplexindex);
00265   tessdisp.displaymulticolor(dispmulticolor);
00266   tessdisp.displaycircles(dispcircles);
00267   
00268 
00269   tessdisp.update();
00270 
00271   xGraphics.push(&tessdisp);
00272 
00273   gobjpush(new gobjglDisable(GL_LIGHTING));
00274   menusystem * menu = 
00275     new menusystem(0,0,true,point2<GLint>(60,30),10);
00276   menu->fontcolor = point4<float>(218.0/255.0,165.0/255.0,32.0/255.0,0.75);
00277 
00278   gobjSwitch<> * menuswitch = new gobjSwitch<>(menu,true);
00279   help = & menuswitch->isdrawn;
00280   gobjpush(menuswitch);
00281 
00282   menu->addfont12("Delaunay Triangulation Demo",2);
00283 
00284   menu->addfont10("1        Toggle the points",1);
00285   menu->addfont10("2        Toggle the mesh",1);
00286   menu->addfont10("3        Toggle the simplexes indexes",1);
00287   menu->addfont10("4        Toggle multicolored simplexes",1);
00288   menu->addfont10("5        Toggle simplexes circles",2);
00289 
00290   menu->addfont10("s        Print simplexes",1);
00291   menu->addfont10("p        Print points",1);
00292   menu->addfont10("space Scroll down",1);
00293   menu->addfont10("u        Scroll up",1); 
00294   menu->addfont10("c        Clear the display",2); 
00295 
00296   menu->addfont10("h        Toggle help menu",1);
00297   menu->addfont10("ESC      Quit");
00298 
00299 /*
00300   tessD2disp02<pt2> tessdisp(tess);
00301 
00302   //cmd.mapvar(tessdisp.circles,"circles");
00303   //cmd.mapvar(tessdisp.multicolored,"multicolored");
00304 
00305   tessdisp.meshupdate();
00306 
00307   tessdisp.eval
00308   (
00309     *gobj::global,
00310     &tess.vi[0],
00311     &tess.vi[tess.vi.size()-1]
00312   );
00313 */
00314 
00315   messages = 
00316     new menusystem(0,0,true,point2<GLint>(60,250),10);
00317   gobjpush(messages);
00318   messages->fontcolor = point4<float>(1.0,0.0,0.0,0.8);
00319   messages->lightingdisable();
00320 
00321   glDisable(GL_DEPTH_TEST);
00322   glEnable(GL_BLEND);
00323   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00324 
00325   zpr zz;
00326   glutMainLoop();
00327 }


Member Data Documentation

Index to displaying the simplexes circles through its points.

Definition at line 42 of file delaunaysimpleD2test.h.

Referenced by test02().

Index to mesh switch.

Definition at line 35 of file delaunaysimpleD2test.h.

Referenced by test02().

Index to displaying the simplexes in multicolors.

Definition at line 39 of file delaunaysimpleD2test.h.

Referenced by test02().

Index to points switch.

Definition at line 33 of file delaunaysimpleD2test.h.

Referenced by test02().

Index to displaying the simplexes indexes.

Definition at line 37 of file delaunaysimpleD2test.h.

Referenced by test02().

Toggle the help menu.

Definition at line 23 of file delaunaysimpleD2test.h.

Referenced by test02().

Output window.

Definition at line 25 of file delaunaysimpleD2test.h.

Referenced by test02().

test02 uses this tessellation class to display properties.

Definition at line 30 of file delaunaysimpleD2test.h.

Referenced by test02().

Access the tessellation in static functions.

Definition at line 27 of file delaunaysimpleD2test.h.

Referenced by test02().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:49:55 2011 for Chelton Evans Source by  doxygen 1.5.8