proj home

Files   Classes   Functions   Hierarchy  

vrmltest Class Reference

Test the VRML classes. More...

#include <vrmltest.h>

Collaboration diagram for vrmltest:

List of all members.

Static Public Member Functions

static void test01 (int argc, char **argv)
 Parse head.wrl .
static void test02 (int argc, char **argv)
 Display a VRML file.
static void test03 (int argc, char **argv)
 Prompt user for vrml file, parse and print shapes.


Detailed Description

Test the VRML classes.

Only a limited subset of VRML is supported.

Definition at line 16 of file vrmltest.h.


Member Function Documentation

void vrmltest::test01 ( int  argc,
char **  argv 
) [static]

Parse head.wrl .

Definition at line 57 of file vrmltest.cpp.

References vrmlconvert::eval(), print(), and vrmlshapeparse::readfile().

Referenced by main().

00058 {
00059   vrmlshapeparse p;
00060  
00061 //  string filename;
00062 //  getfilename(filename);
00063 
00064   string filename("head.wrl");
00065   assert( p.readfile(filename.c_str()) );  
00066 
00067   vector< vrmlshape > s;
00068   vrmlconvert vc;
00069 
00070   assert(vc.eval(s,p));
00071 
00072   cout << endl << endl;
00073   cout << "Printing vrmlshape" << endl;
00074   cout << endl;
00075   cout << "s.size()=" << s.size() << endl;
00076   cout << endl;
00077 
00078 
00079   for (unsigned int i=0; i<s.size(); ++i)
00080     s[i].print(cout);
00081 }

void vrmltest::test02 ( int  argc,
char **  argv 
) [static]

Display a VRML file.

./main filename=head.wrl

Definition at line 83 of file vrmltest.cpp.

References vrmllines::addnormals(), camera::lookat(), commandline::mapvar(), vrmlshapeparse::readfile(), and zpr::update().

Referenced by main().

00084 {
00085   cout << endl;
00086   cout << "VRML reader" << endl;
00087   cout << endl;
00088   cout << "$./main filename=<file>.wrl" << endl;
00089   cout << "  seenormals=true   - to see the normals." << endl;
00090   cout << "  winding=true      - to see the triangles winding." << endl;
00091   cout << endl;
00092 
00093   commandline cmd(argc,argv);
00094   string vrmlfile("head.wrl");
00095   cmd.mapvar(vrmlfile,"vrmlfile");
00096   if (vrmlfile.empty())
00097   {
00098     cout << "error: file must be assigned." << endl;
00099     cout << "  eg vrmlfile=head.wrl" << endl;
00100     return;
00101   }
00102 
00103   if (! vsp.readfile(vrmlfile) )
00104   {
00105     cout << "error: file not read in." << endl;
00106     return;
00107   }
00108 
00109   vrmlconvert().eval(vs,vsp);
00110 
00111   cmd.mapvar(winding,"winding");
00112 
00113   bool seenormals(false);
00114   cmd.mapvar(seenormals,"seenormals");
00115   if (seenormals)
00116   {
00117 
00118     float ci[3];
00119     ci[0] = 1.0;
00120     ci[1] = 0.0;
00121     ci[2] = 0.0;
00122 
00123     for (unsigned int i=0; i<vs.size(); ++i)
00124       vL.addnormals(vs[i],(float*)ci,1.8);
00125   }
00126 
00127   glutInit(&argc,argv);
00128   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00129   glutInitWindowSize(800,800);
00130   glutCreateWindow("");
00131   glutDisplayFunc(display);
00132   glutKeyboardFunc(keyboard);
00133 
00134   zpr zz;
00135 
00136   OpenGLinitialisation();
00137 
00138   glEnable(GL_DEPTH_TEST);
00139   glEnable(GL_CULL_FACE);
00140   glEnable(GL_NORMALIZE);
00141 
00142   zz.update();
00143 
00144   camera::lookat(cmd,0.0,0.0,4.0);
00145 
00146   GLdouble s=0.25;
00147   glScalef(s,s,s);
00148 
00149   glutMainLoop();
00150 }

void vrmltest::test03 ( int  argc,
char **  argv 
) [static]

Prompt user for vrml file, parse and print shapes.

Definition at line 152 of file vrmltest.cpp.

References vrmlshapeparse::readfile(), and vrmlshapeparse::vshp.

Referenced by main().

00153 {
00154   vrmlshapeparse p;
00155  
00156   string filename;
00157   getfilename(filename);
00158 
00159   p.readfile(filename.c_str());
00160 
00161   cout << "Reading " << filename << endl; 
00162 
00163   if (p.vshp.empty()==false)
00164   {
00165     for (uint i=0; i<p.vshp.size(); ++i)
00166       p.vshp[i].print(cout);
00167   }
00168 }


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:25 2011 for Chelton Evans Source by  doxygen 1.5.8