proj home

Files   Classes   Functions   Hierarchy  

d3marchdisp.cpp

Go to the documentation of this file.
00001 
00002 #include <GL/glut.h>
00003 #include <GL/gl.h>
00004 
00005 #include <d3marchdisp.h>
00006 
00007 typedef point2<double> pt2;
00008 
00009 pt3c d3marchdisp::interpolate(pt3c & A, pt3c & B) const
00010 { 
00011   double const t = (cvalue-A.z)/(B.z-A.z); 
00012   pt3 X(B-A); 
00013   X*=t; 
00014   X+=A; 
00015   return X; 
00016 }
00017 
00018 void d3marchdisp::drawline( pt3c & A, pt3c & B ) const 
00019 {
00020   glBegin(GL_LINES);
00021 
00022     glVertex2f(A.x,A.y);
00023     glVertex2f(B.x,B.y);
00024 
00025   glEnd();  
00026 }
00027 
00028 
00029 void d3marchdisp::eval( pt3c & P0, pt3c & P1, pt3c & P2 ) const
00030 {
00031   unsigned int res(0);
00032 
00033   if (P0.z<cvalue)
00034     res += 1;
00035   if (P1.z<cvalue)
00036     res += 2;
00037   if (P2.z<cvalue)
00038     res += 4;
00039 
00040   if (res==0)
00041     return;
00042 
00043   if (res==7)
00044     return;
00045 
00046   switch(res)
00047   {
00048     case 1: case 6:
00049       drawline( interpolate(P0,P1), interpolate(P0,P2) );
00050       break;
00051 
00052     case 2: case 5:
00053       drawline( interpolate(P1,P0), interpolate(P1,P2) );
00054       break;
00055 
00056     case 4: case 3:
00057       drawline( interpolate(P2,P0), interpolate(P2,P1) );
00058       break;
00059 
00060   }
00061 
00062 }
00063 

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