GEnvelope Class Reference

The low level enveloper class. More...

#include <genv.h>

Inheritance diagram for GEnvelope:

GMould CCObject SimpleCCObject List of all members.

Public Member Functions

 GEnvelope ()
virtual BOOL Redefine (POINT *P)
virtual BOOL FitPath (CONST POINT *IPoints, CONST BYTE *ITypes, DWORD ILength, LPPOINT OPoints, LPBYTE OTypes, DWORD OLength, BOOL Close=FALSE)
virtual void CopyShape (POINT *P)

Private Member Functions

virtual void ScaleView ()
virtual void CalcViewBBox ()
virtual void CalcViewConsts ()
virtual void Transform (DPOINT a, DPOINT &b)

Private Attributes

POINT L0
POINT L1
POINT L2
POINT T0
POINT T1
POINT T2
POINT R0
POINT R1
POINT R2
POINT B0
POINT B1
POINT B2
DPOINT VL0
DPOINT VL1
DPOINT VL2
DPOINT VT0
DPOINT VT1
DPOINT VT2
DPOINT VR0
DPOINT VR1
DPOINT VR2
DPOINT VB0
DPOINT VB1
DPOINT VB2
DPOINT A
DPOINT B
DPOINT C
DPOINT D
DPOINT E
DPOINT F
DPOINT G
DPOINT H
DPOINT J
DPOINT K
DPOINT L
DPOINT M

Detailed Description

The low level enveloper class.

Author:
Gavin_Theobald (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/2/94

Definition at line 155 of file genv.h.


Constructor & Destructor Documentation

GEnvelope::GEnvelope  ) 
 

Definition at line 135 of file genv.cpp.

00136 {
00137     SrcBBox.left   = 0;
00138     SrcBBox.top    = 3;
00139     SrcBBox.right  = 3;
00140     SrcBBox.bottom = 0;
00141 
00142     L0.x = 0 ; L0.y = 0 ;
00143     L1.x = 0 ; L1.y = 1 ;
00144     L2.x = 0 ; L2.y = 2 ;
00145     T0.x = 0 ; T0.y = 3 ;
00146     T1.x = 1 ; T1.y = 3 ;
00147     T2.x = 2 ; T2.y = 3 ;
00148     R0.x = 3 ; R0.y = 3 ;
00149     R1.x = 3 ; R1.y = 2 ;
00150     R2.x = 3 ; R2.y = 1 ;
00151     B0.x = 3 ; B0.y = 0 ;
00152     B1.x = 2 ; B1.y = 0 ;
00153     B2.x = 1 ; B2.y = 0 ;
00154 
00155     MinX = 0; MinY = 0;
00156     MaxX = 3; MaxY = 3;
00157     Width = 3; Depth = 3;
00158 
00159     ScaleView();
00160     CalcViewConsts();
00161 }


Member Function Documentation

void GEnvelope::CalcViewBBox  )  [private, virtual]
 

Implements GMould.

Definition at line 191 of file genv.cpp.

00192 {
00193     MinX = MaxX = L0.x ;
00194     MinY = MaxY = L0.y ;
00195     MinX=min(MinX, INT32(L1.x)) ; MaxX=max(MaxX, INT32(L1.x)) ; MinY=min(MinY, INT32(L1.y)) ; MaxY=max(MaxY, INT32(L1.y)) ;
00196     MinX=min(MinX, INT32(L2.x)) ; MaxX=max(MaxX, INT32(L2.x)) ; MinY=min(MinY, INT32(L2.y)) ; MaxY=max(MaxY, INT32(L2.y)) ;
00197     MinX=min(MinX, INT32(T0.x)) ; MaxX=max(MaxX, INT32(T0.x)) ; MinY=min(MinY, INT32(T0.y)) ; MaxY=max(MaxY, INT32(T0.y)) ;
00198     MinX=min(MinX, INT32(T1.x)) ; MaxX=max(MaxX, INT32(T1.x)) ; MinY=min(MinY, INT32(T1.y)) ; MaxY=max(MaxY, INT32(T1.y)) ;
00199     MinX=min(MinX, INT32(T2.x)) ; MaxX=max(MaxX, INT32(T2.x)) ; MinY=min(MinY, INT32(T2.y)) ; MaxY=max(MaxY, INT32(T2.y)) ;
00200     MinX=min(MinX, INT32(R0.x)) ; MaxX=max(MaxX, INT32(R0.x)) ; MinY=min(MinY, INT32(R0.y)) ; MaxY=max(MaxY, INT32(R0.y)) ;
00201     MinX=min(MinX, INT32(R1.x)) ; MaxX=max(MaxX, INT32(R1.x)) ; MinY=min(MinY, INT32(R1.y)) ; MaxY=max(MaxY, INT32(R1.y)) ;
00202     MinX=min(MinX, INT32(R2.x)) ; MaxX=max(MaxX, INT32(R2.x)) ; MinY=min(MinY, INT32(R2.y)) ; MaxY=max(MaxY, INT32(R2.y)) ;
00203     MinX=min(MinX, INT32(B0.x)) ; MaxX=max(MaxX, INT32(B0.x)) ; MinY=min(MinY, INT32(B0.y)) ; MaxY=max(MaxY, INT32(B0.y)) ;
00204     MinX=min(MinX, INT32(B1.x)) ; MaxX=max(MaxX, INT32(B1.x)) ; MinY=min(MinY, INT32(B1.y)) ; MaxY=max(MaxY, INT32(B1.y)) ;
00205     MinX=min(MinX, INT32(B2.x)) ; MaxX=max(MaxX, INT32(B2.x)) ; MinY=min(MinY, INT32(B2.y)) ; MaxY=max(MaxY, INT32(B2.y)) ;
00206     Width = MaxX-MinX ;
00207     Depth = MaxY-MinY ;
00208 }

void GEnvelope::CalcViewConsts  )  [private, virtual]
 

Implements GMould.

Definition at line 244 of file genv.cpp.

00245 {
00246     A.x = VL0.x ;
00247     A.y = VL0.y ;
00248     B.x = 3*(VB2.x-VL0.x) ;
00249     B.y = 3*(VB2.y-VL0.y) ;
00250     C.x = 3*(VL1.x-VL0.x) ;
00251     C.y = 3*(VL1.y-VL0.y) ;
00252     D.x = 3*(VT1.x+VR2.x)-2*(VT0.x+VB0.x)-VL0.x-VR0.x-B.x-C.x ;
00253     D.y = 3*(VT1.y+VR2.y)-2*(VT0.y+VB0.y)-VL0.y-VR0.y-B.y-C.y ;
00254     E.x = 3*(VL0.x-2*VB2.x+VB1.x) ;
00255     E.y = 3*(VL0.y-2*VB2.y+VB1.y) ;
00256     F.x = 3*(VL2.x-2*VL1.x+VL0.x) ;
00257     F.y = 3*(VL2.y-2*VL1.y+VL0.y) ;
00258     G.x = 3*(VT2.x-2*VT1.x+VT0.x)-E.x ;
00259     G.y = 3*(VT2.y-2*VT1.y+VT0.y)-E.y ;
00260     H.x = 3*(VB0.x-2*VR2.x+VR1.x)-F.x ;
00261     H.y = 3*(VB0.y-2*VR2.y+VR1.y)-F.y ;
00262     J.x = VB0.x-3*(VB1.x-VB2.x)-VL0.x ;
00263     J.y = VB0.y-3*(VB1.y-VB2.y)-VL0.y ;
00264     K.x = VT0.x-3*(VL2.x-VL1.x)-VL0.x ;
00265     K.y = VT0.y-3*(VL2.y-VL1.y)-VL0.y ;
00266     L.x = VR0.x-3*(VT2.x-VT1.x)-VT0.x-J.x ;
00267     L.y = VR0.y-3*(VT2.y-VT1.y)-VT0.y-J.y ;
00268     M.x = VR0.x-3*(VR1.x-VR2.x)-VB0.x-K.x ;
00269     M.y = VR0.y-3*(VR1.y-VR2.y)-VB0.y-K.y ;
00270 }

void GEnvelope::CopyShape POINT P  )  [virtual]
 

Implements GMould.

Definition at line 211 of file genv.cpp.

00212 {
00213     P[ 0].x = L0.x ; P[ 0].y = L0.y ; 
00214     P[ 1].x = L1.x ; P[ 1].y = L1.y ;
00215     P[ 2].x = L2.x ; P[ 2].y = L2.y ;
00216     P[ 3].x = T0.x ; P[ 3].y = T0.y ;
00217     P[ 4].x = T1.x ; P[ 4].y = T1.y ;
00218     P[ 5].x = T2.x ; P[ 5].y = T2.y ;
00219     P[ 6].x = R0.x ; P[ 6].y = R0.y ;
00220     P[ 7].x = R1.x ; P[ 7].y = R1.y ;
00221     P[ 8].x = R2.x ; P[ 8].y = R2.y ;
00222     P[ 9].x = B0.x ; P[ 9].y = B0.y ;
00223     P[10].x = B1.x ; P[10].y = B1.y ;
00224     P[11].x = B2.x ; P[11].y = B2.y ;
00225 }

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

Implements GMould.

Definition at line 275 of file genv.cpp.

00284 {
00285     OPoints = pOPoints ;
00286     OTypes  = pOTypes  ;
00287     OLength = pOLength ;
00288 
00289     DPOINT     C2, C4 ;
00290     DPOINT P0, P2, P4, P6, SP ;
00291     DPOINT T0, T2, T4, T6, ST ;
00292     ST.x = ST.y = SP.x = SP.y =0;
00293     while ( ILength )
00294     {
00295         switch ( *ITypes & PT_MOVETO )
00296         {
00297         case PT_MOVETO :
00298             --ILength ;
00299             ScaleSrc ( *IPoints++, P0 ) ; SP.x = P0.x ; SP.y = P0.y ;
00300             Transform( P0, T0 ) ;         ST.x = T0.x ; ST.y = T0.y ;
00301             if ( !GenOp( *ITypes++, T0 ) ) return -1 ;
00302             break ;
00303         case PT_LINETO :
00304             --ILength ; ++ITypes ;
00305             ScaleSrc( *IPoints++, P6 ) ;
00306             P2.x = (2*P0.x+P6.x)/3 ;
00307             P2.y = (2*P0.y+P6.y)/3 ;
00308             P4.x = (P0.x+2*P6.x)/3 ;
00309             P4.y = (P0.y+2*P6.y)/3 ;
00310             Transform( P2, T2 ) ;
00311             Transform( P4, T4 ) ;
00312             Transform( P6, T6 ) ;
00313             if ( !GenCurve( P2, P4, P0, P2, P4, P6, T0, T2, T4, T6 ) ) return -1 ;
00314             P0.x = P6.x ; P0.y = P6.y ;
00315             T0.x = T6.x ; T0.y = T6.y ;
00316             break ;
00317         case PT_BEZIERTO :
00318             ILength -= 3 ; ITypes += 3 ;
00319             ScaleSrc( *IPoints++, C2 ) ;
00320             ScaleSrc( *IPoints++, C4 ) ;
00321             ScaleSrc( *IPoints++, P6 ) ;
00322             P2.x = (8*P0.x+12*C2.x+ 6*C4.x+  P6.x)/27 ;
00323             P2.y = (8*P0.y+12*C2.y+ 6*C4.y+  P6.y)/27 ;
00324             P4.x = (  P0.x+ 6*C2.x+12*C4.x+8*P6.x)/27 ;
00325             P4.y = (  P0.y+ 6*C2.y+12*C4.y+8*P6.y)/27 ;
00326             Transform( P2, T2 ) ;
00327             Transform( P4, T4 ) ;
00328             Transform( P6, T6 ) ;
00329             if ( !GenCurve( C2, C4, P0, P2, P4, P6, T0, T2, T4, T6 ) ) return -1 ;
00330             P0.x = P6.x ; P0.y = P6.y ;
00331             T0.x = T6.x ; T0.y = T6.y ;
00332             break ;
00333         default :
00334             return -1 ;
00335         }
00336 
00337         if ( *(ITypes-1) & PT_CLOSEFIGURE ||
00338                             ( Close && ( ILength==0 || (*ITypes & PT_MOVETO) == PT_MOVETO ) ) )
00339         {
00340             P2.x = (2*P0.x+SP.x)/3 ;
00341             P2.y = (2*P0.y+SP.y)/3 ;
00342             P4.x = (P0.x+2*SP.x)/3 ;
00343             P4.y = (P0.y+2*SP.y)/3 ;
00344             Transform( P2, T2 ) ;
00345             Transform( P4, T4 ) ;
00346             if ( !GenCurve( P2, P4, P0, P2, P4, SP, T0, T2, T4, ST ) ) return -1 ;
00347             *(OTypes-1) |= *(ITypes-1) & PT_CLOSEFIGURE ;
00348         }
00349     }
00350 
00351     if ( ILength )
00352         return -1 ;
00353 
00354     return pOLength-OLength ;
00355 }

BOOL GEnvelope::Redefine POINT P  )  [virtual]
 

Implements GMould.

Definition at line 164 of file genv.cpp.

00165 {
00166     L0.x = P[ 0].x ; L0.y = P[ 0].y ;
00167     L1.x = P[ 1].x ; L1.y = P[ 1].y ;
00168     L2.x = P[ 2].x ; L2.y = P[ 2].y ;
00169     T0.x = P[ 3].x ; T0.y = P[ 3].y ;
00170     T1.x = P[ 4].x ; T1.y = P[ 4].y ;
00171     T2.x = P[ 5].x ; T2.y = P[ 5].y ;
00172     R0.x = P[ 6].x ; R0.y = P[ 6].y ;
00173     R1.x = P[ 7].x ; R1.y = P[ 7].y ;
00174     R2.x = P[ 8].x ; R2.y = P[ 8].y ;
00175     B0.x = P[ 9].x ; B0.y = P[ 9].y ;
00176     B1.x = P[10].x ; B1.y = P[10].y ;
00177     B2.x = P[11].x ; B2.y = P[11].y ;
00178 
00179     CalcViewBBox();
00180     if (Width==0 || Depth==0) 
00181         return FALSE;
00182 
00183     ScaleView();
00184     CalcViewConsts();
00185 
00186     return TRUE;
00187 }

void GEnvelope::ScaleView  )  [private, virtual]
 

Implements GMould.

Definition at line 228 of file genv.cpp.

00229 {
00230     VL0.x = (double)(L0.x-MinX)/Width ; VL0.y = (double)(L0.y-MinY)/Depth ;
00231     VL1.x = (double)(L1.x-MinX)/Width ; VL1.y = (double)(L1.y-MinY)/Depth ;
00232     VL2.x = (double)(L2.x-MinX)/Width ; VL2.y = (double)(L2.y-MinY)/Depth ;
00233     VT0.x = (double)(T0.x-MinX)/Width ; VT0.y = (double)(T0.y-MinY)/Depth ;
00234     VT1.x = (double)(T1.x-MinX)/Width ; VT1.y = (double)(T1.y-MinY)/Depth ;
00235     VT2.x = (double)(T2.x-MinX)/Width ; VT2.y = (double)(T2.y-MinY)/Depth ;
00236     VR0.x = (double)(R0.x-MinX)/Width ; VR0.y = (double)(R0.y-MinY)/Depth ;
00237     VR1.x = (double)(R1.x-MinX)/Width ; VR1.y = (double)(R1.y-MinY)/Depth ;
00238     VR2.x = (double)(R2.x-MinX)/Width ; VR2.y = (double)(R2.y-MinY)/Depth ;
00239     VB0.x = (double)(B0.x-MinX)/Width ; VB0.y = (double)(B0.y-MinY)/Depth ;
00240     VB1.x = (double)(B1.x-MinX)/Width ; VB1.y = (double)(B1.y-MinY)/Depth ;
00241     VB2.x = (double)(B2.x-MinX)/Width ; VB2.y = (double)(B2.y-MinY)/Depth ;
00242 }

void GEnvelope::Transform DPOINT  a,
DPOINT b
[private, virtual]
 

Implements GMould.

Definition at line 359 of file genv.cpp.

00360 {
00361     b.x = A.x+a.x*(B.x+a.x*(E.x+a.x*J.x))
00362              +a.y*(C.x+a.y*(F.x+a.y*K.x)
00363              +a.x*(D.x+a.x*(G.x+a.x*L.x)
00364                       +a.y*(H.x+a.y*M.x))) ;
00365     b.y = A.y+a.x*(B.y+a.x*(E.y+a.x*J.y))
00366              +a.y*(C.y+a.y*(F.y+a.y*K.y)
00367              +a.x*(D.y+a.x*(G.y+a.x*L.y)
00368                       +a.y*(H.y+a.y*M.y))) ;
00369 }


Member Data Documentation

DPOINT GEnvelope::A [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::B [private]
 

Definition at line 189 of file genv.h.

POINT GEnvelope::B0 [private]
 

Definition at line 184 of file genv.h.

POINT GEnvelope::B1 [private]
 

Definition at line 184 of file genv.h.

POINT GEnvelope::B2 [private]
 

Definition at line 184 of file genv.h.

DPOINT GEnvelope::C [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::D [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::E [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::F [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::G [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::H [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::J [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::K [private]
 

Definition at line 189 of file genv.h.

DPOINT GEnvelope::L [private]
 

Definition at line 189 of file genv.h.

POINT GEnvelope::L0 [private]
 

Definition at line 181 of file genv.h.

POINT GEnvelope::L1 [private]
 

Definition at line 181 of file genv.h.

POINT GEnvelope::L2 [private]
 

Definition at line 181 of file genv.h.

DPOINT GEnvelope::M [private]
 

Definition at line 189 of file genv.h.

POINT GEnvelope::R0 [private]
 

Definition at line 183 of file genv.h.

POINT GEnvelope::R1 [private]
 

Definition at line 183 of file genv.h.

POINT GEnvelope::R2 [private]
 

Definition at line 183 of file genv.h.

POINT GEnvelope::T0 [private]
 

Definition at line 182 of file genv.h.

POINT GEnvelope::T1 [private]
 

Definition at line 182 of file genv.h.

POINT GEnvelope::T2 [private]
 

Definition at line 182 of file genv.h.

DPOINT GEnvelope::VB0 [private]
 

Definition at line 188 of file genv.h.

DPOINT GEnvelope::VB1 [private]
 

Definition at line 188 of file genv.h.

DPOINT GEnvelope::VB2 [private]
 

Definition at line 188 of file genv.h.

DPOINT GEnvelope::VL0 [private]
 

Definition at line 185 of file genv.h.

DPOINT GEnvelope::VL1 [private]
 

Definition at line 185 of file genv.h.

DPOINT GEnvelope::VL2 [private]
 

Definition at line 185 of file genv.h.

DPOINT GEnvelope::VR0 [private]
 

Definition at line 187 of file genv.h.

DPOINT GEnvelope::VR1 [private]
 

Definition at line 187 of file genv.h.

DPOINT GEnvelope::VR2 [private]
 

Definition at line 187 of file genv.h.

DPOINT GEnvelope::VT0 [private]
 

Definition at line 186 of file genv.h.

DPOINT GEnvelope::VT1 [private]
 

Definition at line 186 of file genv.h.

DPOINT GEnvelope::VT2 [private]
 

Definition at line 186 of file genv.h.


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