#include <gugr_contour.h>
Public Methods | |
template<class T> bool | init (int nP, const Ptr< point2< T > > &P, T minx, T miny, T scalei) |
template<> bool | init (int nP, const Ptr< point2< rational > > &P) |
Public Attributes | |
Ptr< point2< rational > > | verts |
int | nVerts |
Ptr< line > | lines |
|
Definition at line 98 of file gugr_contour.h. References lines, nVerts, and verts.
00099 { 00100 int i,j; 00101 00102 verts.reserve_pool(nP); 00103 lines.reserve_pool(nP); 00104 00105 verts[0] = P[0]; 00106 j = 0; 00107 i = 1; 00108 00109 for(;;) 00110 { 00111 while( (i < nP) && 00112 (compare(P[i].x,verts[j].x)==0) && 00113 (compare(P[i].y,verts[j].y)==0) ) 00114 i++; 00115 00116 if( i == nP ) break; 00117 00118 j++; 00119 verts[j] = P[i]; 00120 lines[j-1] = line( verts[j-1], verts[j] ); 00121 00122 } 00123 00124 nVerts = j+1; 00125 if( (compare(verts[nVerts-1].x,verts[0].x)==0) && 00126 (compare(verts[nVerts-1].y,verts[0].y)==0) ) 00127 nVerts--; 00128 00129 if( nVerts < 2 ) return false; 00130 00131 lines[nVerts-1] = line( verts[nVerts-1], verts[0] ); 00132 return true; 00133 } |
|
Definition at line 43 of file gugr_contour.h. References gugr::coord2int(), lines, nVerts, and verts.
00044 { 00045 T x,y; 00046 int i,j; 00047 rational vx,vy; 00048 unsigned long *cbuf = 00049 (unsigned long *)alloca(gul::rtr<T>::mantissa_length()); 00050 00051 verts.reserve_pool(nP); 00052 lines.reserve_pool(nP); 00053 00054 x = (P[0].x - minx)*scalei; 00055 y = (P[0].y - miny)*scalei; 00056 verts[0].x = rational(coord2int(x,cbuf),cbuf); 00057 verts[0].y = rational(coord2int(y,cbuf),cbuf); 00058 j = 0; 00059 i = 1; 00060 00061 for( ;; ) 00062 { 00063 while( i < nP ) 00064 { 00065 x = (P[i].x - minx)*scalei; 00066 y = (P[i].y - miny)*scalei; 00067 vx = rational(coord2int(x,cbuf),cbuf); 00068 vy = rational(coord2int(y,cbuf),cbuf); 00069 00070 if( (compare(vx,verts[j].x)!=0) || 00071 (compare(vy,verts[j].y)!=0) ) 00072 break; 00073 00074 i++; 00075 } 00076 00077 if( i == nP ) break; 00078 00079 j++; 00080 00081 verts[j].x = vx; 00082 verts[j].y = vy; 00083 lines[j-1] = line( verts[j-1], verts[j] ); 00084 } 00085 00086 nVerts = j+1; 00087 if( (compare(verts[nVerts-1].x,verts[0].x)==0) && 00088 (compare(verts[nVerts-1].y,verts[0].y)==0) ) 00089 nVerts--; 00090 00091 if( nVerts < 2 ) return false; 00092 00093 lines[nVerts-1] = line( verts[nVerts-1], verts[0] ); 00094 return true; 00095 } |
|
Definition at line 40 of file gugr_contour.h. Referenced by init(). |
|
Definition at line 38 of file gugr_contour.h. Referenced by init(). |
|
Definition at line 37 of file gugr_contour.h. Referenced by init(). |