proj home

Files   Classes   Functions   Hierarchy  

bsptreeD2disp01.h

Go to the documentation of this file.
00001 #ifndef BSPTREED2DISP01_H
00002 #define BSPTREED2DISP01_H
00003 
00004 #include <bsptreeD2.h>
00005 #include <gobj.h>
00006 #include <treeindexedD2iter.h>
00007 
00008 
00012 template< typename PT, typename PD, typename INDX >
00013 class bsptreeD2disp01 : public gobjContainer
00014 {
00015 public:
00016 
00018   bsptreeD2<PT,PD,INDX> & bsp;
00019 
00021   PD tmin;
00023   PD tmax;
00024   
00026   bsptreeD2disp01
00027   ( 
00028     bsptreeD2<PT,PD,INDX> & bsp_,
00029     PD const tmin_,
00030     PD const tmax_
00031   )
00032     : gobjContainer(true), bsp(bsp_), tmin(tmin_), 
00033       tmax(tmax_) {}
00034 
00036   void update();
00037 
00038 
00039 };
00040 
00041 //---------------------------------------------------------
00042 //  Implementation
00043 
00044 template< typename PT, typename PD, typename INDX >
00045 void bsptreeD2disp01<PT,PD,INDX>::update()
00046 {
00047   nuke();
00048 
00049   push(new gobjglColor3f(0.5,0.5,0.5));
00050   push(new gobjglBegin(GL_LINES));
00051 
00052   PT La;
00053   PT Lm;
00054 
00055   PD t0;
00056   PD t1;
00057 
00058   uint index;
00059   uint index2;
00060 
00061   for ( treeindexedD2iterinternal<INDX> i1(bsp.tree); 
00062     !i1; ++i1 )
00063   {
00064     halfspaceD2<PT,PD> & h1(bsp.vi[i1()->index]);
00065 
00066     Lm = h1.p1-h1.p0;
00067     La = h1.p0;
00068 
00069     t0 = tmin;
00070     t1 = tmax;
00071 
00072     uint sz = i1.path.size();
00073     if (sz<=1)
00074     {
00075       if (sz==0)
00076         continue;
00077 
00078       push(new gobjglVertex3d(La+Lm*t0));
00079       push(new gobjglVertex3d(La+Lm*t1));
00080       
00081       continue;
00082     }
00083 
00084     --sz;
00085     for (uint i=0; i<sz; ++i)
00086     {
00087       //cout << SHOW(i1.path[i]->index) << endl;
00088       index = i1.path[i]->index;
00089       index2 = i1.path[i+1]->index;
00090 
00091       if ( i1.path[i]->isleftinternal(index2) )
00092         bsp.vi[index].clip(t0,t1,La,Lm);
00093       else
00094       {
00095         if ( i1.path[i]->isrightinternal(index2) )
00096         {
00097           bsp.vi[index].clipNeg(t0,t1,La,Lm);
00098         }
00099         else
00100           assert(false);
00101       }
00102     }
00103 
00104     push(new gobjglVertex3d(La+Lm*t0));
00105     push(new gobjglVertex3d(La+Lm*t1));
00106   }
00107 
00108   push(new gobjglEnd());
00109 }
00110 
00111 
00112 #endif
00113 
00114 

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