Files Classes Functions Hierarchy
00001 #ifndef REGIOND2TESSDISPLAY_H 00002 #define REGIOND2TESSDISPLAY_H 00003 00004 #include <pointsdisplay.h> 00005 #include <gobj.h> 00006 #include <pnlink.h> 00007 #include <random.h> 00008 #include <typedefs.h> 00009 00010 00014 template< typename TS, typename Indx > 00015 class regionD2tessdisplaymesh : public gobj 00016 { 00017 public: 00018 00020 gobjContainer & gr; 00022 TS & tess; 00023 00025 bool multicolored; 00026 00028 regionD2tessdisplaymesh 00029 ( 00030 gobjContainer & gr_, 00031 TS & tess_, 00032 boolc _multicolored=true 00033 ) 00034 : gr(gr_), tess(tess_), multicolored(_multicolored) {} 00035 00037 void draw(); 00038 }; 00039 00040 00044 template< typename TS, typename Indx > 00045 class regionD2tessdisplaypoints : public gobj 00046 { 00047 public: 00048 00050 gobjContainer & gr; 00052 TS & tess; 00053 00055 point3<float> pointcolor; 00057 point3<float> regioncolor; 00058 00060 bool displaypoints; 00061 00063 bool displayregions; 00064 00066 regionD2tessdisplaypoints 00067 ( 00068 gobjContainer & gr_, 00069 TS & tess_ 00070 ); 00071 00073 void draw(); 00074 }; 00075 00076 00077 //--------------------------------------------------------- 00078 // Implementation 00079 00080 template< typename TS, typename Indx > 00081 regionD2tessdisplaypoints<TS,Indx>::regionD2tessdisplaypoints 00082 ( 00083 gobjContainer & gr_, 00084 TS & tess_ 00085 ) 00086 : gr(gr_), tess(tess_) 00087 { 00088 pointcolor=point3<float>(0.0,1.0,0.0); 00089 regioncolor=point3<float>(1.0,0.0,0.0); 00090 displaypoints=true; 00091 displayregions=true; 00092 } 00093 00094 template< typename TS, typename Indx > 00095 void regionD2tessdisplaypoints<TS,Indx>::draw() 00096 { 00097 if (displaypoints) 00098 { 00099 gr.push( new gobjglColor3f(pointcolor) ); 00100 gr.push( new pointsdisplay2D< point2<double> >(gr,tess.pts,false,true)); 00101 } 00102 00103 if (displayregions) 00104 { 00105 vector< point2<float> > vicenter; 00106 for (Indx i=0; i<tess.vi.size(); ++i) 00107 { 00108 if (tess.vi[i].isnull()) 00109 { 00110 vicenter.push_back( point2<float>() ); 00111 continue; 00112 } 00113 00114 uint count=0; 00115 point2<float> c(0.0,0.0); 00116 pnlinkiter<Indx> iter(tess.vi[i].start); 00117 iter.reset(); 00118 do 00119 { 00120 c.x += tess.pts[iter->plink].x; 00121 c.y += tess.pts[iter->plink].y; 00122 ++count; 00123 ++iter; 00124 } while (!iter); 00125 00126 assert(count!=0); 00127 c /= (double)count; 00128 vicenter.push_back(c); 00129 } 00130 00131 gr.push( new gobjglColor3f(regioncolor) ); 00132 gr.push( new pointsdisplay2D< point2<float> >(gr,vicenter,false,true)); 00133 } 00134 } 00135 00136 template< typename TS, typename Indx > 00137 void regionD2tessdisplaymesh<TS,Indx>::draw() 00138 { 00139 //cout << "regionD2tessdisplaymesh<TS,Indx>::draw()" << endl; 00140 gr.push( new gobjglEnable(GL_LINE_STIPPLE) ); 00141 gr.push( new gobjglLineStipple(1,0x1C47) ); 00142 00143 gr.push( new gobjglBegin(GL_LINES) ); 00144 00145 Indx imax = tess.vi.size(); 00146 for (Indx i=0; i<imax; ++i) 00147 { 00148 if ( tess.vi[i].isnull()) 00149 continue; 00150 00151 //cout << SHOW(i) << endl; 00152 00153 if (multicolored) 00154 { 00155 random11<double> r; 00156 gr.push(new gobjglColor3f(r(),r(),r())); 00157 } 00158 00159 pnlinkiterconst<Indx> k(tess.vi[i].start); 00160 k.reset(); 00161 do 00162 { 00163 //cout << SHOW(k->plink) << " " << SHOW(k->next->plink) << endl; 00164 gr.push( new gobjglVertex2f(tess.pts[k->plink]) ); 00165 gr.push( new gobjglVertex2f(tess.pts[k->next->plink]) ); 00166 ++k; 00167 } while (!k); 00168 } 00169 00170 gr.push( new gobjglEnd() ); 00171 gr.push(new gobjglDisable(GL_LINE_STIPPLE)); 00172 } 00173 00174 00175 00176 00177 #endif 00178 00179
1.5.8