Files Classes Functions Hierarchy
00001 #ifndef POLYTOPED2TESSDISP01_H 00002 #define POLYTOPED2TESSDISP01_H 00003 00004 #include <pointsdisplay.h> 00005 #include <graphmisc.h> 00006 #include <gobj.h> 00007 #include <point.h> 00008 #include <random.h> 00009 #include <typedefs.h> 00010 00011 template< typename VPTS, typename VPOLY > 00012 class polytopeD2tessdisp01 00013 { 00014 public: 00015 00017 VPTS const & pts; 00019 VPOLY const & vi; 00020 00022 polytopeD2tessdisp01 00023 ( 00024 VPTS const & pts_, 00025 VPOLY const & vi_ 00026 ) 00027 : pts(pts_), vi(vi_) {} 00028 00029 bool lines; 00030 bool multicolored; 00031 bool labelpoints; 00032 bool labelpolytopes; 00033 00035 void eval( gobjContainer & gr ); 00036 00037 vector< point3<float> > multicoloredvec; 00038 vector< point2<float> > vicenter; 00039 }; 00040 00041 00042 //--------------------------------------------------------- 00043 // Implementation 00044 00045 template< typename VPTS, typename VPOLY > 00046 void polytopeD2tessdisp01<VPTS,VPOLY>::eval 00047 ( 00048 gobjContainer & gr 00049 ) 00050 { 00051 random11<double> r; 00052 00053 /* 00054 if (labelpoints) 00055 { 00056 00057 } 00058 */ 00059 uintc imax = vi.size(); 00060 assert(imax>1); 00061 00062 if (multicolored) 00063 { 00064 // Dummy to start index at 1. 00065 multicoloredvec.push_back( point3<float>() ); 00066 for (uint i=1; i<imax; ++i) 00067 { 00068 if (vi[i].isnull()) 00069 { 00070 multicoloredvec.push_back( point3<float>() ); 00071 continue; 00072 } 00073 00074 multicoloredvec.push_back( point3<float>(r(),r(),r()) ); 00075 } 00076 } 00077 00078 if (lines) 00079 { 00080 gr.push( new gobjglEnable(GL_LINE_STIPPLE) ); 00081 gr.push( new gobjglLineStipple(1,0x1C47) ); 00082 00083 uint kmax; 00084 gr.push( new gobjglBegin(GL_LINES) ); 00085 for (uint i=1; i<imax; ++i) 00086 { 00087 if (vi[i].isnull()) 00088 continue; 00089 00090 //gr.push_back( new gobjglLineStipple(1,(GLushort)rand()) ); 00091 00092 if (multicolored) 00093 gr.push( new gobjglColor3f( 00094 multicoloredvec[i].x,multicoloredvec[i].y,multicoloredvec[i].z) ); 00095 00096 kmax = vi[i].pi.size(); 00097 for (uint k=0; k<kmax; ++k) 00098 { 00099 gr.push( new gobjglVertex2f(pts[ vi[i].pi[k]]) ); 00100 gr.push( new gobjglVertex2f(pts[ vi[i].pi[(k+1)%kmax]]) ); 00101 } 00102 } 00103 00104 gr.push( new gobjglEnd() ); 00105 00106 gr.push(new gobjglDisable(GL_LINE_STIPPLE)); 00107 } 00108 00109 if (labelpolytopes) 00110 { 00111 uint kmax; 00112 vicenter.push_back( point2<float>() ); 00113 for (uint i=1; i<imax; ++i) 00114 { 00115 if (vi[i].isnull()) 00116 { 00117 vicenter.push_back( point2<float>() ); 00118 continue; 00119 } 00120 00121 kmax = vi[i].pi.size(); 00122 assert(kmax!=0); 00123 00124 point2<float> c(0.0,0.0); 00125 for (uint k=0; k<kmax; ++k) 00126 { 00127 c.x += pts[vi[i].pi[k]].x; 00128 c.y += pts[vi[i].pi[k]].y; 00129 } 00130 00131 c.x /= (double)kmax; 00132 c.y /= (double)kmax; 00133 00134 vicenter.push_back(c); 00135 } 00136 00137 gr.push(new gobjglColor3f(1.0,0.0,0.0)); 00138 00139 pointsdisplay2D< point2<float> > * dp = 00140 new pointsdisplay2D< point2<float> >(gr,vicenter,false,true); 00141 gr.push(dp); 00142 } 00143 00144 if (labelpoints) 00145 { 00146 gr.push(new gobjglColor3f(0.0,1.0,0.0)); 00147 gr.push( new pointsdisplay2D< point2<double> >(gr,pts,false,true)); 00148 } 00149 00150 } 00151 00152 00153 #endif 00154 00155
1.5.8