proj home

Files   Classes   Functions   Hierarchy  

planeinttest.cpp

Go to the documentation of this file.
00001 #include <fstream>
00002 
00003 #include <commandline.h>
00004 #include <gobj.h>
00005 #include <graphmisc.h>
00006 #include <planeinttest.h>
00007 #include <planepointsurface.h>
00008 #include <pointsurface.h>
00009 #include <zpr.h>
00010 
00011 
00012 void planeinttestdisplay01()
00013 {
00014   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00015 
00016   gobj::global->draw();
00017 
00018   glerrordisplay();
00019   
00020   glutSwapBuffers();
00021 }
00022 
00023 void planeinttestkeyboard01(unsigned char key, int x, int y)
00024 {
00025   switch (key)
00026   {
00027     case 27:
00028       exit(0);
00029       break;
00030   }
00031 }
00032 
00033 void planeinttest::test01(int & argc, char** argv)
00034 {
00035   commandline cmd(argc,argv);
00036 
00037   string in;
00038 
00039   cmd.mapvar(in,"in");
00040   if ( in.empty() )
00041   {
00042     cout << "error: in=filename expected" << endl;
00043     return;
00044   }
00045 
00046   ifstream filein(in.c_str());
00047   assert(filein.good()==true);
00048   if (filein.good()==false)
00049     return;
00050 
00051   point3<double> nml;
00052   double d;
00053 
00054   filein >> nml.x;
00055   filein >> nml.y;
00056   filein >> nml.z;
00057   filein >> d;
00058 
00059   plane P1(nml,d);
00060 
00061   filein >> nml.x;
00062   filein >> nml.y;
00063   filein >> nml.z;
00064   filein >> d;
00065 
00066   plane P2(nml,d);
00067 
00068   //cout << SHOW(nml) << endl;
00069   //cout << SHOW(d) << endl;
00070   
00071   point3<double> A;
00072   point3<double> B;
00073 
00074   bool res = P1.intersects(A,B,P2);
00075   cout << SHOW(res) << endl;
00076     
00077 
00078   glutInit(&argc,argv);
00079   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00080   glutInitWindowSize(800,600);
00081   glutCreateWindow("");
00082   glutDisplayFunc(planeinttestdisplay01);
00083   glutKeyboardFunc(planeinttestkeyboard01);
00084 
00085   OpenGLinitialisation();
00086 
00087   glEnable(GL_DEPTH_TEST);
00088   glEnable(GL_CULL_FACE);
00089   glEnable(GL_NORMALIZE);
00090 
00092   zpr zz;
00093 
00094   xGraphics.set();
00095 
00096   planepointsurface f1(P1);
00097   pointsurface<> ps1(4000);
00098   ps1.pre.push(new gobjglColor3ub(184,134,11) );
00099   ps1.addsurface2D(f1);
00100   gobjpush(&ps1);
00101 
00102   planepointsurface f2(P2);
00103   pointsurface<> ps2(4000);
00104 
00105   f2.scaleSet(100.0);
00106 
00107   ps2.pre.push(new gobjglColor3ub(192,192,192) );
00108   ps2.addsurface2D(f2);
00109   gobjpush(&ps2);
00110 
00111   gobjpush(new gobjglDisable(GL_LIGHTING));
00112 
00113   gobjpush(new gobjglColor3ub(255,0,0) );
00114   gobjpush(new gobjglBegin(GL_LINES));
00115 
00116   gobjpush(new gobjglVertex3d(A+B*(-10.0)));
00117   gobjpush(new gobjglVertex3d(A+B*10.0));
00118 
00119   gobjpush(new gobjglEnd() );
00120 
00121   zz.update();
00122   glutMainLoop();
00123 }
00124 
00125 

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