proj home

Files   Classes   Functions   Hierarchy  

simplexD2tessapp01 Class Reference

Application to displays a 2D triangle tessellation from indexed triangles. More...

#include <simplexD2tessapp01.h>

Collaboration diagram for simplexD2tessapp01:

List of all members.

Public Types

typedef point2< double > pt2

Public Member Functions

void test02 (int argc, char **argv)
 Tessellation 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 simplexD2tessindexed
< pt2, double, uint > * 
tessptr = 0
 Access the tessellation in static functions.
static tessD2disp02
< simplexD2tessindexed< pt2,
double, uint >, pt2, uint > * 
tessD2disp02ptr = 0
 test02 uses this tessellation class to display properties.
static uint displaypoints = 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

Application to displays a 2D triangle tessellation from indexed triangles.

Definition at line 14 of file simplexD2tessapp01.h.


Member Typedef Documentation

Definition at line 20 of file simplexD2tessapp01.h.


Member Function Documentation

void simplexD2tessapp01::display01 (  )  [static]

Displays gobj::global .

Definition at line 44 of file simplexD2tessapp01.cpp.

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

Referenced by test02().

00045 { 
00046   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00047 
00048   gobj::global->draw();
00049 
00050 
00051   glerrordisplay();
00052   
00053   glutSwapBuffers();
00054 }

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

Keyboard handler for test01.

Definition at line 32 of file simplexD2tessapp01.cpp.

00037 {
00038   switch (key)
00039   {
00040     case 27: exit(0); break;
00041   }
00042 }

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

Keyboard handler for test02.

Definition at line 60 of file simplexD2tessapp01.cpp.

References help().

Referenced by test02().

00065 {
00066   assert(messages!=0);
00067   assert(tessD2disp02ptr!=0);
00068   assert(tessptr!=0);
00069 
00070   switch (key)
00071   {
00072     case 27: exit(0); break;
00073 
00074     case 'h': if (help!=0) *help = !*help; break;
00075     case 'u': messages->scrollup(); break;
00076     case ' ': messages->scrolldown(); break;
00077 
00078     case '1': tessD2disp02ptr->gswitches[displaypoints]->toggle(); break;
00079     case '2': tessD2disp02ptr->gswitches[dispmesh]->toggle(); break;
00080     case '3': tessD2disp02ptr->gswitches[dispsimplexindex]->toggle(); break;
00081     case '4': tessD2disp02ptr->gswitches[dispmulticolor]->toggle(); break;
00082     case '5': tessD2disp02ptr->gswitches[dispcircles]->toggle(); break;
00083 
00084     case 's': 
00085     {
00086       stringstream ss;
00087       for (uint i=1; i<tessptr->vi.size(); ++i)
00088         ss << i << ":   " << tessptr->vi[i] << endl;
00089 
00090       messages->addfont10blockstart(ss.str(),1); 
00091     }
00092     break;
00093 
00094     case 'p':
00095     {
00096       stringstream ss;
00097       for (uint i=1; i<tessptr->pts.size(); ++i)
00098         ss << i << ":   " << tessptr->pts[i] << endl;
00099 
00100       messages->addfont10blockstart(ss.str(),1); 
00101     }
00102     break;
00103 
00104     case 'c':  messages->clear(); break;
00105 
00106   }
00107 
00108   glutPostRedisplay();
00109 }

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

Tessellation in 2D.

Definition at line 113 of file simplexD2tessapp01.cpp.

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

00114 {
00115   glutInit(&argc,argv);
00116   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00117   glutInitWindowSize(800,600);
00118   glutCreateWindow("");
00119   glutDisplayFunc(display01);
00120   glutKeyboardFunc(keyboard02);
00121 
00122   OpenGLinitialisation();
00123 
00124   glEnable(GL_DEPTH_TEST);
00125   glEnable(GL_CULL_FACE);
00126   glEnable(GL_NORMALIZE);
00127 
00128   xGraphics.set();
00129 
00130   commandline cmd(argc,argv);
00131 
00132   string file;
00133   cmd.mapvar(file,"file");
00134 
00135   typedef point2<double> pt2;
00136 
00137   simplexD2tessindexed<point2<double>,double,uint> tess;
00138   tessptr = & tess;
00139 
00140   if (file.empty())
00141   {
00142     cout << "error:  filename of an indexed 2D tessellation expected." << endl;
00143     cout << "  eg ./main prog=4 file=tessD2002.txt" << endl;
00144     return;
00145   }
00146 
00147   string s;
00148   bool res = tokenizermisc::readfile(s,file);
00149   if (res==false)
00150   {
00151     cout << "error:  could not read file " << file << endl;
00152     return;
00153   }
00154   tess.serializeInverse(s);
00155   tess.windinganticlockwise();
00156 
00157 
00158   tessD2disp02<simplexD2tessindexed<pt2,double,uint>,pt2,uint> 
00159     tessdisp(tess);
00160 
00161   tessD2disp02ptr = & tessdisp;
00162 
00163   tessdisp.displaypoints(displaypoints);
00164   tessdisp.displaymesh(dispmesh);
00165   tessdisp.displaysimplexindex(dispsimplexindex);
00166   tessdisp.displaymulticolor(dispmulticolor);
00167   tessdisp.displaycircles(dispcircles);
00168   
00169   tessdisp.update();
00170 
00171   tessdisp.gswitches[dispcircles]->isdrawn=false;
00172 
00173   xGraphics.push(&tessdisp);
00174 
00175   gobjpush(new gobjglDisable(GL_LIGHTING));
00176   menusystem * menu = 
00177     new menusystem(0,0,true,point2<GLint>(60,30),10);
00178   menu->fontcolor = point4<float>(218.0/255.0,165.0/255.0,32.0/255.0,0.75);
00179 
00180   gobjSwitch<> * menuswitch = new gobjSwitch<>(menu,true);
00181   help = & menuswitch->isdrawn;
00182   gobjpush(menuswitch);
00183 
00184   menu->addfont12("Indexed Triangles Tessellation",2);
00185 
00186   menu->addfont10("1        Toggle the points",1);
00187   menu->addfont10("2        Toggle the mesh",1);
00188   menu->addfont10("3        Toggle the simplexes indexes",1);
00189   menu->addfont10("4        Toggle multicolored simplexes",1);
00190   menu->addfont10("5        Toggle simplexes circles",2);
00191 
00192   menu->addfont10("s        Print simplexes",1);
00193   menu->addfont10("p        Print points",1);
00194   menu->addfont10("space Scroll down",1);
00195   menu->addfont10("u        Scroll up",1); 
00196   menu->addfont10("c        Clear the display",2); 
00197 
00198   menu->addfont10("h        Toggle help menu",1);
00199   menu->addfont10("ESC      Quit");
00200 
00201 /*
00202   tessD2disp02<pt2> tessdisp(tess);
00203 
00204   //cmd.mapvar(tessdisp.circles,"circles");
00205   //cmd.mapvar(tessdisp.multicolored,"multicolored");
00206 
00207   tessdisp.meshupdate();
00208 
00209   tessdisp.eval
00210   (
00211     *gobj::global,
00212     &tess.vi[0],
00213     &tess.vi[tess.vi.size()-1]
00214   );
00215 */
00216 
00217   messages = 
00218     new menusystem(0,0,true,point2<GLint>(60,250),10);
00219   gobjpush(messages);
00220   messages->fontcolor = point4<float>(1.0,0.0,0.0,0.8);
00221   messages->lightingdisable();
00222 
00223   glDisable(GL_DEPTH_TEST);
00224   glEnable(GL_BLEND);
00225   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00226 
00227   zpr zz;
00228   glutMainLoop();
00229 }


Member Data Documentation

Index to displaying the simplexes circles through its points.

Definition at line 42 of file simplexD2tessapp01.h.

Referenced by test02().

Index to points switch.

Definition at line 33 of file simplexD2tessapp01.h.

Referenced by test02().

Index to mesh switch.

Definition at line 35 of file simplexD2tessapp01.h.

Referenced by test02().

Index to displaying the simplexes in multicolors.

Definition at line 39 of file simplexD2tessapp01.h.

Referenced by test02().

Index to displaying the simplexes indexes.

Definition at line 37 of file simplexD2tessapp01.h.

Referenced by test02().

Toggle the help menu.

Definition at line 23 of file simplexD2tessapp01.h.

Referenced by test02().

Output window.

Definition at line 25 of file simplexD2tessapp01.h.

Referenced by test02().

test02 uses this tessellation class to display properties.

Definition at line 30 of file simplexD2tessapp01.h.

Referenced by test02().

Access the tessellation in static functions.

Definition at line 27 of file simplexD2tessapp01.h.

Referenced by test02().


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

Generated on Fri Mar 4 00:50:17 2011 for Chelton Evans Source by  doxygen 1.5.8