GMould Class Reference

#include <gmould.h>

Inheritance diagram for GMould:

CCObject SimpleCCObject GEnvelope GEnvelope2x2 GPerspective List of all members.

Public Member Functions

 GMould ()
BOOL Define (POINT *P, RECT *pBBox, DWORD pTolerance=0)
virtual void CopyShape (POINT *P)=0
virtual BOOL Redefine (POINT *P)=0
virtual BOOL FitPath (CONST POINT *IPoints, CONST BYTE *ITypes, DWORD ILength, LPPOINT OPoints, LPBYTE OTypes, DWORD OLength, BOOL Close=FALSE)=0
void FitPoint (POINT a, POINT &b)
void FitPoint (DPOINT a, POINT &b)
DocRect GetBoundingRect ()
RECT GetSourceBBox () const

Protected Member Functions

double CalcTolerance (DWORD pTolerance)
BOOL GenOp (BYTE Op, DPOINT T)
BOOL GenMove (DPOINT T)
BOOL GenLine (DPOINT T)
void ScaleSrc (POINT a, DPOINT &b)
void Scale (POINT a, DPOINT &b)
void InverseScale (DPOINT a, POINT &b)
BOOL GenCurve (DPOINT C2, DPOINT C4, DPOINT P0, DPOINT P2, DPOINT P4, DPOINT P6, DPOINT T0, DPOINT T2, DPOINT T4, DPOINT T6)
virtual void ScaleView ()=0
virtual void CalcViewBBox ()=0
virtual void CalcViewConsts ()=0
virtual void Transform (DPOINT a, DPOINT &b)=0

Protected Attributes

RECT SrcBBox
INT32 MinX
INT32 MaxX
INT32 MinY
INT32 MaxY
INT32 Width
INT32 Depth
double Tolerance
LPPOINT OPoints
LPBYTE OTypes
DWORD OLength

Detailed Description

Definition at line 169 of file gmould.h.


Constructor & Destructor Documentation

GMould::GMould  ) 
 

Definition at line 111 of file gmould.cpp.

00112 {
00113     SrcBBox.left   = 0;
00114     SrcBBox.top    = 1;
00115     SrcBBox.right  = 1;
00116     SrcBBox.bottom = 0;
00117 
00118     MinX = MinY = 0;
00119     MaxX = MaxY = 1;
00120     Width = Depth = 1;
00121 
00122     Tolerance = 0.0;    
00123 }


Member Function Documentation

double GMould::CalcTolerance DWORD  pTolerance  )  [protected]
 

Definition at line 154 of file gmould.cpp.

00155 {
00156 //  INT32 x, y ;
00157 //  x = (INT32)( ((float)Tolerance*0x10000000)/Width  ) ;
00158 //  y = (INT32)( ((float)Tolerance*0x10000000)/Depth ) ;
00159     if ( pTolerance==0 )
00160         return 0.0 ;
00161 
00162     double x, y ;
00163 
00164     x = (double) pTolerance/Width ;
00165     y = (double) pTolerance/Depth ;
00166 
00167     return 16*(x+y+2*max(x,y)) ;
00168 }

virtual void GMould::CalcViewBBox  )  [protected, pure virtual]
 

Implemented in GEnvelope, GEnvelope2x2, and GPerspective.

virtual void GMould::CalcViewConsts  )  [protected, pure virtual]
 

Implemented in GEnvelope, GEnvelope2x2, and GPerspective.

virtual void GMould::CopyShape POINT P  )  [pure virtual]
 

Implemented in GEnvelope, GEnvelope2x2, and GPerspective.

BOOL GMould::Define POINT P,
RECT pBBox,
DWORD  pTolerance = 0
 

Definition at line 126 of file gmould.cpp.

00127 {
00128     SrcBBox.left    = pBBox->left ;
00129     SrcBBox.top     = pBBox->top ;
00130     SrcBBox.right   = pBBox->right ;
00131     SrcBBox.bottom  = pBBox->bottom ;
00132 
00133     if (!Redefine( P ))
00134         return FALSE;
00135 
00136     Tolerance = CalcTolerance( pTolerance ) ;
00137 
00138     return TRUE;
00139 }

virtual BOOL GMould::FitPath CONST POINT IPoints,
CONST BYTE *  ITypes,
DWORD  ILength,
LPPOINT  OPoints,
LPBYTE  OTypes,
DWORD  OLength,
BOOL  Close = FALSE
[pure virtual]
 

Implemented in GEnvelope, GEnvelope2x2, and GPerspective.

void GMould::FitPoint DPOINT  a,
POINT b
 

Definition at line 180 of file gmould.cpp.

00181 {
00182     DPOINT t ;
00183     Transform   ( a, t ) ;
00184     InverseScale( t, b ) ;
00185 }

void GMould::FitPoint POINT  a,
POINT b
 

Definition at line 172 of file gmould.cpp.

00173 {
00174     DPOINT t ;
00175     ScaleSrc    ( a, t ) ;
00176     Transform   ( t, t ) ;
00177     InverseScale( t, b ) ;
00178 }

BOOL GMould::GenCurve DPOINT  C2,
DPOINT  C4,
DPOINT  P0,
DPOINT  P2,
DPOINT  P4,
DPOINT  P6,
DPOINT  T0,
DPOINT  T2,
DPOINT  T4,
DPOINT  T6
[protected]
 

Definition at line 189 of file gmould.cpp.

00192 {
00193     if ( Tolerance > 0 )
00194     {
00195         double T ;
00196         DPOINT D ;
00197         DPOINT P1, P3, P5 ;
00198         DPOINT T1, T3, T5 ;
00199         DPOINT N1, N3, N5 ;
00200         P1.x = (125*P0.x+75*C2.x+15*C4.x +    P6.x)/216 ;
00201         P1.y = (125*P0.y+75*C2.y+15*C4.y +    P6.y)/216 ;
00202         P3.x = (    P0.x+3*(C2.x+   C4.x)+    P6.x)/8 ;
00203         P3.y = (    P0.y+3*(C2.y+   C4.y)+    P6.y)/8 ;
00204         P5.x = (    P0.x+15*C2.x+75*C4.x +125*P6.x)/216 ;
00205         P5.y = (    P0.y+15*C2.y+75*C4.y +125*P6.y)/216 ;
00206         Transform( P1, T1 ) ;
00207         Transform( P3, T3 ) ;
00208         Transform( P5, T5 ) ;
00209         N3.x = -T0.x+9*(T2.x+T4.x)-T6.x ;
00210         N3.y = -T0.y+9*(T2.y+T4.y)-T6.y ;
00211         D.x = fabs(16*T3.x-N3.x) ;
00212         D.y = fabs(16*T3.y-N3.y) ;
00213         T = D.x+D.y+2*max(D.x,D.y) ;
00214         if ( T<=Tolerance )
00215         {
00216             N1.x = 5*(T0.x-T4.x)+15*T2.x+T6.x ;
00217             N1.y = 5*(T0.y-T4.y)+15*T2.y+T6.y ;
00218             D.x = fabs(16*T1.x-N1.x) ;
00219             D.y = fabs(16*T1.y-N1.y) ;
00220             T = D.x+D.y+2*max(D.x,D.y) ;
00221             if ( T<=Tolerance )
00222             {
00223                 N5.x = T0.x+15*T4.x+5*(T6.x-T2.x) ;
00224                 N5.y = T0.y+15*T4.y+5*(T6.y-T2.y) ;
00225                 D.x = fabs(16*T5.x-N5.x) ;
00226                 D.y = fabs(16*T5.y-N5.y) ;
00227                 T = D.x+D.y+2*max(D.x,D.y) ;
00228             }
00229         }
00230         if ( T>Tolerance )
00231         {
00232             DPOINT CL1, CL2, CR1, CR2 ;
00233             CL1.x = (P0.x+C2.x)/2 ;
00234             CL1.y = (P0.y+C2.y)/2 ;
00235             CL2.x = (P0.x+2*C2.x+C4.x)/4 ;
00236             CL2.y = (P0.y+2*C2.y+C4.y)/4 ;
00237             CR1.x = (C2.x+2*C4.x+P6.x)/4 ;
00238             CR1.y = (C2.y+2*C4.y+P6.y)/4 ;
00239             CR2.x = (C4.x+P6.x)/2 ;
00240             CR2.y = (C4.y+P6.y)/2 ;
00241             return GenCurve( CL1, CL2, P0, P1, P2, P3, T0, T1, T2, T3 ) &&
00242                    GenCurve( CR1, CR2, P3, P4, P5, P6, T3, T4, T5, T6 ) ;
00243         }           
00244     }
00245     if ( OLength <= 3 ) return FALSE ;
00246     OLength -= 3 ;
00247     DPOINT N2, N4 ;
00248     N2.x = (-5*T0.x+18*T2.x- 9*T4.x+2*T6.x)/6 ;
00249     N2.y = (-5*T0.y+18*T2.y- 9*T4.y+2*T6.y)/6 ;
00250     N4.x = ( 2*T0.x- 9*T2.x+18*T4.x-5*T6.x)/6 ;
00251     N4.y = ( 2*T0.y- 9*T2.y+18*T4.y-5*T6.y)/6 ;
00252     InverseScale( N2, *OPoints++ ) ; *OTypes++ = PT_BEZIERTO ;
00253     InverseScale( N4, *OPoints++ ) ; *OTypes++ = PT_BEZIERTO ;
00254     InverseScale( T6, *OPoints++ ) ; *OTypes++ = PT_BEZIERTO ;
00255     return TRUE ;
00256 }

BOOL GMould::GenLine DPOINT  T  )  [inline, protected]
 

Definition at line 303 of file gmould.h.

00304 {
00305     return GenOp( PT_LINETO, T );
00306 }

BOOL GMould::GenMove DPOINT  T  )  [inline, protected]
 

Definition at line 298 of file gmould.h.

00299 {
00300     return GenOp( PT_MOVETO, T );
00301 }

BOOL GMould::GenOp BYTE  Op,
DPOINT  T
[inline, protected]
 

Definition at line 291 of file gmould.h.

00292 {
00293     if ( OLength-- < 1 ) return FALSE ;
00294     InverseScale( T, *OPoints++ ) ; *OTypes++ = Op ;
00295     return TRUE ;
00296 }

DocRect GMould::GetBoundingRect  ) 
 

Definition at line 141 of file gmould.cpp.

00142 {
00143     DocRect Rect;
00144     Rect.lo.x = MinX;
00145     Rect.lo.y = MinY;
00146     Rect.hi.x = MaxX;
00147     Rect.hi.y = MaxY;
00148     return Rect;
00149 }

RECT GMould::GetSourceBBox  )  const [inline]
 

Definition at line 191 of file gmould.h.

00191 { return SrcBBox; }

void GMould::InverseScale DPOINT  a,
POINT b
[protected]
 

Definition at line 272 of file gmould.cpp.

00273 {
00274     b.x = MinX+(INT32)(Width*a.x) ;
00275     b.y = MinY+(INT32)(Depth*a.y) ;
00276 }

virtual BOOL GMould::Redefine POINT P  )  [pure virtual]
 

Implemented in GEnvelope, GEnvelope2x2, and GPerspective.

void GMould::Scale POINT  a,
DPOINT b
[protected]
 

Definition at line 266 of file gmould.cpp.

00267 {
00268     b.x = (double)(a.x-MinX)/Width ;
00269     b.y = (double)(a.y-MinY)/Depth ;
00270 }

void GMould::ScaleSrc POINT  a,
DPOINT b
[protected]
 

Definition at line 260 of file gmould.cpp.

00261 {
00262     b.x = (double)(a.x-SrcBBox.left  )/(SrcBBox.right-SrcBBox.left  ) ;
00263     b.y = (double)(a.y-SrcBBox.bottom)/(SrcBBox.top  -SrcBBox.bottom) ;
00264 }

virtual void GMould::ScaleView  )  [protected, pure virtual]
 

Implemented in GEnvelope, GEnvelope2x2, and GPerspective.

virtual void GMould::Transform DPOINT  a,
DPOINT b
[protected, pure virtual]
 

Implemented in GEnvelope, GEnvelope2x2, and GPerspective.


Member Data Documentation

INT32 GMould::Depth [protected]
 

Definition at line 240 of file gmould.h.

INT32 GMould::MaxX [protected]
 

Definition at line 239 of file gmould.h.

INT32 GMould::MaxY [protected]
 

Definition at line 239 of file gmould.h.

INT32 GMould::MinX [protected]
 

Definition at line 239 of file gmould.h.

INT32 GMould::MinY [protected]
 

Definition at line 239 of file gmould.h.

DWORD GMould::OLength [protected]
 

Definition at line 245 of file gmould.h.

LPPOINT GMould::OPoints [protected]
 

Definition at line 243 of file gmould.h.

LPBYTE GMould::OTypes [protected]
 

Definition at line 244 of file gmould.h.

RECT GMould::SrcBBox [protected]
 

Definition at line 238 of file gmould.h.

double GMould::Tolerance [protected]
 

Definition at line 242 of file gmould.h.

INT32 GMould::Width [protected]
 

Definition at line 240 of file gmould.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:54:51 2007 for Camelot by  doxygen 1.4.4