Files Classes Functions Hierarchy
#include <spiralindextest.h>
Public Types | |
| typedef point2< double > | pt2 |
| typedef point3< double > | pt3 |
Public Member Functions | |
| void | test02 (int argc, char **argv) |
| Display a spiral. | |
| void | test04 (int argc, char **argv) |
| Display a 3D spiral. | |
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 out a spiral's indexes. | |
| static void | test03 (int argc, char **argv) |
| Print out a 3D spiral's indexes. | |
Definition at line 10 of file spiralindextest.h.
| typedef point2<double> spiralindextest::pt2 |
Definition at line 16 of file spiralindextest.h.
| typedef point3<double> spiralindextest::pt3 |
Definition at line 17 of file spiralindextest.h.
| void spiralindextest::display01 | ( | ) | [static] |
Displays the gobj::global with double buffering.
Definition at line 25 of file spiralindextest.cpp.
References gobjContainer::draw(), glerrordisplay(), and gobj::global.
Referenced by test02(), and test04().
00026 { 00027 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00028 00029 gobj::global->draw(); 00030 00031 00032 glerrordisplay(); 00033 00034 glutSwapBuffers(); 00035 }
| void spiralindextest::keyboard01 | ( | unsigned char | key, | |
| int | x, | |||
| int | y | |||
| ) | [static] |
Default keyboard handler - ESC to quit.
Definition at line 11 of file spiralindextest.cpp.
Referenced by test02(), and test04().
| void spiralindextest::test01 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Print out a spiral's indexes.
Definition at line 101 of file spiralindextest.cpp.
References commandline::mapvar(), spiralindex< T >::pos(), spiralindex< T >::reset(), and SHOW.
Referenced by main().
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 }
| void spiralindextest::test02 | ( | int | argc, | |
| char ** | argv | |||
| ) |
Display a spiral.
Definition at line 37 of file spiralindextest.cpp.
References display01(), gobjpush, keyboard01(), gobjQuadric::loops, commandline::mapvar(), spiralindex< T >::pos(), r, gobjQuadric::radius, spiralindex< T >::reset(), gobjContainer::set(), and gobjQuadric::slices.
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 }
| void spiralindextest::test03 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Print out a 3D spiral's indexes.
Definition at line 128 of file spiralindextest.cpp.
References commandline::mapvar(), spiralindex3D< T >::pos(), spiralindex3D< T >::reset(), and SHOW.
Referenced by main().
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 }
| void spiralindextest::test04 | ( | int | argc, | |
| char ** | argv | |||
| ) |
Display a 3D spiral.
Definition at line 165 of file spiralindextest.cpp.
References display01(), gobjpush, keyboard01(), gobjQuadric::loops, commandline::mapvar(), spiralindex3D< T >::pos(), r, gobjQuadric::radius, spiralindex3D< T >::reset(), gobjContainer::set(), and gobjQuadric::slices.
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 }
1.5.8