Files Classes Functions Hierarchy
00001 #ifndef BSPTREED2DISP03_H 00002 #define BSPTREED2DISP03_H 00003 00004 #include <sstream> 00005 using namespace std; 00006 00007 #include <bsptreeD2.h> 00008 #include <gobj.h> 00009 #include <graphmisc.h> 00010 #include <pointsdisplay.h> 00011 #include <treeindexedD2iter.h> 00012 00013 00022 template< typename PT, typename PD, typename INDX > 00023 class bsptreeD2disp03 : public gobjContainer 00024 { 00025 public: 00026 00028 bsptreeD2<PT,PD,INDX> & bsp; 00029 00031 double radius; 00032 00034 bsptreeD2disp03 00035 ( 00036 bsptreeD2<PT,PD,INDX> & bsp_, 00037 doublec radius_=0.05 00038 ) 00039 : gobjContainer(true), bsp(bsp_), radius(radius_) {} 00040 00042 void update(); 00043 00044 }; 00045 00046 //--------------------------------------------------------- 00047 // Implementation 00048 00049 template< typename PT, typename PD, typename INDX > 00050 void bsptreeD2disp03<PT,PD,INDX>::update() 00051 { 00052 nuke(); 00053 00054 if ( bsp.empty() ) 00055 return; 00056 00057 PT La; 00058 PT Lm; 00059 PT Lb; 00060 00061 PT Lmid; 00062 vector<string> ptlabels; 00063 vector<PT> ptlist; 00064 00065 PD t0; 00066 PD t1; 00067 00068 gobjQuadric * q2 = new gobjQuadric(); 00069 q2->radius = radius; 00070 q2->slices=30; 00071 q2->loops=7; 00072 00073 push(q2); 00074 00075 push(new gobjglPushAttrib(GL_LIGHTING)); 00076 push(new gobjglPushAttrib(GL_CURRENT_BIT)); 00077 00078 for ( treeindexedD2iterinternal<INDX> i1(bsp.tree); 00079 !i1; ++i1 ) 00080 { 00081 halfspaceD2<PT,PD> & h1(bsp.vi[i1()->index]); 00082 00083 Lm = h1.p1-h1.p0; 00084 La = h1.p0; 00085 Lb = h1.p1; 00086 00087 //t0 = tmin; 00088 //t1 = tmax; 00089 t0 = bsp.tmin; 00090 t1 = bsp.tmax; 00091 00092 Lmid = (La+Lb)*0.5; 00093 ptlist.push_back(Lmid); 00094 { 00095 stringstream ss; 00096 INDX idx = i1()->index; 00097 ss << idx; 00098 ptlabels.push_back(ss.str()); 00099 } 00100 00101 uint sz = i1.path.size(); 00102 if (sz<=1) 00103 { 00104 if (sz==0) 00105 continue; 00106 00107 push(new gobjglDisable(GL_LIGHTING)); 00108 push(new gobjglBegin(GL_LINES)); 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 push(new gobjglEnd()); 00114 00115 push(new gobjglEnable(GL_LIGHTING)); 00116 push(new gobjglColor3f(0.0,0.0,1.0)); 00117 push(new gobjMySphereDraw(La,q2)); 00118 push(new gobjglColor3f(1.0,0.0,0.0)); 00119 push(new gobjMySphereDraw(Lb,q2)); 00120 00121 continue; 00122 } 00123 00124 bsp.clip(t0,t1,La,Lm,i1); 00125 00126 push(new gobjglDisable(GL_LIGHTING)); 00127 push(new gobjglBegin(GL_LINES)); 00128 push(new gobjglColor3f(0.0,0.0,1.0)); 00129 push(new gobjglVertex3d(La+Lm*t0)); 00130 push(new gobjglColor3f(1.0,0.0,0.0)); 00131 push(new gobjglVertex3d(La+Lm*t1)); 00132 push(new gobjglEnd()); 00133 00134 push(new gobjglEnable(GL_LIGHTING)); 00135 push(new gobjglColor3f(0.0,0.0,1.0)); 00136 push(new gobjMySphereDraw(La,q2)); 00137 push(new gobjglColor3f(1.0,0.0,0.0)); 00138 push(new gobjMySphereDraw(Lb,q2)); 00139 } 00140 00141 push(new gobjglDisable(GL_LIGHTING)); 00142 push(new gobjglColor3f(1.0,1.0,0.0)); 00143 pointsdisplay2D< PT > pd( *this, ptlist, ptlabels ); 00144 00145 push(new gobjglPopAttrib()); 00146 push(new gobjglPopAttrib()); 00147 } 00148 00149 00150 #endif 00151 00152
1.5.8