Files Classes Functions Hierarchy
00001 00002 #include <iostream> 00003 #include <cmath> 00004 using namespace std; 00005 00006 #include <GL/glut.h> 00007 00008 00009 #include <func.h> 00010 #include <func2dovervec3d.h> 00011 #include <gobj.h> 00012 #include <graphmisc.h> 00013 #include <mathlib.h> 00014 #include <meshpatch.h> 00015 #include <meshpatchtest.h> 00016 #include <meshpatchptr.h> 00017 #include <point.h> 00018 #include <pointgrid3D.h> 00019 #include <pointgrid3Ddraw.h> 00020 #include <pointgrid3Dbilineardraw.h> 00021 #include <print.h> 00022 #include <triangleuniformsubdivision.h> 00023 #include <triangles3Tdisplay.h> 00024 #include <triangles3Tdisplaymulticolored.h> 00025 #include <zpr.h> 00026 00027 00028 typedef point3<double> pt3; 00029 typedef point3<double> const pt3c; 00030 00031 class meshtestpatch01 00032 { 00033 public: 00034 00035 pt3 pi[4]; 00036 00037 pt3c operator () (uintc i, uintc j) const 00038 { return pi[i+2*j]; } 00039 pt3 & operator () (uintc i, uintc j) 00040 { return pi[i+2*j]; } 00041 00042 meshtestpatch01(); 00043 00044 }; 00045 00046 meshtestpatch01::meshtestpatch01() 00047 { 00048 operator()(0,0) = pt3(0.0,0.0,0.0); 00049 operator()(1,0) = pt3(1.0,0.0,1.0); 00050 operator()(1,1) = pt3(1.0,1.0,2.0); 00051 operator()(0,1) = pt3(0.0,1.0,0.0); 00052 } 00053 00054 void meshpatchtest::test01() 00055 { 00056 meshpatch m(1,1); 00057 00058 meshtestpatch01 pij; 00059 00060 cout << "Enter u v: "; 00061 double u,v; 00062 cin >> u >> v; 00063 00064 pt3 p; 00065 m.eval(p,u,v,pij); 00066 00067 cout << SHOW(p) << endl; 00068 00069 } 00070 00071 funcA2(tempsin2,sin((x*x-y*y)*0.25),x,y,double,doublec); 00072 funcA2(tempsin3,sin(x*x-y*y),x,y,double,doublec); 00073 00074 gobjContainer xGraphics; 00075 00076 void meshpatchtestdisplay01() 00077 { 00078 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00079 00080 gobj::global->draw(); 00081 00082 glerrordisplay(); 00083 00084 glutSwapBuffers(); 00085 } 00086 00087 void meshpatchtestkeyboard01(unsigned char key, int x, int y) 00088 { 00089 switch (key) 00090 { 00091 case 27: 00092 exit(0); 00093 break; 00094 } 00095 } 00096 00097 void meshpatchtest::test02(int argc, char** argv) 00098 { 00099 glutInit(&argc,argv); 00100 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00101 glutInitWindowSize(800,600); 00102 glutCreateWindow(""); 00103 glutDisplayFunc(meshpatchtestdisplay01); 00104 glutKeyboardFunc(meshpatchtestkeyboard01); 00105 00106 OpenGLinitialisation(); 00107 00108 glEnable(GL_DEPTH_TEST); 00109 glEnable(GL_CULL_FACE); 00110 glEnable(GL_NORMALIZE); 00111 00112 zpr zz; 00113 00114 xGraphics.set(); 00115 00116 //pointgrid3D g(10,10,-1.0,3.0,-1.0,3.0); 00117 pointgrid3D g(5,4,-1.0,3.0,-1.0,3.0,true); 00118 00119 pointgrid3Ddraw gd(g); 00120 00121 gobjpush(&gd); 00122 00123 tempsin2 f2; 00124 00125 func2Dovervec3D< point3<double> >(g.pt,g.M*g.N).evalY(f2); 00126 00127 gd.update(); 00128 00129 //cout << printvecfunc(g.pt,g.M*g.N,"\n") << endl; 00130 00131 pointgrid3Dbilineardraw gbd(g); 00132 gobjpush(&gbd); 00133 gbd.update(); 00134 00135 00136 //gobj::globaldisplaylist(); 00137 00138 zz.update(); 00139 00140 glutMainLoop(); 00141 } 00142 00143 00144 void meshpatchtest::test03(int argc, char** argv) 00145 { 00146 glutInit(&argc,argv); 00147 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00148 glutInitWindowSize(800,600); 00149 glutCreateWindow(""); 00150 glutDisplayFunc(meshpatchtestdisplay01); 00151 glutKeyboardFunc(meshpatchtestkeyboard01); 00152 00153 OpenGLinitialisation(); 00154 00155 glEnable(GL_DEPTH_TEST); 00156 glEnable(GL_CULL_FACE); 00157 glEnable(GL_NORMALIZE); 00158 00159 zpr zz; 00160 00161 00162 xGraphics.set(); 00163 00164 vector< point3<double> > pts; 00165 vector< point3<uint> > vi; 00166 00167 pts.push_back( point3<double>(0.0,0.0,0.0)); 00168 pts.push_back( point3<double>(1.0,0.0,0.0)); 00169 pts.push_back( point3<double>(0.5,1.0,0.0)); 00170 00171 point3<uint> tri0(0,1,2); 00172 //vi.push_back(tri0); 00173 00174 /* 00175 triangleuniformsubdivision< point3<double> > tusd(vi,pts); 00176 tusd.divide(tri0); 00177 */ 00178 00179 vector< point3<uint> > vi2; 00180 triangleuniformsubdivision< point3<double> > tusd2(vi2,pts); 00181 00182 // tusd2.divide(vi); 00183 00184 tusd2.divide(tri0,3); 00185 00186 00187 /* 00188 vectorprint::space="\n"; 00189 cout << "vi" << endl; 00190 cout << vi << endl; 00191 cout << SHOW(vi.size()) << endl; 00192 cout << "pts" << endl; 00193 cout << pts << endl; 00194 cout << SHOW(pts.size()) << endl; 00195 */ 00196 00197 triangles3Tdisplaymulticolored<GLfloat,double> * td = 00198 new triangles3Tdisplaymulticolored<GLfloat,double>(vi2.size(), & vi2[0], & pts[0]); 00199 gobjpush(td); 00200 00201 zz.update(); 00202 glutMainLoop(); 00203 } 00204 00205 00206 void meshpatchtest::test04(int argc, char** argv) 00207 { 00208 glutInit(&argc,argv); 00209 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00210 glutInitWindowSize(800,600); 00211 glutCreateWindow(""); 00212 glutDisplayFunc(meshpatchtestdisplay01); 00213 glutKeyboardFunc(meshpatchtestkeyboard01); 00214 00215 OpenGLinitialisation(); 00216 00217 glEnable(GL_DEPTH_TEST); 00218 glEnable(GL_CULL_FACE); 00219 glEnable(GL_NORMALIZE); 00220 00221 zpr zz; 00222 00223 xGraphics.set(); 00224 00225 //pointgrid3D g(10,10,-1.0,3.0,-1.0,3.0); 00226 pointgrid3D g(5,4,-1.0,3.0,-1.0,3.0,true); 00227 00228 pointgrid3Ddraw gd(g); 00229 00230 gobjpush(&gd); 00231 00232 tempsin2 f2; 00233 00234 func2Dovervec3D< point3<double> >(g.pt,g.M*g.N).evalY(f2); 00235 00236 gd.update(); 00237 00238 //cout << printvecfunc(g.pt,g.M*g.N,"\n") << endl; 00239 00240 //pointgrid3Dbilineardraw gbd(g); 00241 //gobjpush(&gbd); 00242 //gbd.update(); 00243 00244 00245 vector< point3<double> > pts; 00246 vector< point3<uint> > vi; 00247 g.createIndexedTriangles(pts,vi); 00248 00249 triangles3Tdisplaymulticolored<GLfloat,double> * td = 00250 new triangles3Tdisplaymulticolored<GLfloat,double>(vi.size(), & vi[0], & pts[0]); 00251 gobjpush(td); 00252 00253 00254 zz.update(); 00255 glutMainLoop(); 00256 } 00257 00258 00259 00260
1.5.8