proj home

Files   Classes   Functions   Hierarchy  

snakesorttest Class Reference

Test the snakesort class. More...

#include <snakesorttest.h>

Collaboration diagram for snakesorttest:

List of all members.

Public Member Functions

void test02 (int argc, char **argv)
 Display a 2D snake sort.
void test03 (int argc, char **argv)
 Display a 3D snake sort.

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.
static void test01 (int argc, char **argv)
 Print a 1D snake sort test.


Detailed Description

Test the snakesort class.

By visually seeing the sort the algorithm is somewhat validated. Lines connecting successive points are drawn.

Definition at line 16 of file snakesorttest.h.


Member Function Documentation

void snakesorttest::display01 (  )  [static]

Displays the gobj::global with double buffering.

Definition at line 29 of file snakesorttest.cpp.

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

Referenced by test02(), and test03().

00030 { 
00031   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00032 
00033   gobj::global->draw();
00034 
00035 
00036   glerrordisplay();
00037   
00038   glutSwapBuffers();
00039 }

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

Default keyboard handler - ESC to quit.

Definition at line 15 of file snakesorttest.cpp.

Referenced by test02(), and test03().

00020 {
00021   switch (key)
00022   {
00023     case 27:
00024       exit(0);
00025       break;
00026   }
00027 }

void snakesorttest::test01 ( int  argc,
char **  argv 
) [static]

Print a 1D snake sort test.

Definition at line 41 of file snakesorttest.cpp.

References snakesort::d1(), and print().

Referenced by main().

00042 {
00043   int a1[]=
00044   {
00045     93,2,95,-2,5, 
00046     84,23,58,-10,50,
00047     100,120,-73 
00048   };
00049 
00050   snakesort::d1(&a1[0],13,5,less<int>());
00051   cout << print(a1,a1+13) << endl;
00052 }

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

Display a 2D snake sort.

Definition at line 55 of file snakesorttest.cpp.

References snakesort::d2(), display01(), gobjContainer::displaylist(), gobj::global, gobjpush, keyboard01(), and gobjContainer::set().

00056 {
00057   glutInit(&argc,argv);
00058   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00059   glutInitWindowSize(800,600);
00060   glutCreateWindow("");
00061   glutDisplayFunc(display01);
00062   glutKeyboardFunc(keyboard01);
00063 
00064   OpenGLinitialisation();
00065 
00066   glEnable(GL_DEPTH_TEST);
00067   glEnable(GL_CULL_FACE);
00068   glEnable(GL_NORMALIZE);
00069 
00070   xGraphics.set();
00071 
00072   uint N(125);
00073   vector< point2<double> > v;
00074   fillvec(v,N);
00075 
00076   snakesort::d2(&v[0],v.size(),less<double>());
00077 
00078   drawlinethroughpoints(v);
00079 
00080   typedef point3<double> pt3;
00081 
00082   vector<pt3> v2;
00083   for (uint i=0; i<N; ++i)
00084     v2.push_back( pt3(v[i].x,v[i].y,0.0) );
00085   drawpoints(v2);
00086 
00087   gobjpush( new myaxes(1.0) );
00088   
00089 
00090   gobj::global->displaylist(1);
00091   zpr zz;
00092   glutMainLoop();
00093 }

void snakesorttest::test03 ( int  argc,
char **  argv 
)

Display a 3D snake sort.

Definition at line 166 of file snakesorttest.cpp.

References snakesort::d3(), display01(), gobjContainer::displaylist(), gobj::global, gobjpush, keyboard01(), and gobjContainer::set().

00167 {
00168   glutInit(&argc,argv);
00169   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00170   glutInitWindowSize(800,600);
00171   glutCreateWindow("");
00172   glutDisplayFunc(display01);
00173   glutKeyboardFunc(keyboard01);
00174 
00175   OpenGLinitialisation();
00176 
00177   glEnable(GL_DEPTH_TEST);
00178   glEnable(GL_CULL_FACE);
00179   glEnable(GL_NORMALIZE);
00180 
00181   xGraphics.set();
00182 
00183   uint N(100);
00184   vector< pt3 > v;
00185   fillvec(v,N);
00186 
00187   snakesort::d3(&v[0],N,less<double>());
00188 
00189   drawlinethroughpoints(v);
00190   drawpoints(v);
00191 
00192   gobjpush( new myaxes(1.0) );
00193 
00194   gobj::global->displaylist(1);
00195   zpr zz;
00196   glutMainLoop();
00197 }


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

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