00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 #include "camtypes.h"
00115
00116 #include <math.h>
00117 #include "moldshap.h"
00118 #include "gmould.h"
00119 #include "genv.h"
00120
00121 DECLARE_SOURCE("$Revision: 751 $");
00122
00123 CC_IMPLEMENT_DYNAMIC(GEnvelope, GMould)
00124 CC_IMPLEMENT_DYNAMIC(GEnvelope2x2, GMould)
00125
00126
00127 #define new CAM_DEBUG_NEW
00128
00130
00131
00132
00134
00135 GEnvelope::GEnvelope()
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 }
00162
00163
00164 BOOL GEnvelope::Redefine( POINT *P )
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 }
00188
00190
00191 void GEnvelope::CalcViewBBox()
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 }
00209
00210
00211 void GEnvelope::CopyShape(POINT* P)
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 }
00226
00227
00228 void GEnvelope::ScaleView()
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 }
00243
00244 void GEnvelope::CalcViewConsts()
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 }
00271
00272
00274
00275 BOOL GEnvelope::FitPath (
00276 CONST POINT* IPoints,
00277 CONST BYTE* ITypes,
00278 DWORD ILength,
00279 LPPOINT pOPoints,
00280 LPBYTE pOTypes,
00281 DWORD pOLength,
00282 BOOL Close
00283 )
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 }
00356
00358
00359 void GEnvelope::Transform( DPOINT a, DPOINT& b )
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 }
00370
00372
00373
00374
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388 GEnvelope2x2::GEnvelope2x2()
00389 {
00390 L0.x = 0 ; L0.y = 0 ;
00391 L1.x = 0 ; L1.y = 1 ;
00392 L2.x = 0 ; L2.y = 2 ;
00393 L3.x = 0 ; L3.y = 3 ;
00394 L4.x = 0 ; L4.y = 4 ;
00395 L5.x = 0 ; L5.y = 5 ;
00396
00397 T0.x = 0 ; T0.y = 6 ;
00398 T1.x = 1 ; T1.y = 6 ;
00399 T2.x = 2 ; T2.y = 6 ;
00400 T3.x = 3 ; T3.y = 6 ;
00401 T4.x = 4 ; T4.y = 6 ;
00402 T5.x = 5 ; T5.y = 6 ;
00403
00404 R0.x = 6 ; R0.y = 6 ;
00405 R1.x = 6 ; R1.y = 5 ;
00406 R2.x = 6 ; R2.y = 4 ;
00407 R3.x = 6 ; R3.y = 3 ;
00408 R4.x = 6 ; R4.y = 2 ;
00409 R5.x = 6 ; R5.y = 1 ;
00410
00411 B0.x = 6 ; B0.y = 0 ;
00412 B1.x = 5 ; B1.y = 0 ;
00413 B2.x = 4 ; B2.y = 0 ;
00414 B3.x = 3 ; B3.y = 0 ;
00415 B4.x = 2 ; B4.y = 0 ;
00416 B5.x = 1 ; B5.y = 0 ;
00417
00418 CalcConsts();
00419 }
00420
00421
00422 BOOL GEnvelope2x2::Redefine( POINT *P )
00423 {
00424 L0.x = P[ 0].x ; L0.y = P[ 0].y ;
00425 L1.x = P[ 1].x ; L1.y = P[ 1].y ;
00426 L2.x = P[ 2].x ; L2.y = P[ 2].y ;
00427 L3.x = P[ 3].x ; L3.y = P[ 3].y ;
00428 L4.x = P[ 4].x ; L4.y = P[ 4].y ;
00429 L5.x = P[ 5].x ; L5.y = P[ 5].y ;
00430 T0.x = P[ 6].x ; T0.y = P[ 6].y ;
00431 T1.x = P[ 7].x ; T1.y = P[ 7].y ;
00432 T2.x = P[ 8].x ; T2.y = P[ 8].y ;
00433 T3.x = P[ 9].x ; T3.y = P[ 9].y ;
00434 T4.x = P[10].x ; T4.y = P[10].y ;
00435 T5.x = P[11].x ; T5.y = P[11].y ;
00436 R0.x = P[12].x ; R0.y = P[12].y ;
00437 R1.x = P[13].x ; R1.y = P[13].y ;
00438 R2.x = P[14].x ; R2.y = P[14].y ;
00439 R3.x = P[15].x ; R3.y = P[15].y ;
00440 R4.x = P[16].x ; R4.y = P[16].y ;
00441 R5.x = P[17].x ; R5.y = P[17].y ;
00442 B0.x = P[18].x ; B0.y = P[18].y ;
00443 B1.x = P[19].x ; B1.y = P[19].y ;
00444 B2.x = P[20].x ; B2.y = P[20].y ;
00445 B3.x = P[21].x ; B3.y = P[21].y ;
00446 B4.x = P[22].x ; B4.y = P[22].y ;
00447 B5.x = P[23].x ; B5.y = P[23].y ;
00448
00449 return CalcConsts();
00450 }
00451
00452
00453 BOOL GEnvelope2x2::CalcConsts()
00454 {
00455 MM.x = (- B0.x + 2*B3.x - L0.x + 2*L3.x - R0.x + 2*R3.x - T0.x + 2*T3.x)/ 4 ;
00456 MM.y = (- B0.y + 2*B3.y - L0.y + 2*L3.y - R0.y + 2*R3.y - T0.y + 2*T3.y)/ 4 ;
00457 H1.x = (- B0.x + 6*B5.x - 5*L0.x + 10*L3.x - R0.x + 2*R3.x - 5*T0.x + 6*T1.x)/12 ;
00458 H1.y = (- B0.y + 6*B5.y - 5*L0.y + 10*L3.y - R0.y + 2*R3.y - 5*T0.y + 6*T1.y)/12 ;
00459 H2.x = (- B0.x + 3*B4.x - 2*L0.x + 4*L3.x - R0.x + 2*R3.x - 2*T0.x + 3*T2.x)/ 6 ;
00460 H2.y = (- B0.y + 3*B4.y - 2*L0.y + 4*L3.y - R0.y + 2*R3.y - 2*T0.y + 3*T2.y)/ 6 ;
00461 H4.x = (-2*B0.x + 3*B2.x - L0.x + 2*L3.x - 2*R0.x + 4*R3.x - T0.x + 3*T4.x)/ 6 ;
00462 H4.y = (-2*B0.y + 3*B2.y - L0.y + 2*L3.y - 2*R0.y + 4*R3.y - T0.y + 3*T4.y)/ 6 ;
00463 H5.x = (-5*B0.x + 6*B1.x - L0.x + 2*L3.x - 5*R0.x + 10*R3.x - T0.x + 6*T5.x)/12 ;
00464 H5.y = (-5*B0.y + 6*B1.y - L0.y + 2*L3.y - 5*R0.y + 10*R3.y - T0.y + 6*T5.y)/12 ;
00465 V1.x = (-5*B0.x + 10*B3.x - 5*L0.x + 6*L1.x - R0.x + 6*R5.x - T0.x + 2*T3.x)/12 ;
00466 V1.y = (-5*B0.y + 10*B3.y - 5*L0.y + 6*L1.y - R0.y + 6*R5.y - T0.y + 2*T3.y)/12 ;
00467 V2.x = (-2*B0.x + 4*B3.x - 2*L0.x + 3*L2.x - R0.x + 3*R4.x - T0.x + 2*T3.x)/ 6 ;
00468 V2.y = (-2*B0.y + 4*B3.y - 2*L0.y + 3*L2.y - R0.y + 3*R4.y - T0.y + 2*T3.y)/ 6 ;
00469 V4.x = (- B0.x + 2*B3.x - L0.x + 3*L4.x - 2*R0.x + 3*R2.x - 2*T0.x + 4*T3.x)/ 6 ;
00470 V4.y = (- B0.y + 2*B3.y - L0.y + 3*L4.y - 2*R0.y + 3*R2.y - 2*T0.y + 4*T3.y)/ 6 ;
00471 V5.x = (- B0.x + 2*B3.x - L0.x + 6*L5.x - 5*R0.x + 6*R1.x - 5*T0.x + 10*T3.x)/12 ;
00472 V5.y = (- B0.y + 2*B3.y - L0.y + 6*L5.y - 5*R0.y + 6*R1.y - 5*T0.y + 10*T3.y)/12 ;
00473 SmoothX = T4.x-T3.x == T3.x-T2.x && T4.y-T3.y == T3.y-T2.y &&
00474 B4.x-B3.x == B3.x-B2.x && B4.y-B3.y == B3.y-B2.y ;
00475 SmoothY = L4.x-L3.x == L3.x-L2.x && L4.y-L3.y == L3.y-L2.y &&
00476 R4.x-R3.x == R3.x-R2.x && R4.y-R3.y == R3.y-R2.y ;
00477
00478 CalcViewBBox() ;
00479 if (Width==0 || Depth==0)
00480 return FALSE;
00481
00482 ScaleView() ;
00483 CalcViewConsts() ;
00484
00485 return TRUE;
00486 }
00487
00488
00489
00490 void GEnvelope2x2::CopyShape(POINT* P)
00491 {
00492 P[ 0].x = L0.x ; P[ 0].y = L0.y ;
00493 P[ 1].x = L1.x ; P[ 1].y = L1.y ;
00494 P[ 2].x = L2.x ; P[ 2].y = L2.y ;
00495 P[ 3].x = L3.x ; P[ 3].y = L3.y ;
00496 P[ 4].x = L4.x ; P[ 4].y = L4.y ;
00497 P[ 5].x = L5.x ; P[ 5].y = L5.y ;
00498 P[ 6].x = T0.x ; P[ 6].y = T0.y ;
00499 P[ 7].x = T1.x ; P[ 7].y = T1.y ;
00500 P[ 8].x = T2.x ; P[ 8].y = T2.y ;
00501 P[ 9].x = T3.x ; P[ 9].y = T3.y ;
00502 P[10].x = T4.x ; P[10].y = T4.y ;
00503 P[11].x = T5.x ; P[11].y = T5.y ;
00504 P[12].x = R0.x ; P[12].y = R0.y ;
00505 P[13].x = R1.x ; P[13].y = R1.y ;
00506 P[14].x = R2.x ; P[14].y = R2.y ;
00507 P[15].x = R3.x ; P[15].y = R3.y ;
00508 P[16].x = R4.x ; P[16].y = R4.y ;
00509 P[17].x = R5.x ; P[17].y = R5.y ;
00510 P[18].x = B0.x ; P[18].y = B0.y ;
00511 P[19].x = B1.x ; P[19].y = B1.y ;
00512 P[20].x = B2.x ; P[20].y = B2.y ;
00513 P[21].x = B3.x ; P[21].y = B3.y ;
00514 P[22].x = B4.x ; P[22].y = B4.y ;
00515 P[23].x = B5.x ; P[23].y = B5.y ;
00516 }
00517
00518
00520
00521 void GEnvelope2x2::CalcViewBBox()
00522 {
00523 MinX = MaxX = L0.x ;
00524 MinY = MaxY = L0.y ;
00525 MinX=min(MinX, INT32(L1.x)) ; MaxX=max(MaxX, INT32(L1.x)) ; MinY=min(MinY, INT32(L1.y)) ; MaxY=max(MaxY, INT32(L1.y)) ;
00526 MinX=min(MinX, INT32(L2.x)) ; MaxX=max(MaxX, INT32(L2.x)) ; MinY=min(MinY, INT32(L2.y)) ; MaxY=max(MaxY, INT32(L2.y)) ;
00527 MinX=min(MinX, INT32(L3.x)) ; MaxX=max(MaxX, INT32(L3.x)) ; MinY=min(MinY, INT32(L3.y)) ; MaxY=max(MaxY, INT32(L3.y)) ;
00528 MinX=min(MinX, INT32(L4.x)) ; MaxX=max(MaxX, INT32(L4.x)) ; MinY=min(MinY, INT32(L4.y)) ; MaxY=max(MaxY, INT32(L4.y)) ;
00529 MinX=min(MinX, INT32(L5.x)) ; MaxX=max(MaxX, INT32(L5.x)) ; MinY=min(MinY, INT32(L5.y)) ; MaxY=max(MaxY, INT32(L5.y)) ;
00530 MinX=min(MinX, INT32(T0.x)) ; MaxX=max(MaxX, INT32(T0.x)) ; MinY=min(MinY, INT32(T0.y)) ; MaxY=max(MaxY, INT32(T0.y)) ;
00531 MinX=min(MinX, INT32(T1.x)) ; MaxX=max(MaxX, INT32(T1.x)) ; MinY=min(MinY, INT32(T1.y)) ; MaxY=max(MaxY, INT32(T1.y)) ;
00532 MinX=min(MinX, INT32(T2.x)) ; MaxX=max(MaxX, INT32(T2.x)) ; MinY=min(MinY, INT32(T2.y)) ; MaxY=max(MaxY, INT32(T2.y)) ;
00533 MinX=min(MinX, INT32(T3.x)) ; MaxX=max(MaxX, INT32(T3.x)) ; MinY=min(MinY, INT32(T3.y)) ; MaxY=max(MaxY, INT32(T3.y)) ;
00534 MinX=min(MinX, INT32(T4.x)) ; MaxX=max(MaxX, INT32(T4.x)) ; MinY=min(MinY, INT32(T4.y)) ; MaxY=max(MaxY, INT32(T4.y)) ;
00535 MinX=min(MinX, INT32(T5.x)) ; MaxX=max(MaxX, INT32(T5.x)) ; MinY=min(MinY, INT32(T5.y)) ; MaxY=max(MaxY, INT32(T5.y)) ;
00536 MinX=min(MinX, INT32(R0.x)) ; MaxX=max(MaxX, INT32(R0.x)) ; MinY=min(MinY, INT32(R0.y)) ; MaxY=max(MaxY, INT32(R0.y)) ;
00537 MinX=min(MinX, INT32(R1.x)) ; MaxX=max(MaxX, INT32(R1.x)) ; MinY=min(MinY, INT32(R1.y)) ; MaxY=max(MaxY, INT32(R1.y)) ;
00538 MinX=min(MinX, INT32(R2.x)) ; MaxX=max(MaxX, INT32(R2.x)) ; MinY=min(MinY, INT32(R2.y)) ; MaxY=max(MaxY, INT32(R2.y)) ;
00539 MinX=min(MinX, INT32(R3.x)) ; MaxX=max(MaxX, INT32(R3.x)) ; MinY=min(MinY, INT32(R3.y)) ; MaxY=max(MaxY, INT32(R3.y)) ;
00540 MinX=min(MinX, INT32(R4.x)) ; MaxX=max(MaxX, INT32(R4.x)) ; MinY=min(MinY, INT32(R4.y)) ; MaxY=max(MaxY, INT32(R4.y)) ;
00541 MinX=min(MinX, INT32(R5.x)) ; MaxX=max(MaxX, INT32(R5.x)) ; MinY=min(MinY, INT32(R5.y)) ; MaxY=max(MaxY, INT32(R5.y)) ;
00542 MinX=min(MinX, INT32(B0.x)) ; MaxX=max(MaxX, INT32(B0.x)) ; MinY=min(MinY, INT32(B0.y)) ; MaxY=max(MaxY, INT32(B0.y)) ;
00543 MinX=min(MinX, INT32(B1.x)) ; MaxX=max(MaxX, INT32(B1.x)) ; MinY=min(MinY, INT32(B1.y)) ; MaxY=max(MaxY, INT32(B1.y)) ;
00544 MinX=min(MinX, INT32(B2.x)) ; MaxX=max(MaxX, INT32(B2.x)) ; MinY=min(MinY, INT32(B2.y)) ; MaxY=max(MaxY, INT32(B2.y)) ;
00545 MinX=min(MinX, INT32(B3.x)) ; MaxX=max(MaxX, INT32(B3.x)) ; MinY=min(MinY, INT32(B3.y)) ; MaxY=max(MaxY, INT32(B3.y)) ;
00546 MinX=min(MinX, INT32(B4.x)) ; MaxX=max(MaxX, INT32(B4.x)) ; MinY=min(MinY, INT32(B4.y)) ; MaxY=max(MaxY, INT32(B4.y)) ;
00547 MinX=min(MinX, INT32(B5.x)) ; MaxX=max(MaxX, INT32(B5.x)) ; MinY=min(MinY, INT32(B5.y)) ; MaxY=max(MaxY, INT32(B5.y)) ;
00548 Width = MaxX-MinX ;
00549 Depth = MaxY-MinY ;
00550 }
00551
00552
00553
00554 void GEnvelope2x2::ScaleView()
00555 {
00556 VL0.x = (double)(L0.x-MinX)/Width ; VL0.y = (double)(L0.y-MinY)/Depth ;
00557 VL1.x = (double)(L1.x-MinX)/Width ; VL1.y = (double)(L1.y-MinY)/Depth ;
00558 VL2.x = (double)(L2.x-MinX)/Width ; VL2.y = (double)(L2.y-MinY)/Depth ;
00559 VL3.x = (double)(L3.x-MinX)/Width ; VL3.y = (double)(L3.y-MinY)/Depth ;
00560 VL4.x = (double)(L4.x-MinX)/Width ; VL4.y = (double)(L4.y-MinY)/Depth ;
00561 VL5.x = (double)(L5.x-MinX)/Width ; VL5.y = (double)(L5.y-MinY)/Depth ;
00562 VT0.x = (double)(T0.x-MinX)/Width ; VT0.y = (double)(T0.y-MinY)/Depth ;
00563 VT1.x = (double)(T1.x-MinX)/Width ; VT1.y = (double)(T1.y-MinY)/Depth ;
00564 VT2.x = (double)(T2.x-MinX)/Width ; VT2.y = (double)(T2.y-MinY)/Depth ;
00565 VT3.x = (double)(T3.x-MinX)/Width ; VT3.y = (double)(T3.y-MinY)/Depth ;
00566 VT4.x = (double)(T4.x-MinX)/Width ; VT4.y = (double)(T4.y-MinY)/Depth ;
00567 VT5.x = (double)(T5.x-MinX)/Width ; VT5.y = (double)(T5.y-MinY)/Depth ;
00568 VR0.x = (double)(R0.x-MinX)/Width ; VR0.y = (double)(R0.y-MinY)/Depth ;
00569 VR1.x = (double)(R1.x-MinX)/Width ; VR1.y = (double)(R1.y-MinY)/Depth ;
00570 VR2.x = (double)(R2.x-MinX)/Width ; VR2.y = (double)(R2.y-MinY)/Depth ;
00571 VR3.x = (double)(R3.x-MinX)/Width ; VR3.y = (double)(R3.y-MinY)/Depth ;
00572 VR4.x = (double)(R4.x-MinX)/Width ; VR4.y = (double)(R4.y-MinY)/Depth ;
00573 VR5.x = (double)(R5.x-MinX)/Width ; VR5.y = (double)(R5.y-MinY)/Depth ;
00574 VB0.x = (double)(B0.x-MinX)/Width ; VB0.y = (double)(B0.y-MinY)/Depth ;
00575 VB1.x = (double)(B1.x-MinX)/Width ; VB1.y = (double)(B1.y-MinY)/Depth ;
00576 VB2.x = (double)(B2.x-MinX)/Width ; VB2.y = (double)(B2.y-MinY)/Depth ;
00577 VB3.x = (double)(B3.x-MinX)/Width ; VB3.y = (double)(B3.y-MinY)/Depth ;
00578 VB4.x = (double)(B4.x-MinX)/Width ; VB4.y = (double)(B4.y-MinY)/Depth ;
00579 VB5.x = (double)(B5.x-MinX)/Width ; VB5.y = (double)(B5.y-MinY)/Depth ;
00580 VMM.x = (double)(MM.x-MinX)/Width ; VMM.y = (double)(MM.y-MinY)/Depth ;
00581 VH1.x = (double)(H1.x-MinX)/Width ; VH1.y = (double)(H1.y-MinY)/Depth ;
00582 VH2.x = (double)(H2.x-MinX)/Width ; VH2.y = (double)(H2.y-MinY)/Depth ;
00583 VH4.x = (double)(H4.x-MinX)/Width ; VH4.y = (double)(H4.y-MinY)/Depth ;
00584 VH5.x = (double)(H5.x-MinX)/Width ; VH5.y = (double)(H5.y-MinY)/Depth ;
00585 VV1.x = (double)(V1.x-MinX)/Width ; VV1.y = (double)(V1.y-MinY)/Depth ;
00586 VV2.x = (double)(V2.x-MinX)/Width ; VV2.y = (double)(V2.y-MinY)/Depth ;
00587 VV4.x = (double)(V4.x-MinX)/Width ; VV4.y = (double)(V4.y-MinY)/Depth ;
00588 VV5.x = (double)(V5.x-MinX)/Width ; VV5.y = (double)(V5.y-MinY)/Depth ;
00589 }
00590
00591
00592
00593 void GEnvelope2x2::CalcViewConsts()
00594 {
00595 A00.x = VL0.x ;
00596 A00.y = VL0.y ;
00597 B00.x = 3*(VB5.x-VL0.x) ;
00598 B00.y = 3*(VB5.y-VL0.y) ;
00599 C00.x = 3*(VL1.x-VL0.x) ;
00600 C00.y = 3*(VL1.y-VL0.y) ;
00601 D00.x = 3*(VH1.x+VV1.x)-2*(VL3.x+VB3.x)-VL0.x-VMM.x-B00.x-C00.x ;
00602 D00.y = 3*(VH1.y+VV1.y)-2*(VL3.y+VB3.y)-VL0.y-VMM.y-B00.y-C00.y ;
00603 E00.x = 3*(VL0.x-2*VB5.x+VB4.x) ;
00604 E00.y = 3*(VL0.y-2*VB5.y+VB4.y) ;
00605 F00.x = 3*(VL2.x-2*VL1.x+VL0.x) ;
00606 F00.y = 3*(VL2.y-2*VL1.y+VL0.y) ;
00607 G00.x = 3*(VH2.x-2*VH1.x+VL3.x)-E00.x ;
00608 G00.y = 3*(VH2.y-2*VH1.y+VL3.y)-E00.y ;
00609 H00.x = 3*(VB3.x-2*VV1.x+VV2.x)-F00.x ;
00610 H00.y = 3*(VB3.y-2*VV1.y+VV2.y)-F00.y ;
00611 J00.x = VB3.x-3*(VB4.x-VB5.x)-VL0.x ;
00612 J00.y = VB3.y-3*(VB4.y-VB5.y)-VL0.y ;
00613 K00.x = VL3.x-3*(VL2.x-VL1.x)-VL0.x ;
00614 K00.y = VL3.y-3*(VL2.y-VL1.y)-VL0.y ;
00615 L00.x = VMM.x-3*(VH2.x-VH1.x)-VL3.x-J00.x ;
00616 L00.y = VMM.y-3*(VH2.y-VH1.y)-VL3.y-J00.y ;
00617 M00.x = VMM.x-3*(VV2.x-VV1.x)-VB3.x-K00.x ;
00618 M00.y = VMM.y-3*(VV2.y-VV1.y)-VB3.y-K00.y ;
00619
00620 A01.x = VB3.x ;
00621 A01.y = VB3.y ;
00622 B01.x = 3*(VB2.x-VB3.x) ;
00623 B01.y = 3*(VB2.y-VB3.y) ;
00624 C01.x = 3*(VV1.x-VB3.x) ;
00625 C01.y = 3*(VV1.y-VB3.y) ;
00626 D01.x = 3*(VH4.x+VR5.x)-2*(VMM.x+VB0.x)-VB3.x-VR3.x-B01.x-C01.x ;
00627 D01.y = 3*(VH4.y+VR5.y)-2*(VMM.y+VB0.y)-VB3.y-VR3.y-B01.y-C01.y ;
00628 E01.x = 3*(VB3.x-2*VB2.x+VB1.x) ;
00629 E01.y = 3*(VB3.y-2*VB2.y+VB1.y) ;
00630 F01.x = 3*(VV2.x-2*VV1.x+VB3.x) ;
00631 F01.y = 3*(VV2.y-2*VV1.y+VB3.y) ;
00632 G01.x = 3*(VH5.x-2*VH4.x+VMM.x)-E01.x ;
00633 G01.y = 3*(VH5.y-2*VH4.y+VMM.y)-E01.y ;
00634 H01.x = 3*(VB0.x-2*VR5.x+VR4.x)-F01.x ;
00635 H01.y = 3*(VB0.y-2*VR5.y+VR4.y)-F01.y ;
00636 J01.x = VB0.x-3*(VB1.x-VB2.x)-VB3.x ;
00637 J01.y = VB0.y-3*(VB1.y-VB2.y)-VB3.y ;
00638 K01.x = VMM.x-3*(VV2.x-VV1.x)-VB3.x ;
00639 K01.y = VMM.y-3*(VV2.y-VV1.y)-VB3.y ;
00640 L01.x = VR3.x-3*(VH5.x-VH4.x)-VMM.x-J01.x ;
00641 L01.y = VR3.y-3*(VH5.y-VH4.y)-VMM.y-J01.y ;
00642 M01.x = VR3.x-3*(VR4.x-VR5.x)-VB0.x-K01.x ;
00643 M01.y = VR3.y-3*(VR4.y-VR5.y)-VB0.y-K01.y ;
00644
00645 A10.x = VL3.x ;
00646 A10.y = VL3.y ;
00647 B10.x = 3*(VH1.x-VL3.x) ;
00648 B10.y = 3*(VH1.y-VL3.y) ;
00649 C10.x = 3*(VL4.x-VL3.x) ;
00650 C10.y = 3*(VL4.y-VL3.y) ;
00651 D10.x = 3*(VT1.x+VV4.x)-2*(VT0.x+VMM.x)-VL3.x-VT3.x-B10.x-C10.x ;
00652 D10.y = 3*(VT1.y+VV4.y)-2*(VT0.y+VMM.y)-VL3.y-VT3.y-B10.y-C10.y ;
00653 E10.x = 3*(VL3.x-2*VH1.x+VH2.x) ;
00654 E10.y = 3*(VL3.y-2*VH1.y+VH2.y) ;
00655 F10.x = 3*(VL5.x-2*VL4.x+VL3.x) ;
00656 F10.y = 3*(VL5.y-2*VL4.y+VL3.y) ;
00657 G10.x = 3*(VT2.x-2*VT1.x+VT0.x)-E10.x ;
00658 G10.y = 3*(VT2.y-2*VT1.y+VT0.y)-E10.y ;
00659 H10.x = 3*(VMM.x-2*VV4.x+VV5.x)-F10.x ;
00660 H10.y = 3*(VMM.y-2*VV4.y+VV5.y)-F10.y ;
00661 J10.x = VMM.x-3*(VH2.x-VH1.x)-VL3.x ;
00662 J10.y = VMM.y-3*(VH2.y-VH1.y)-VL3.y ;
00663 K10.x = VT0.x-3*(VL5.x-VL4.x)-VL3.x ;
00664 K10.y = VT0.y-3*(VL5.y-VL4.y)-VL3.y ;
00665 L10.x = VT3.x-3*(VT2.x-VT1.x)-VT0.x-J10.x ;
00666 L10.y = VT3.y-3*(VT2.y-VT1.y)-VT0.y-J10.y ;
00667 M10.x = VT3.x-3*(VV5.x-VV4.x)-VMM.x-K10.x ;
00668 M10.y = VT3.y-3*(VV5.y-VV4.y)-VMM.y-K10.y ;
00669
00670 A11.x = VMM.x ;
00671 A11.y = VMM.y ;
00672 B11.x = 3*(VH4.x-VMM.x) ;
00673 B11.y = 3*(VH4.y-VMM.y) ;
00674 C11.x = 3*(VV4.x-VMM.x) ;
00675 C11.y = 3*(VV4.y-VMM.y) ;
00676 D11.x = 3*(VT4.x+VR2.x)-2*(VT3.x+VR3.x)-VMM.x-VR0.x-B11.x-C11.x ;
00677 D11.y = 3*(VT4.y+VR2.y)-2*(VT3.y+VR3.y)-VMM.y-VR0.y-B11.y-C11.y ;
00678 E11.x = 3*(VMM.x-2*VH4.x+VH5.x) ;
00679 E11.y = 3*(VMM.y-2*VH4.y+VH5.y) ;
00680 F11.x = 3*(VV5.x-2*VV4.x+VMM.x) ;
00681 F11.y = 3*(VV5.y-2*VV4.y+VMM.y) ;
00682 G11.x = 3*(VT5.x-2*VT4.x+VT3.x)-E11.x ;
00683 G11.y = 3*(VT5.y-2*VT4.y+VT3.y)-E11.y ;
00684 H11.x = 3*(VR3.x-2*VR2.x+VR1.x)-F11.x ;
00685 H11.y = 3*(VR3.y-2*VR2.y+VR1.y)-F11.y ;
00686 J11.x = VR3.x-3*(VH5.x-VH4.x)-VMM.x ;
00687 J11.y = VR3.y-3*(VH5.y-VH4.y)-VMM.y ;
00688 K11.x = VT3.x-3*(VV5.x-VV4.x)-VMM.x ;
00689 K11.y = VT3.y-3*(VV5.y-VV4.y)-VMM.y ;
00690 L11.x = VR0.x-3*(VT5.x-VT4.x)-VT3.x-J11.x ;
00691 L11.y = VR0.y-3*(VT5.y-VT4.y)-VT3.y-J11.y ;
00692 M11.x = VR0.x-3*(VR1.x-VR2.x)-VR3.x-K11.x ;
00693 M11.y = VR0.y-3*(VR1.y-VR2.y)-VR3.y-K11.y ;
00694 }
00695
00697
00698 BOOL GEnvelope2x2::FitPath (
00699 CONST POINT* IPoints,
00700 CONST BYTE* ITypes,
00701 DWORD ILength,
00702 LPPOINT pOPoints,
00703 LPBYTE pOTypes,
00704 DWORD pOLength,
00705 BOOL Close
00706 )
00707 {
00708 OPoints = pOPoints ;
00709 OTypes = pOTypes ;
00710 OLength = pOLength ;
00711
00712 DPOINT C2, C4 ;
00713 DPOINT P0, P2, P4, P6, SP;
00714 DPOINT T0, T2, T4, T6, ST;
00715 SP.x=SP.y=ST.x=ST.y=0;
00716 while ( ILength )
00717 {
00718 switch ( *ITypes & PT_MOVETO )
00719 {
00720 case PT_MOVETO :
00721 --ILength ; ++ITypes ;
00722 ScaleSrc ( *IPoints++, P0 ) ; SP.x = P0.x ; SP.y = P0.y ;
00723 Transform( P0, T0 ) ; ST.x = T0.x ; ST.y = T0.y ;
00724 if ( !GenMove( T0 ) ) return -1 ;
00725 break ;
00726 case PT_LINETO :
00727 --ILength ; ++ITypes ;
00728 ScaleSrc( *IPoints++, P6 ) ;
00729 Transform( P6, T6 ) ;
00730 if ( !GenLine( P0,P6,T0,T6 ) ) return -1 ;
00731 P0.x = P6.x ; P0.y = P6.y ;
00732 T0.x = T6.x ; T0.y = T6.y ;
00733 break ;
00734 case PT_BEZIERTO :
00735 ILength -= 3 ; ITypes += 3 ;
00736 ScaleSrc( *IPoints++, C2 ) ;
00737 ScaleSrc( *IPoints++, C4 ) ;
00738 ScaleSrc( *IPoints++, P6 ) ;
00739 P2.x = (8*P0.x+12*C2.x+ 6*C4.x+ P6.x)/27 ;
00740 P2.y = (8*P0.y+12*C2.y+ 6*C4.y+ P6.y)/27 ;
00741 P4.x = ( P0.x+ 6*C2.x+12*C4.x+8*P6.x)/27 ;
00742 P4.y = ( P0.y+ 6*C2.y+12*C4.y+8*P6.y)/27 ;
00743 Transform( P2, T2 ) ;
00744 Transform( P4, T4 ) ;
00745 Transform( P6, T6 ) ;
00746 if ( !GenCurve( C2, C4, P0, P2, P4, P6, T0, T2, T4, T6 ) ) return -1 ;
00747 P0.x = P6.x ; P0.y = P6.y ;
00748 T0.x = T6.x ; T0.y = T6.y ;
00749 break ;
00750 default :
00751 return -1 ;
00752 }
00753 if ( *(ITypes-1) & PT_CLOSEFIGURE ||
00754 ( Close && ( ILength==0 || (*ITypes & PT_MOVETO) == PT_MOVETO ) ) )
00755 {
00756 if ( !GenLine( P0,SP,T0,ST ) ) return -1 ;
00757 *(OTypes-1) |= *(ITypes-1) & PT_CLOSEFIGURE ;
00758 }
00759 }
00760 if ( ILength )
00761 return -1 ;
00762 return pOLength-OLength ;
00763 }
00764
00766
00767 BOOL GEnvelope2x2::GenLine( DPOINT P0, DPOINT P6, DPOINT T0, DPOINT T6 )
00768 {
00769 BOOL F0 = !SmoothX && ((P0.x<0.5 && P6.x>0.5) || (P0.x>0.5 && P6.x<0.5)) ;
00770 BOOL F1 = !SmoothY && ((P0.y<0.5 && P6.y>0.5) || (P0.y>0.5 && P6.y<0.5)) ;
00771 if ( F0 || F1 )
00772 {
00773 DPOINT P1,P2,P3,P4,P5 ;
00774 DPOINT T1,T2,T3,T4,T5 ;
00775 P3.x=P3.y=0;
00776 if ( F0 )
00777 {
00778 P3.x = 0.5 ;
00779 P3.y = P0.y+(0.5-P0.x)*(P6.y-P0.y)/(P6.x-P0.x) ;
00780 }
00781 else if ( F1 )
00782 {
00783 P3.x = P0.x+(0.5-P0.y)*(P6.x-P0.x)/(P6.y-P0.y) ;
00784 P3.y = 0.5 ;
00785 }
00786 P1.x = (2*P0.x+P3.x)/3 ;
00787 P1.y = (2*P0.y+P3.y)/3 ;
00788 P2.x = (P0.x+2*P3.x)/3 ;
00789 P2.y = (P0.y+2*P3.y)/3 ;
00790 P4.x = (2*P3.x+P6.x)/3 ;
00791 P4.y = (2*P3.y+P6.y)/3 ;
00792 P5.x = (P3.x+2*P6.x)/3 ;
00793 P5.y = (P3.y+2*P6.y)/3 ;
00794 Transform( P1, T1 ) ;
00795 Transform( P2, T2 ) ;
00796 Transform( P3, T3 ) ;
00797 Transform( P4, T4 ) ;
00798 Transform( P5, T5 ) ;
00799 return GenCurve( P1, P2, P0, P1, P2, P3, T0, T1, T2, T3 ) &&
00800 GenCurve( P4, P5, P3, P4, P5, P6, T3, T4, T5, T6 ) ;
00801 }
00802 else
00803 {
00804 DPOINT P2,P4 ;
00805 DPOINT T2,T4 ;
00806 P2.x = (2*P0.x+P6.x)/3 ;
00807 P2.y = (2*P0.y+P6.y)/3 ;
00808 P4.x = (P0.x+2*P6.x)/3 ;
00809 P4.y = (P0.y+2*P6.y)/3 ;
00810 Transform( P2, T2 ) ;
00811 Transform( P4, T4 ) ;
00812 return GenCurve( P2, P4, P0, P2, P4, P6, T0, T2, T4, T6 ) ;
00813 }
00814 }
00815
00817
00818 void GEnvelope2x2::Transform( DPOINT a, DPOINT& b )
00819 {
00820 a.x *= 2.0 ;
00821 a.y *= 2.0 ;
00822 if ( a.y<1.0 )
00823 if ( a.x<1.0 )
00824 {
00825 b.x = A00.x+a.x*(B00.x+a.x*(E00.x+a.x*J00.x))
00826 +a.y*(C00.x+a.y*(F00.x+a.y*K00.x)
00827 +a.x*(D00.x+a.x*(G00.x+a.x*L00.x)
00828 +a.y*(H00.x+a.y*M00.x))) ;
00829 b.y = A00.y+a.x*(B00.y+a.x*(E00.y+a.x*J00.y))
00830 +a.y*(C00.y+a.y*(F00.y+a.y*K00.y)
00831 +a.x*(D00.y+a.x*(G00.y+a.x*L00.y)
00832 +a.y*(H00.y+a.y*M00.y))) ;
00833 }
00834 else
00835 {
00836 a.x-- ;
00837 b.x = A01.x+a.x*(B01.x+a.x*(E01.x+a.x*J01.x))
00838 +a.y*(C01.x+a.y*(F01.x+a.y*K01.x)
00839 +a.x*(D01.x+a.x*(G01.x+a.x*L01.x)
00840 +a.y*(H01.x+a.y*M01.x))) ;
00841 b.y = A01.y+a.x*(B01.y+a.x*(E01.y+a.x*J01.y))
00842 +a.y*(C01.y+a.y*(F01.y+a.y*K01.y)
00843 +a.x*(D01.y+a.x*(G01.y+a.x*L01.y)
00844 +a.y*(H01.y+a.y*M01.y))) ;
00845 }
00846 else
00847 {
00848 a.y-- ;
00849 if ( a.x<1.0 )
00850 {
00851 b.x = A10.x+a.x*(B10.x+a.x*(E10.x+a.x*J10.x))
00852 +a.y*(C10.x+a.y*(F10.x+a.y*K10.x)
00853 +a.x*(D10.x+a.x*(G10.x+a.x*L10.x)
00854 +a.y*(H10.x+a.y*M10.x))) ;
00855 b.y = A10.y+a.x*(B10.y+a.x*(E10.y+a.x*J10.y))
00856 +a.y*(C10.y+a.y*(F10.y+a.y*K10.y)
00857 +a.x*(D10.y+a.x*(G10.y+a.x*L10.y)
00858 +a.y*(H10.y+a.y*M10.y))) ;
00859 }
00860 else
00861 {
00862 a.x-- ;
00863 b.x = A11.x+a.x*(B11.x+a.x*(E11.x+a.x*J11.x))
00864 +a.y*(C11.x+a.y*(F11.x+a.y*K11.x)
00865 +a.x*(D11.x+a.x*(G11.x+a.x*L11.x)
00866 +a.y*(H11.x+a.y*M11.x))) ;
00867 b.y = A11.y+a.x*(B11.y+a.x*(E11.y+a.x*J11.y))
00868 +a.y*(C11.y+a.y*(F11.y+a.y*K11.y)
00869 +a.x*(D11.y+a.x*(G11.y+a.x*L11.y)
00870 +a.y*(H11.y+a.y*M11.y))) ;
00871 }
00872 }
00873 }
00874