proj home

Files   Classes   Functions   Hierarchy  

spiralindextest.cpp

Go to the documentation of this file.
00001 
00002 #include <commandline.h>
00003 #include <graphmisc.h>
00004 #include <spiralindex.h>
00005 #include <spiralindextest.h>
00006 
00007 #include <zpr.h>
00008 
00009 
00010 void spiralindextest::keyboard01
00011 (
00012   unsigned char key, 
00013   int x, 
00014   int y
00015 )
00016 {
00017   switch (key)
00018   {
00019     case 27:
00020       exit(0);
00021       break;
00022   }
00023 }
00024 
00025 void spiralindextest::display01()
00026 { 
00027   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00028 
00029   gobj::global->draw();
00030 
00031 
00032   glerrordisplay();
00033   
00034   glutSwapBuffers();
00035 }
00036 
00037 void spiralindextest::test02(int argc, char** argv)
00038 {
00039   glutInit(&argc,argv);
00040   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00041   glutInitWindowSize(800,600);
00042   glutCreateWindow("");
00043   glutDisplayFunc(display01);
00044   glutKeyboardFunc(keyboard01);
00045 
00046   OpenGLinitialisation();
00047 
00048   glEnable(GL_DEPTH_TEST);
00049   glEnable(GL_CULL_FACE);
00050   glEnable(GL_NORMALIZE);
00051 
00052   xGraphics.set();
00053 
00054 
00055   uint M = 6;
00056   uint N = 4;
00057 
00058   commandline cmd(argc,argv);
00059   cmd.mapvar(M,"M");
00060   cmd.mapvar(N,"N");
00061   bool anticlockwise(true);
00062   cmd.mapvar(anticlockwise,"anticlockwise");
00063 
00064   double dy = 1.0 / ((double)M-1.0);
00065   double dx = 1.0 / ((double)N-1.0);
00066 
00067   gobjQuadric * q2 = new gobjQuadric();
00068   q2->radius = 0.02;
00069   q2->slices=20;
00070   q2->loops=6;
00071   gobjpush(q2);
00072 
00073   gobjpush( new gobjglColor3ub(0,255,0) );
00074   for (uint r=0; r<M; ++r)
00075   {
00076     for (uint k=0; k<N; ++k)
00077       { gobjpush( new gobjMySphereDraw(pt3(dx*k,1.0-dy*r,0.0),q2) ); }
00078   }
00079 
00080   spiralindex<> si(M,N,anticlockwise);
00081 
00082   gobjpush( new gobjglColor3ub(255,0,0) );
00083   gobjpush( new gobjglBegin(GL_LINE_STRIP) );
00084 
00085   int row;
00086   int col;
00087 
00088   for (si.reset(); !si; ++si)
00089   {
00090     si.pos(row,col);
00091     gobjpush( new gobjglVertex3d( pt3(dx*col,1.0-dy*row,0.0) ) );
00092   }
00093 
00094   gobjpush( new gobjglEnd() );
00095 
00096 
00097   zpr zz;
00098   glutMainLoop();
00099 }
00100 
00101 void spiralindextest::test01(int argc, char** argv)
00102 {
00103   uint M = 6;
00104   uint N = 4;
00105 
00106   commandline cmd(argc,argv);
00107   cmd.mapvar(M,"M");
00108   cmd.mapvar(N,"N");
00109   bool anticlockwise(true);
00110   cmd.mapvar(anticlockwise,"anticlockwise");
00111 
00112   spiralindex<> si(M,N,anticlockwise);
00113 
00114   int k2;
00115 
00116   int row;
00117   int col;
00118 
00119   for (si.reset(); !si; ++si)
00120   {
00121     si.pos(row,col);
00122     si.pos(k2);
00123     cout << "(" << row << ", " << col << ")   ";
00124     cout << SHOW(k2) << endl;
00125   }
00126 }
00127 
00128 void spiralindextest::test03(int argc, char** argv)
00129 {
00130   uint M = 6;
00131   uint N = 4;
00132   uint Z = 3;
00133 
00134   commandline cmd(argc,argv);
00135   cmd.mapvar(M,"M");
00136   cmd.mapvar(N,"N");
00137   cmd.mapvar(Z,"Z");
00138   bool anticlockwise(true);
00139   cmd.mapvar(anticlockwise,"anticlockwise");
00140 
00141   spiralindex3D<> si(M,N,Z,anticlockwise);
00142 
00143   int k2;
00144 
00145   int row;
00146   int col;
00147   int z;
00148 
00149   int count = 0;
00150   for (si.reset(); !si; ++si)
00151   {
00152     si.pos(row,col,z);
00153     si.pos(k2);
00154     cout << "(" << row << ", " << col << ", " << z << ")   ";
00155     cout << SHOW(k2) << endl;
00156 
00157     if (++count == 100)
00158       break;
00159     
00160   }
00161 
00162 }
00163 
00164 
00165 void spiralindextest::test04(int argc, char** argv)
00166 {
00167   glutInit(&argc,argv);
00168   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00169   glutInitWindowSize(800,600);
00170   glutCreateWindow("");
00171   glutDisplayFunc(display01);
00172   glutKeyboardFunc(keyboard01);
00173 
00174   OpenGLinitialisation();
00175 
00176   glEnable(GL_DEPTH_TEST);
00177   glEnable(GL_CULL_FACE);
00178   glEnable(GL_NORMALIZE);
00179 
00180   xGraphics.set();
00181 
00182   uint M = 6;
00183   uint N = 4;
00184   uint Z = 3;
00185 
00186   commandline cmd(argc,argv);
00187   cmd.mapvar(M,"M");
00188   cmd.mapvar(N,"N");
00189   cmd.mapvar(Z,"Z");
00190   bool anticlockwise(true);
00191   cmd.mapvar(anticlockwise,"anticlockwise");
00192 
00193   double dy = 1.0 / ((double)M-1.0);
00194   double dx = 1.0 / ((double)N-1.0);
00195   double dz = 1.0 / ((double)Z-1.0);
00196 
00197   gobjQuadric * q2 = new gobjQuadric();
00198   q2->radius = 0.02;
00199   q2->slices=20;
00200   q2->loops=6;
00201   gobjpush(q2);
00202 
00203   gobjpush( new gobjglColor3ub(0,255,0) );
00204   for (uint zi=0; zi<Z; ++zi)
00205   {
00206     for (uint r=0; r<M; ++r)
00207     {
00208       for (uint k=0; k<N; ++k)
00209         { gobjpush( new gobjMySphereDraw(pt3(dx*k,1.0-dy*r,dz*zi),q2) ); }
00210     }
00211   }
00212 
00213   spiralindex3D<> si(M,N,Z,anticlockwise);
00214 
00215   gobjpush( new gobjglColor3ub(255,0,0) );
00216   gobjpush( new gobjglBegin(GL_LINE_STRIP) );
00217 
00218   int row;
00219   int col;
00220   int z;
00221 
00222   for (si.reset(); !si; ++si)
00223   {
00224     si.pos(row,col,z);
00225     gobjpush( new gobjglVertex3d( pt3(dx*col,1.0-dy*row,dz*z) ) );
00226   }
00227 
00228   gobjpush( new gobjglEnd() );
00229 
00230 
00231   zpr zz;
00232   glutMainLoop();
00233 }
00234 

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