proj home

Files   Classes   Functions   Hierarchy  

quickhull3Dtest Class Reference

3D quickhull test and program tools. More...

#include <quickhull3Dtest.h>

Collaboration diagram for quickhull3Dtest:

List of all members.

Public Member Functions

 quickhull3Dtest ()
void test01 (int argc, char **argv)

Static Public Member Functions

static void keyboard01 (unsigned char key, int x, int y)
 Default keyboard handler - ESC to quit.
static void display01 ()
 Displays the gobj::global with double buffering.


Detailed Description

3D quickhull test and program tools.

Definition at line 13 of file quickhull3Dtest.h.


Constructor & Destructor Documentation

quickhull3Dtest::quickhull3Dtest (  ) 

Definition at line 101 of file quickhull3Dtest.cpp.

00102   : xGraphics(true), pointscontainer(true), dynamic(true), 
00103     pointsdisplay(true),
00104     pointsnumber(false), menuhelp(true), menuswitch(0), quickhull(0)
00105 {
00106 }


Member Function Documentation

void quickhull3Dtest::display01 (  )  [static]

Displays the gobj::global with double buffering.

Definition at line 89 of file quickhull3Dtest.cpp.

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

Referenced by test01().

00090 { 
00091   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00092 
00093   gobj::global->draw();
00094 
00095 
00096   glerrordisplay();
00097   
00098   glutSwapBuffers();
00099 }

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

Default keyboard handler - ESC to quit.

Definition at line 24 of file quickhull3Dtest.cpp.

References quickhull3D< PT, D >::reset().

Referenced by test01().

00029 {
00030   assert(member!=0);
00031   assert(member->displayaxes!=0);
00032   assert(member->quickhull!=0);
00033 
00034   switch (key)
00035   {
00036     case 27: exit(0); break;
00037     case 'a': member->displayaxes->toggle(); break;
00038 
00039     case 'p': member->pointsdisplay = ! member->pointsdisplay; break;
00040     case 'P': member->pointsnumber= ! member->pointsnumber;
00041       member->pointscontainer.nuke();
00042       pointsdisplay3D< pt3 >(
00043         member->pointscontainer,
00044         member->pts,
00045         member->pointsdisplay,
00046         member->pointsnumber);
00047       break;
00048 
00049     case 'h': member->menuhelp = ! member->menuhelp; break;
00050 
00051     case 'R':
00052     {
00053       quickhull3D< pt3, double > & qh(*(member->quickhull));
00054       qh.reset(); 
00055     }
00056     dynamicupdate();
00057     break;
00058 
00059     case 'r': 
00060     {
00061       quickhull3D< pt3, double > & qh(*(member->quickhull));
00062       for ( ; !qh; ++qh);
00063     }
00064     dynamicupdate();
00065     break;
00066 
00067     case 's':
00068     {
00069       quickhull3D< pt3, double > & qh(*(member->quickhull));
00070       if (!qh)
00071         ++qh;
00072     }
00073     dynamicupdate();
00074     break;
00075 
00076     case 'x': 
00077     {
00078       quickhull3D< pt3, double > & qh(*(member->quickhull));
00079       for ( qh.reset(); !qh; ++qh);
00080     }
00081     dynamicupdate();
00082     break;
00083      
00084   }
00085 
00086   glutPostRedisplay();
00087 }

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

Definition at line 210 of file quickhull3Dtest.cpp.

References display01(), menusystem::fontcolor, gobjpush, keyboard01(), commandline::mapvar(), pointscontainer, and gobjContainer::set().

00211 {
00212   glutInit(&argc,argv);
00213   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00214   glutInitWindowSize(800,600);
00215   glutCreateWindow("");
00216   glutDisplayFunc(display01);
00217   glutKeyboardFunc(keyboard01);
00218 
00219   OpenGLinitialisation();
00220 
00221   glEnable(GL_DEPTH_TEST);
00222   glEnable(GL_CULL_FACE);
00223   glEnable(GL_NORMALIZE);
00224 
00225   xGraphics.set();
00226 
00227   member = this;
00228   displayaxes = new gobjSwitch<>( new myaxes(1.0), true);
00229   gobjpush(displayaxes);
00230 
00231   commandline cmd(argc,argv);
00232   uint numPoints(10);
00233   cmd.mapvar(numPoints,"n");
00234 
00235   typedef point3<double> pt3;
00236   //vector< pt3 > v;
00237   generateRandomPointsInSphere< pt3, double, random11<double> >(pts,numPoints+1);
00238 
00239   //cout << SHOW(pts.size()) << endl;
00240 
00241   gobjpush(new gobjglColor3f(0.0,1.0,0.0));
00242   gobjpush(new gobjglDisable(GL_LIGHTING));
00243 
00244   pointsdisplay3D< pt3 >( member->pointscontainer, pts, pointsdisplay, pointsnumber );
00245   gobjpush(new gobjSwitch<bool &>(&member->pointscontainer,pointsdisplay,false));
00246 
00247   menusystem * menu = 
00248     new menusystem(0,0,true,point2<GLint>(60,30),10);
00249   menu->fontcolor = point4<float>(218.0/255.0,165.0/255.0,32.0/255.0,0.75);
00250 
00251   menuswitch = new gobjSwitch<bool &>(menu,menuhelp);
00252 
00253   menu->addfont12("Hull calculation in 3D",2);
00254   menu->addfont10("p   Toggle the points.",1);
00255   menu->addfont10("P   Toggle numbering the points.",1);
00256   menu->addfont10("a   Toggle the axes.",2);
00257 
00258   menu->addfont10("x   reset and run",1);
00259   menu->addfont10("R   reset",1);
00260   menu->addfont10("r   run",1);
00261   menu->addfont10("s   step",2);
00262 
00263   menu->addfont10("h   toggle this help menu",1);
00264   menu->addfont10("ESC  quit");
00265 
00266   gobjpush(menuswitch);
00267 
00268   gobjpush(new gobjSwitch<>(&dynamic,true,false));
00269   
00270   glutPostRedisplay();
00271 
00272   quickhull = new quickhull3D< pt3, double >(pts);
00273 
00274   //quickhull3D< pt3, double > qh(pts);
00275 
00276   //for ( qh.reset(); !qh; ++qh);
00277   
00278 
00279   //cout << print(qh.boundary) << endl;
00280 
00281 
00282 /*
00283   quickhull3D< pt3, double > qh(v);
00284 
00285   //cout << SHOW(print(qh.boundary)) << endl;
00286 
00287   gobjpush(new gobjglDisable(GL_LIGHTING));
00288   gobjpush(new gobjglColor3ub(255,0,0));
00289   gobjpush(new gobjglBegin(GL_POINTS));
00290   for (uint i=0; i<qh.boundary.size(); ++i)
00291     { gobjpush(new gobjglVertex3d(v[qh.boundary[i]])); }
00292   gobjpush(new gobjglEnd());
00293 
00294   vector<uint> v2;
00295   integersetdiff(v2,qh.boundary,numPoints);
00296   gobjpush(new gobjglColor3ub(0,255,0));
00297   gobjpush(new gobjglBegin(GL_POINTS));
00298   for (uint i=0; i<v2.size(); ++i)
00299     { gobjpush(new gobjglVertex3d(v[v2[i]])); }
00300   gobjpush(new gobjglEnd());
00301 */
00302 
00303 
00304   //gobj::global->displaylist(1);
00305 
00306 
00307   zpr zz;
00308   glutMainLoop();
00309 }


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

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