proj home

Files   Classes   Functions   Hierarchy  

tessD2disp01.h

Go to the documentation of this file.
00001 #ifndef TESSD2DISP01_H
00002 #define TESSD2DISP01_H
00003 
00004 #include <simplexD2indexed.h>
00005 #include <graphmisc.h>
00006 #include <gobj.h>
00007 #include <point.h>
00008 #include <random.h>
00009 #include <triangle.h>
00010 #include <typedefs.h>
00011 
00017 template< typename PT >
00018 class tessD2disp01
00019 {
00020   typedef point2<double> pt2;
00021 
00023   void get
00024   ( 
00025     triangle<pt2,double> & t,
00026     simplexD2indexed<> const & s
00027   ) const;
00028 public:
00029 
00031   bool multicolored;
00033   bool circles;
00034 
00036   PT const * pts;
00037 
00039   tessD2disp01(PT const * _pts)
00040     : multicolored(true), circles(false), pts(_pts)
00041     { assert(pts!=0); }
00042 
00044   void eval
00045   (
00046     gobjContainer & gr, 
00047     simplexD2indexed<> const * beg,
00048     simplexD2indexed<> const * end
00049   ) const; 
00050 
00051 };
00052 
00053 
00054 //---------------------------------------------------------
00055 // Implementation
00056 
00057 template< typename PT >
00058 void tessD2disp01<PT>::get
00059 ( 
00060   triangle<pt2,double> & t,
00061   simplexD2indexed<> const & s
00062 ) const
00063 {
00064   t.constructUnordered( pts[s.pi[0]], pts[s.pi[1]], pts[s.pi[2]] );
00065 }
00066 
00067 
00068 template< typename PT >
00069 void tessD2disp01<PT>::eval
00070 (
00071   gobjContainer & gr, 
00072   simplexD2indexed<> const * beg,
00073   simplexD2indexed<> const * end
00074 ) const
00075 {
00076   //typedef point2<double> pt2;
00077   typedef point3<double> pt3;
00078 
00079   assert(beg!=0);
00080   assert(end!=0);
00081 
00082   gr.push( new gobjglDisable(GL_LIGHTING) );
00083 
00084 //  pt2 a, b, c;
00085 
00086   random11<double> r;
00087 
00088   if (multicolored==false)
00089   {
00090     gr.push( new gobjglColor4f(0.0,0.0,1.0,0.5 ) );
00091   }
00092 
00093   gobjMyCircle * cir = new gobjMyCircle();
00094   gr.push(cir);
00095   pt2 p0;
00096   double radius;
00097 
00098   triangle<pt2,double> t;
00099 
00100   for (simplexD2indexed<> const * i = beg; i!=end; ++i)
00101   {
00102     if (i->isnull())
00103       continue;
00104 
00105     if (multicolored)
00106       gr.push( new gobjglColor4f(r(),r(),r(),0.5) );
00107 
00108     get(t,*i);
00109     //get(a,b,c,*i);
00110 
00111 
00112     //t.constructUnordered( pts[t.pi[0]], pts[t.pi[1]], pts[t.pi[2]] ); 
00113 
00114 
00115 
00116 
00117     gr.push( new gobjglBegin(GL_TRIANGLES) );
00118     gr.push( new gobjglVertex2f(t.pi[0]) ); 
00119     gr.push( new gobjglVertex2f(t.pi[1]) ); 
00120     gr.push( new gobjglVertex2f(t.pi[2]) ); 
00121     gr.push( new gobjglEnd() );
00122 
00123     if (circles==true)
00124     {
00125 /*
00126       simplexD2indexed<> ti(x.vT[i]);
00127       a.x = x.X[ti.pi[0]].x;
00128       a.y = x.X[ti.pi[0]].y;
00129       b.x = x.X[ti.pi[1]].x;
00130       b.y = x.X[ti.pi[1]].y;
00131       c.x = x.X[ti.pi[2]].x;
00132       c.y = x.X[ti.pi[2]].y;
00133 */
00134 //    triangle<pt2,double> t(a,b,c);
00135 //      triangle<pt2,double> t;
00136 //      t.constructUnordered(a,b,c);
00137       t.outercircle(radius,p0);
00138 
00139       gr.push( 
00140         new gobjMyCircleDraw(radius, pt3(p0), *cir) );
00141     }
00142   }
00143 }
00144 
00145 
00146 
00147 #endif
00148 
00149 

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