proj home

Files   Classes   Functions   Hierarchy  

main.cpp File Reference

#include <vector>
#include <GL/glut.h>
#include <commandline.h>
#include <cpsphere.h>
#include <delaunay3D.h>
#include <pointsdisplay.h>
#include <gobj.h>
#include <graphmisc.h>
#include <point.h>
#include <random.h>
#include <tetrahedron.h>
#include <tetrahedrondraw.h>
#include <zpr.h>

Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

void test01 (int argc, char **argv)
void keyboard (unsigned char key, int x, int y)
void display01 ()
void drawspheres01 (vector< point3< double > > const &v, vector< point4< uint > > const &vi)
void init ()
void test02 (int argc, char **argv)
void display02 ()
void test03 (int argc, char **argv)
int main (int argc, char **argv)

Variables

gobjContainer xGraphics (true)
cpspherepcpsphere = 0


Function Documentation

void display01 (  ) 

Definition at line 75 of file main.cpp.

References gobjContainer::draw(), glerrordisplay(), and xGraphics.

Referenced by menusystemtest::test01(), test02(), and test03().

00076 {
00077   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00078 
00079   xGraphics.draw();
00080 
00081   glerrordisplay();
00082   
00083   glutSwapBuffers();
00084 }

void display02 (  ) 

Definition at line 253 of file main.cpp.

References gobjContainer::draw(), glerrordisplay(), and xGraphics.

Referenced by menusystemtest::test02(), and test03().

00254 {
00255   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00256 
00257   xGraphics.draw();
00258 
00259   glerrordisplay();
00260   
00261   glutSwapBuffers();
00262 }

void drawspheres01 ( vector< point3< double > > const &  v,
vector< point4< uint > > const &  vi 
)

Definition at line 87 of file main.cpp.

References tetrahedrondraw< T, D >::displayedges().

Referenced by test02().

00091 {
00092   uintc imax = vi.size();
00093 
00094 /*
00095   double radius;
00096   uintc slices=30;
00097   uintc stacks=30;
00098 
00099   random11<double> r;
00100 
00101   xGraphics.push_back( new gobjglDisable(GL_DEPTH_TEST) );
00102   xGraphics.push_back( new gobjglEnable(GL_BLEND) );
00103   xGraphics.push_back( 
00104     new gobjglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) );
00105   xGraphics.push_back( new gobjglEnable(GL_LIGHTING) );
00106 
00107   for (uint i=0; i<imax; ++i)
00108   {
00109     point3<double> const & P1( v[ vi[i].x ] );
00110     point3<double> const & P2( v[ vi[i].y ] );
00111     point3<double> const & P3( v[ vi[i].z ] );
00112     point3<double> const & P4( v[ vi[i].a ] );
00113 
00114     tetrahedron<double> const t(P1,P2,P3,P4);
00115     point3<double> const c(t.circumcenter());
00116     radius = (c-P1).distance();
00117 
00118     xGraphics.push_back( new gobjglColor4f(r(),r(),r(),0.1) );
00119 
00120     xGraphics.push_back( new gobjglPushMatrix() );
00121     xGraphics.push_back( new gobjglTranslatef(c) );
00122     xGraphics.push_back( 
00123       new gobjglutSolidSphere(radius,slices,stacks) );
00124       //new gobjglutWireSphere(radius,slices,stacks) );
00125 
00126     xGraphics.push_back( new gobjglPopMatrix() );
00127   }
00128 
00129   xGraphics.push_back( new gobjglDisable(GL_BLEND) );
00130 
00131 */
00132 
00133 
00134   for (uint i=0; i<imax; ++i)
00135   {
00136     point3<double> const & P1( v[ vi[i].x ] );
00137     point3<double> const & P2( v[ vi[i].y ] );
00138     point3<double> const & P3( v[ vi[i].z ] );
00139     point3<double> const & P4( v[ vi[i].w ] );
00140 
00141     tetrahedrondraw<point3<double>,double> td(P1,P2,P3,P4);
00142     td.displayedges();
00143   }
00144 
00145 }

void init (  ) 

Definition at line 148 of file main.cpp.

Referenced by exploreh< FN, XI, T >::exploreh(), keyboardinterface::keyboardinterface(), singletontest01(), test02(), test03(), and textoverlay::textoverlay().

00149 {
00150   GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
00151   GLfloat mat_shininess[] = { 50.0 };
00152   GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
00153   GLfloat white_light[] = { 1.0, 1.0, 1.0, 1.0 };
00154  
00155   glClearColor(0.0,0.0,0.0,0.0);
00156   glShadeModel(GL_SMOOTH);
00157  
00158   glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
00159   glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
00160   glLightfv(GL_LIGHT0, GL_POSITION, light_position);
00161   glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
00162   glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
00163 
00164   glEnable(GL_LIGHTING);
00165   glEnable(GL_LIGHT0);
00166   glEnable(GL_DEPTH_TEST);
00167   glEnable(GL_NORMALIZE);
00168   glEnable(GL_COLOR_MATERIAL); 
00169 }

void keyboard ( unsigned char  key,
int  x,
int  y 
)

Definition at line 52 of file main.cpp.

References cpsphere::statedec(), and cpsphere::stateinc().

00057 {
00058   switch (key)
00059   {
00060     case 27:
00061       exit(0);
00062 
00063     case 'a':
00064       pcpsphere->stateinc();
00065       glutPostRedisplay();
00066       break;
00067 
00068     case 'A':
00069       pcpsphere->statedec();
00070       glutPostRedisplay();
00071       break;
00072   }
00073 }

int main ( int  argc,
char **  argv 
)

Definition at line 323 of file main.cpp.

References gobjContainer::set(), test02(), and xGraphics.

00324 {
00325   xGraphics.set();
00326 
00327   test02(argc,argv);
00328 
00329   return 0;
00330 }

void test01 ( int  argc,
char **  argv 
)

Definition at line 32 of file main.cpp.

References delaunay3D::eval(), r, and delaunay3D::tet.

00033 {
00034   vector< point3<double> > v;
00035 
00036   uint n=5;
00037     
00038   random11<double> r;
00039   for (uint i=0; i<n; ++i)
00040     v.push_back( point3<double>(r(),r(),r()) );
00041   
00042   delaunay3D tess(v);
00043   tess.eval();
00044 
00045   for (uint i=0; i<tess.tet.size(); ++i)
00046     cout << tess.tet[i] << endl;
00047 }

void test02 ( int  argc,
char **  argv 
)

Definition at line 172 of file main.cpp.

References cpsphere::current, display01(), drawspheres01(), delaunay3D::eval(), init(), keyboard(), commandline::mapvar(), gobjContainer::push(), r, delaunay3D::tet, cpsphere::update(), and xGraphics.

00173 {
00174   cout << "Denaulay Triangulation in 3D" << endl;
00175   cout << endl;
00176   cout << "Keyboard commands:" << endl;
00177   cout << "'a'  - iterate forwards through the tetrahedron mesh." << endl;
00178   cout << "'A'  - iterate backwards throuth the tetrahedron mesh." << endl;
00179   cout << endl;
00180 
00181   commandline cmd(argc,argv);
00182 
00183   uint n=5;
00184   cmd.mapvar(n,"n");
00185 
00186   vector< point3<double> > v;
00187 
00188   random11<double> r;
00189   for (uint i=0; i<n; ++i)
00190     v.push_back( point3<double>(r(),r(),r()) );
00191   
00192   delaunay3D tess(v);
00193   tess.eval();
00194 
00195 /*
00196   for (uint i=0; i<tess.tet.size(); ++i)
00197     cout << tess.tet[i] << endl;
00198 */
00199 
00200 
00201 
00202 
00203   xGraphics.push( new gobjglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) );
00204   //xGraphics.push( new gobjglClearColor(0.0,0.0,0.0,0.0) ); 
00205 
00206   pcpsphere = new cpsphere(v,tess.tet);
00207   xGraphics.push( pcpsphere->current );
00208   pcpsphere->update();
00209 
00210 
00211   xGraphics.push( new gobjglPushAttrib(GL_LIGHTING_BIT) );
00212   xGraphics.push( new gobjglPushAttrib(GL_CURRENT_BIT) );
00213   xGraphics.push( new gobjglDisable(GL_LIGHTING) );
00214   xGraphics.push( new gobjglColor3ub(0,255,255) );
00215 
00216   pointsdisplay3D< point3<double> > ptdisp(xGraphics,v);
00217 
00218   //xGraphics.push( new gobjglEnable(GL_LIGHTING) );
00219 
00220   drawspheres01(v,tess.tet);
00221 
00222   xGraphics.push( new gobjglPopAttrib() );
00223   xGraphics.push( new gobjglPopAttrib() );
00224 
00225 
00226   glutInit(&argc, argv);
00227   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
00228 
00229   glutInitWindowSize(600,600);
00230   glutCreateWindow("");  
00231   init();
00232   glutDisplayFunc(display01);
00233   glutKeyboardFunc(keyboard);
00234 
00235   //zprInit();
00236   //OpenGLinitialisation();
00237   //
00238 
00239 /*
00240   glDisable(GL_DEPTH_TEST);
00241   glEnable(GL_BLEND);
00242   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00243 */
00244 
00245   zpr zz;
00246   glutMainLoop();
00247 }

void test03 ( int  argc,
char **  argv 
)

Definition at line 264 of file main.cpp.

References cpsphere::current, display02(), delaunay3D::eval(), init(), keyboard(), commandline::mapvar(), gobjContainer::push(), r, delaunay3D::tet, cpsphere::update(), and xGraphics.

00265 {
00266   cout << "Denaulay Triangulation in 3D" << endl;
00267   cout << endl;
00268   cout << "Keyboard commands:" << endl;
00269   cout << "'a'  - iterate forwards through the tetrahedron mesh." << endl;
00270   cout << "'A'  - iterate backwards throuth the tetrahedron mesh." << endl;
00271   cout << endl;
00272 
00273   commandline cmd(argc,argv);
00274 
00275   uint n=5;
00276   cmd.mapvar(n,"n");
00277 
00278   vector< point3<double> > v;
00279 
00280   random11<double> r;
00281   for (uint i=0; i<n; ++i)
00282     v.push_back( point3<double>(r(),r(),r()) );
00283   
00284   delaunay3D tess(v);
00285   tess.eval();
00286 
00287   xGraphics.push( new gobjglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) );
00288   //xGraphics.push( new gobjglClearColor(0.0,0.0,0.0,0.0) ); 
00289 
00290   pcpsphere = new cpsphere(v,tess.tet);
00291   xGraphics.push( pcpsphere->current );
00292   pcpsphere->update();
00293 
00294 /*
00295 
00296   xGraphics.push( new gobjglPushAttrib(GL_LIGHTING_BIT) );
00297   xGraphics.push( new gobjglPushAttrib(GL_CURRENT_BIT) );
00298   xGraphics.push( new gobjglDisable(GL_LIGHTING) );
00299   xGraphics.push( new gobjglColor3ub(0,255,255) );
00300 
00301   pointsdisplay3D< point3<double> > ptdisp(xGraphics,v);
00302 
00303   xGraphics.push( new gobjglPopAttrib() );
00304   xGraphics.push( new gobjglPopAttrib() );
00305 */
00306 
00307 
00308   glutInit(&argc, argv);
00309   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00310 
00311   glutInitWindowSize(600,600);
00312   glutCreateWindow("");
00313   init();
00314   glutDisplayFunc(display02);
00315   glutKeyboardFunc(keyboard);
00316 
00317   zpr zz;
00318   glutMainLoop();
00319 }


Variable Documentation

Definition at line 24 of file main.cpp.


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