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