Files Classes Functions Hierarchy
#include <polytrimon.h>
Public Member Functions | |
| polytrimon (vector< point2< float > > const &pts_) | |
| Pass in the points of monotone polygon ordered clockwise from the highest point. | |
| template<typename T > | |
| void | tessellate (T f) |
| void | vsprint () const |
| void | colorsprint () const |
| void | vyprint () const |
Public Attributes | |
| vector< point2< float > > const & | pts |
| Polyline of 2D points. | |
| vector< uint > | colors |
| Each point is either on the rhs (black)=1, the left hand side (white)=2 or both=1+2=3 eg the start and finish points. | |
| vector< uint > | vy |
| pts[] ordered on the y-axis in constructor. | |
| deque< uint > | vs |
| The current tessellation state. | |
Assume that the order of the points is clockwise starting from the top.
Definition at line 20 of file polytrimon.h.
| polytrimon::polytrimon | ( | vector< point2< float > > const & | pts_ | ) |
Pass in the points of monotone polygon ordered clockwise from the highest point.
Definition at line 83 of file polytrimon.cpp.
References pts.
00086 : pts(pts_) 00087 { 00088 assert(pts.size()>2); 00089 00090 colorsinit(); 00091 00092 vyinit(); 00093 }
| void polytrimon::colorsprint | ( | ) | const |
| void polytrimon::tessellate | ( | T | f | ) | [inline] |
Definition at line 64 of file polytrimon.h.
References colors, vs, and vy.
Referenced by test01(), and test02().
00065 { 00066 vs.push_front( vy[0] ); 00067 vs.push_front( vy[1] ); 00068 00069 uint imax= vy.size(); 00070 00071 // The first two points from the current vs state. 00072 uint z0; 00073 uint z1; 00074 00075 for (uint i=2; i<imax; ++i) 00076 { 00077 vs.push_front( vy[i] ); 00078 //vsprint(); 00079 00080 z0 = vs[0]; 00081 z1 = vs[1]; 00082 00083 bool samecolor = 00084 (( colors[ z0 ] & colors[ z1 ])!=0); 00085 00086 if (samecolor==false) 00087 { 00088 // Triangle fan about z0. 00089 for (uint k=2; k<vs.size(); ++k) 00090 f(z0,vs[k-1],vs[k]); 00091 00092 vs.clear(); 00093 vs.push_front(z1); 00094 vs.push_front(z0); 00095 } 00096 else 00097 { 00098 for ( ; ispointvisible(); ) 00099 { 00100 z0 = vs[0]; 00101 z1 = vs[1]; 00102 00103 f(z0,z1,vs[2]); 00104 00105 vs.pop_front(); 00106 vs.pop_front(); 00107 vs.push_front(z0); 00108 } 00109 } 00110 } 00111 }
| void polytrimon::vsprint | ( | ) | const |
| void polytrimon::vyprint | ( | ) | const |
| vector< uint > polytrimon::colors |
Each point is either on the rhs (black)=1, the left hand side (white)=2 or both=1+2=3 eg the start and finish points.
Definition at line 38 of file polytrimon.h.
Referenced by colorsprint(), and tessellate().
| vector< point2<float> > const& polytrimon::pts |
| deque<uint> polytrimon::vs |
The current tessellation state.
Definition at line 48 of file polytrimon.h.
Referenced by tessellate(), and vsprint().
| vector< uint > polytrimon::vy |
pts[] ordered on the y-axis in constructor.
Definition at line 41 of file polytrimon.h.
Referenced by tessellate(), and vyprint().
1.5.8