Files Classes Functions Hierarchy
00001 00002 #include <commandline.h> 00003 00004 #include <point.h> 00005 #include <polytopeD2linked.h> 00006 #include <polytopeD2linkedtest.h> 00007 #include <polytopeD2tess.h> 00008 #include <polytopeD2tessdisp01.h> 00009 00010 #include <graphmisc.h> 00011 #include <random.h> 00012 #include <zpr.h> 00013 00014 void polytopesD2linkedtest::test01() 00015 { 00016 typedef point2<double> pt2; 00017 00018 vector<pt2> pts; 00019 00020 pts.push_back( pt2(0.0,0.0) ); 00021 pts.push_back( pt2(1.0,0.0) ); 00022 pts.push_back( pt2(1.0,1.0) ); 00023 pts.push_back( pt2(0.0,1.0) ); 00024 pts.push_back( pt2(0.5,1.3) ); 00025 00026 vector<polytopeD2linked> vi(1); 00027 vi.push_back( polytopeD2linked(0,1,2,3,0,0,2,0) ); 00028 vi.push_back( polytopeD2linked(2,4,3,0,0,1) ); 00029 00030 for (uint i=1; i<vi.size(); ++i) 00031 cout << (string)vi[i] << endl; 00032 00033 polytopeD2tess< vector<polytopeD2linked>, vector<pt2> > 00034 tess(vi,pts); 00035 assert(tess.verify()); 00036 00037 00038 00039 //polytopeD2linkedverify< vector<polytopeD2linked> > ver(vi); 00040 //assert(ver.eval()); 00041 } 00042 00043 void polytopesD2linkedtest::test02(int argc, char** argv) 00044 { 00045 glutInit(&argc,argv); 00046 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00047 glutInitWindowSize(800,600); 00048 glutCreateWindow(""); 00049 glutDisplayFunc(display01); 00050 glutKeyboardFunc(keyboard01); 00051 00052 OpenGLinitialisation(); 00053 00054 glEnable(GL_DEPTH_TEST); 00055 glEnable(GL_CULL_FACE); 00056 glEnable(GL_NORMALIZE); 00057 00058 xGraphics.set(); 00059 00060 commandline cmd(argc,argv); 00061 00062 typedef point2<double> pt2; 00063 00064 vector<pt2> pts(1); 00065 00066 pts.push_back( pt2(0.0,0.0) ); 00067 pts.push_back( pt2(1.0,0.0) ); 00068 pts.push_back( pt2(1.0,1.0) ); 00069 pts.push_back( pt2(0.0,1.0) ); 00070 pts.push_back( pt2(0.5,1.3) ); 00071 00072 vector<polytopeD2linked> vi(1); 00073 vi.push_back( polytopeD2linked(1,2,3,4,0,0,2,0) ); 00074 vi.push_back( polytopeD2linked(3,5,4,0,0,1) ); 00075 00076 polytopeD2tess< vector<polytopeD2linked>, vector<pt2> > 00077 tess(vi,pts); 00078 assert(tess.verify()); 00079 00080 tess.printvi(); 00081 00082 pts.push_back( (pts[3]+pts[4])*0.5 ); 00083 tess.addpoint(2,4,6); 00084 00085 tess.printvi(); 00086 00087 assert(tess.verify()); 00088 00089 polytopeD2tessdisp01 00090 < 00091 vector<pt2>, 00092 vector<polytopeD2linked> 00093 > tessdisp(pts,vi); 00094 00095 tessdisp.multicolored=true; 00096 tessdisp.labelpolytopes=true; 00097 tessdisp.labelpoints=true; 00098 00099 gobjpush(new gobjglDisable(GL_LIGHTING)); 00100 00101 tessdisp.eval(*gobj::global); 00102 00103 // glDisable(GL_DEPTH_TEST); 00104 // glEnable(GL_BLEND); 00105 // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00106 00107 zpr zz; 00108 glutMainLoop(); 00109 } 00110 00111 00112 void polytopesD2linkedtest::test03(int argc, char** argv) 00113 { 00114 glutInit(&argc,argv); 00115 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00116 glutInitWindowSize(800,600); 00117 glutCreateWindow(""); 00118 glutDisplayFunc(display01); 00119 glutKeyboardFunc(keyboard01); 00120 00121 OpenGLinitialisation(); 00122 00123 glEnable(GL_DEPTH_TEST); 00124 glEnable(GL_CULL_FACE); 00125 glEnable(GL_NORMALIZE); 00126 00127 xGraphics.set(); 00128 00129 commandline cmd(argc,argv); 00130 00131 typedef point2<double> pt2; 00132 00133 vector<pt2> pts(17); 00134 00135 pts[0] = pt2(0.0,0.0); 00136 pts[1] = pt2(1.0,3.0); 00137 pts[2] = pt2(2.0,3.0); 00138 pts[3] = pt2(3.0,2.0); 00139 pts[4] = pt2(3.0,1.0); 00140 pts[5] = pt2(2.0,0.0); 00141 pts[6] = pt2(1.0,0.0); 00142 pts[7] = pt2(0.0,0.0); 00143 pts[8] = pt2(0.0,1.0); 00144 pts[9] = pt2(0.0,2.0); 00145 pts[10] = pt2(0.0,3.0); 00146 pts[11] = pt2(1.0,2.0); 00147 pts[12] = pt2(2.0,2.0); 00148 pts[13] = pt2(2.0,1.0); 00149 pts[14] = pt2(1.0,1.0); 00150 pts[15] = pt2(3.0,3.0); 00151 pts[16] = pt2(3.0,0.0); 00152 00153 00154 vector<polytopeD2linked> vi(1); 00155 vi.push_back( polytopeD2linked(1,10,9,11,0,0,2,0) ); 00156 vi.push_back( polytopeD2linked(3,12,11,9,8,14,13,4, 00157 5,0,1,0,3,0,4,0) ); 00158 vi.push_back( polytopeD2linked(14,8,7,6,2,0,0,0) ); 00159 vi.push_back( polytopeD2linked(4,13,5,16,2,0,0,0) ); 00160 vi.push_back( polytopeD2linked(3,15,2,12,0,0,0,2) ); 00161 00162 polytopeD2tessdisp01 00163 < 00164 vector<pt2>, 00165 vector<polytopeD2linked> 00166 > tessdisp(pts,vi); 00167 00168 tessdisp.multicolored=true; 00169 tessdisp.labelpolytopes=true; 00170 tessdisp.labelpoints=true; 00171 00172 tessdisp.eval(*gobj::global); 00173 00174 zpr zz; 00175 glutMainLoop(); 00176 } 00177 00178 00179 00180 void polytopesD2linkedtest::keyboard01 00181 ( 00182 unsigned char key, 00183 int x, 00184 int y 00185 ) 00186 { 00187 switch (key) 00188 { 00189 case 27: 00190 exit(0); 00191 break; 00192 } 00193 } 00194 00195 void polytopesD2linkedtest::display01() 00196 { 00197 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00198 00199 gobj::global->draw(); 00200 00201 00202 glerrordisplay(); 00203 00204 glutSwapBuffers(); 00205 } 00206 00207 00208 00209 void polytopesD2linkedtest::test04(int argc, char** argv) 00210 { 00211 glutInit(&argc,argv); 00212 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00213 glutInitWindowSize(800,600); 00214 glutCreateWindow(""); 00215 glutDisplayFunc(display01); 00216 glutKeyboardFunc(keyboard01); 00217 00218 OpenGLinitialisation(); 00219 00220 glEnable(GL_DEPTH_TEST); 00221 glEnable(GL_CULL_FACE); 00222 glEnable(GL_NORMALIZE); 00223 00224 xGraphics.set(); 00225 00226 commandline cmd(argc,argv); 00227 00228 typedef point2<double> pt2; 00229 00230 vector<pt2> pts; 00231 00232 pts.push_back( pt2(0.0,0.0) ); 00233 pts.push_back( pt2(0.5,0.0) ); 00234 pts.push_back( pt2(0.5,1.0) ); 00235 00236 vector<polytopeD2linked> vi(1); 00237 vi.push_back( polytopeD2linked(1,2,2,0) ); 00238 vi.push_back( polytopeD2linked(2,1,1,0) ); 00239 00240 polytopeD2tessdisp01 00241 < 00242 vector<pt2>, 00243 vector<polytopeD2linked> 00244 > tessdisp(pts,vi); 00245 00246 tessdisp.multicolored=true; 00247 tessdisp.labelpolytopes=true; 00248 tessdisp.labelpoints=true; 00249 00250 tessdisp.eval(*gobj::global); 00251 00252 zpr zz; 00253 glutMainLoop(); 00254 } 00255
1.5.8