Files Classes Functions Hierarchy
#include <d3tessdraw.h>
Public Member Functions | |
| writevoronoidiagramobj (d3tess &tess_) | |
| void | draw () |
| Draw the object. | |
Definition at line 201 of file d3tessdraw.h.
| writevoronoidiagramobj::writevoronoidiagramobj | ( | d3tess & | tess_ | ) | [inline] |
| void writevoronoidiagramobj::draw | ( | ) | [virtual] |
Draw the object.
Implements gobj.
Definition at line 351 of file d3tessdraw.cpp.
References virtualtriangle::clockwise(), d3tess::cp, gobj::global, d3tess::pt, gobjContainer::push(), virtualtriangle::set(), d3tess::vi, and d3tess::vs.
00352 { 00353 00354 // Construct a one to one mapping between a point 00355 // and one of its bordering simplices. 00356 00357 vector<pt3> const & pt(tess.pt); 00358 uint psz = pt.size(); 00359 uint * fp = new unsigned int[psz]; 00360 for (uint i=0; i<psz; ++i) 00361 fp[i] = 0; 00362 00363 vector<simplexD2linked> const & vi(tess.vi); 00364 uint vsz = tess.vi.size(); 00365 00366 uint k; 00367 uint p1; 00368 for (uint i=1; i<vsz; ++i) 00369 { 00370 if (vi[i].isnull()) 00371 continue; 00372 00373 for (k=0; k<3; ++k) 00374 { 00375 p1 = vi[i].pi[k]; 00376 if (fp[p1]!=0) 00377 continue; 00378 00379 fp[p1] = i; 00380 } 00381 } 00382 00383 d3tesspreserve preservecp(tess); 00384 00385 // Use the mapping to construct the voronoi regions by 00386 // rotating about the point. 00387 00388 gobjContainer & x = * gobjContainer::global; 00389 00390 x.push( new gobjglPushAttrib(GL_CURRENT_BIT) ); 00391 x.push( new gobjglPushAttrib(GL_LIGHTING_BIT) ); 00392 00393 x.push( new gobjglDisable(GL_LIGHTING) ); 00394 00395 x.push( new gobjglColor3f(0.0,1.0,0.0) ); 00396 00397 x.push( new gobjglEnable(GL_LINE_STIPPLE) ); 00398 00399 x.push( new gobjglLineStipple(1,0x00FF) ); 00400 00401 x.push( new gobjglBegin(GL_LINES) ); 00402 00403 // Draw voronoi polygons. 00404 for (uint i=1; i<psz; ++i) 00405 { 00406 if (fp[i]==0) 00407 { 00408 cout << "error: point " << i << " has no triangle" << endl; 00409 continue; 00410 } 00411 00412 // Let the point i be in the bottom right hand corner of 00413 // vs's orientation. 00414 tess.cp = fp[i]; 00415 tess.vs.set( vi[ fp[i] ].piInverse(i)); 00416 tess.vs.clockwise(); 00417 onevertex(); 00418 } 00419 00420 x.push( new gobjglEnd() ); 00421 00422 x.push( new gobjglDisable(GL_LINE_STIPPLE) ); 00423 00424 x.push( new gobjglPopAttrib() ); 00425 x.push( new gobjglPopAttrib() ); 00426 00427 delete[] fp; 00428 }
1.5.8