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 #include "camtypes.h"
00104
00105 #include "tracergn.h"
00106
00107 #include "nodepath.h"
00108
00109
00110
00111
00112
00113
00114 #include "nodebmp.h"
00115 #include "bitmpinf.h"
00116 #include "chapter.h"
00117
00118 #include "page.h"
00119 #include "bfxtest.h"
00120 #include "bfxalu.h"
00121 #include "bfxpixop.h"
00122
00123
00124
00125
00126 DECLARE_SOURCE("$Revision: 1282 $");
00127
00128
00129
00130 CC_IMPLEMENT_DYNCREATE(TraceRegion, CCObject)
00131
00132
00133
00134 #define new CAM_DEBUG_NEW
00135
00136 #define MAXTANGENTPOINTS 10
00137
00138 #define MIN(a,b) (((a)<(b))?(a):(b))
00139 #define MAX(a,b) (((a)>(b))?(a):(b))
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 TraceRegion::TraceRegion()
00166 {
00167 pBfxPixelOp = NULL;
00168 BoundaryBuffer = NULL;
00169 BoundaryRingSize = 0;
00170 BoundaryRingMask =0;
00171 Bitmap = NULL;
00172 xsize = 1;
00173 ysize = 1;
00174 VirginBuffer = TRUE;
00175 AtCusp = FALSE;
00176 TailCusp = FALSE;
00177 TailDirection = -1;
00178 ThePath = NULL;
00179
00180 double TheError = 1.00;
00181 SetParams(&TheError);
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 Directions[0].Init( (1<<8), (0<<8));
00253 Directions[1].Init( (1<<8),-(1<<8));
00254 Directions[2].Init( (0<<8),-(1<<8));
00255 Directions[3].Init(-(1<<8),-(1<<8));
00256 Directions[4].Init(-(1<<8), (0<<8));
00257 Directions[5].Init(-(1<<8), (1<<8));
00258 Directions[6].Init( (0<<8), (1<<8));
00259 Directions[7].Init( (1<<8), (1<<8));
00260
00261
00262 DirectionPoint[0][0][0].Init( (1<<7), (1<<7));
00263 DirectionPoint[0][0][1].Init( -1, -1);
00264 DirectionPoint[0][0][2].Init( -1, -1);
00265 DirectionPoint[0][0][3].Init( -1, -1);
00266
00267 DirectionPoint[0][1][0].Init( (1<<7), (1<<7));
00268 DirectionPoint[0][1][1].Init( (1<<7),-(1<<7));
00269 DirectionPoint[0][1][2].Init( -1, -1);
00270 DirectionPoint[0][1][3].Init( -1, -1);
00271
00272 DirectionPoint[0][2][0].Init( (1<<7), (1<<7));
00273 DirectionPoint[0][2][1].Init( -1, 2);
00274 DirectionPoint[0][2][2].Init( -1, -1);
00275 DirectionPoint[0][2][3].Init( -1, -1);
00276
00277 DirectionPoint[0][3][0].Init( (1<<7), (1<<7));
00278 DirectionPoint[0][3][1].Init( -1, 3);
00279 DirectionPoint[0][3][2].Init( -1, -1);
00280 DirectionPoint[0][3][3].Init( -1, -1);
00281
00282 DirectionPoint[0][4][0].Init( (1<<7), (1<<7));
00283 DirectionPoint[0][4][1].Init( -1, 2);
00284 DirectionPoint[0][4][2].Init( -1, -1);
00285 DirectionPoint[0][4][3].Init( -1, -1);
00286
00287 DirectionPoint[0][5][0].Init( (1<<7), (1<<7));
00288 DirectionPoint[0][5][1].Init( (1<<7),-(1<<7));
00289 DirectionPoint[0][5][2].Init( -1, 5);
00290 DirectionPoint[0][5][3].Init( -1, -1);
00291
00292 DirectionPoint[0][6][0].Init( -1, 6);
00293 DirectionPoint[0][6][1].Init( -1, -1);
00294 DirectionPoint[0][6][2].Init( -1, -1);
00295 DirectionPoint[0][6][3].Init( -1, -1);
00296
00297 DirectionPoint[0][7][0].Init( (1<<7), (1<<7));
00298 DirectionPoint[0][7][1].Init( -1, -1);
00299 DirectionPoint[0][7][2].Init( -1, -1);
00300 DirectionPoint[0][7][3].Init( -1, -1);
00301
00302
00303
00304 DirectionPoint[1][0][0].Init( (1<<7), (1<<7));
00305 DirectionPoint[1][0][1].Init( -1, -1);
00306 DirectionPoint[1][0][2].Init( -1, -1);
00307 DirectionPoint[1][0][3].Init( -1, -1);
00308
00309 DirectionPoint[1][1][0].Init( (1<<7), (1<<7));
00310 DirectionPoint[1][1][1].Init( (1<<7),-(1<<7));
00311 DirectionPoint[1][1][2].Init( -1, -1);
00312 DirectionPoint[1][1][3].Init( -1, -1);
00313
00314 DirectionPoint[1][2][0].Init( (1<<7), (1<<7));
00315 DirectionPoint[1][2][1].Init( (1<<7),-(1<<7));
00316 DirectionPoint[1][2][2].Init( -1, -1);
00317 DirectionPoint[1][2][3].Init( -1, -1);
00318
00319 DirectionPoint[1][3][0].Init( (1<<7), (1<<7));
00320 DirectionPoint[1][3][1].Init( (1<<7), (0<<7));
00321 DirectionPoint[1][3][2].Init( -1, 3);
00322 DirectionPoint[1][3][3].Init( -1, -1);
00323
00324 DirectionPoint[1][4][0].Init( (1<<7), (1<<7));
00325 DirectionPoint[1][4][1].Init( (1<<7),-(1<<7));
00326 DirectionPoint[1][4][2].Init( -1, 4);
00327 DirectionPoint[1][4][3].Init( -1, -1);
00328
00329 DirectionPoint[1][5][0].Init( (1<<7), (1<<7));
00330 DirectionPoint[1][5][1].Init( (1<<7),-(1<<7));
00331 DirectionPoint[1][5][2].Init( -1, 5);
00332 DirectionPoint[1][5][3].Init( -1, -1);
00333
00334 DirectionPoint[1][6][0].Init( -1, 6);
00335 DirectionPoint[1][6][1].Init( -1, -1);
00336 DirectionPoint[1][6][2].Init( -1, -1);
00337 DirectionPoint[1][6][3].Init( -1, -1);
00338
00339 DirectionPoint[1][7][0].Init( (0<<7), (1<<7));
00340 DirectionPoint[1][7][1].Init( -1, 7);
00341 DirectionPoint[1][7][2].Init( -1, -1);
00342 DirectionPoint[1][7][3].Init( -1, -1);
00343
00344 INT32 i;
00345 INT32 j;
00346 INT32 k;
00347 for (i=2; i<=7; i+=1) for (j=0; j<=7; j++) for (k=0; k<=3; k++)
00348 {
00349
00350 INT32 j2 = (j-(i & 0x6)) & TR_NUMDIRECTIONMASK;
00351 DirectionPoint[i][j][k]=DirectionPoint[i & 0x1][j2][k];
00352
00353 if (DirectionPoint[i][j][k].x != -1)
00354 {
00355 DirectionPoint[i][j][k].RotateDirection(Directions[(i & 0x6)]);
00356 }
00357 else
00358 {
00359 if (DirectionPoint[i][j][k].y != -1)
00360 DirectionPoint[i][j][k].y = (((INT32)(DirectionPoint[(i & 0x1)][j2][k].y) + (i & 0x6)) & TR_NUMDIRECTIONMASK);
00361 }
00362 }
00363
00364 TraceBoundaryPoint Centre;
00365 Centre.Init((1<<7),(1<<7));
00366 for (i=0; i<=7; i+=1) for (j=0; j<=7; j++) for (k=0; k<=3; k++)
00367 {
00368 if (DirectionPoint[i][j][k].x != -1)
00369 {
00370 DirectionPoint[i][j][k].translate(Centre);
00371 }
00372 }
00373
00374 }
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393 BOOL TraceRegion::SetParams(double * pPixelError)
00394 {
00395 if (pPixelError) PixelError = *pPixelError;
00396 Error = PixelError;
00397 Error *= 256.0;
00398 Error *= Error;
00399
00400 return TRUE;
00401 }
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419 BOOL TraceRegion::GetParams(double * pPixelError)
00420 {
00421 if (pPixelError) *pPixelError = PixelError;
00422 return TRUE;
00423 }
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444 void TraceBoundaryPoint::RotateDirection(const TraceBoundaryPoint & rotation)
00445 {
00446
00447
00448 TraceBoundaryPoint temp;
00449 temp = *this;
00450
00451
00452
00453
00454
00455
00456 x = (temp.x * ((INT32)(rotation.x)>>8)) - (temp.y * ((INT32)(rotation.y)>>8));
00457 y = (temp.x * ((INT32)(rotation.y)>>8)) + (temp.y * ((INT32)(rotation.x)>>8));
00458 }
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 TraceBoundaryPoint TraceBoundaryPoint::SetLength( double NewLen )
00474 {
00475 TraceBoundaryPoint Result(x, y);
00476
00477 double Len = Length();
00478 if (Len != 0.0)
00479 {
00480 Result.x *= (NewLen / Len);
00481 Result.y *= (NewLen / Len);
00482 }
00483
00484 return Result;
00485 }
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505 TraceRegion::~TraceRegion()
00506 {
00507 if (BoundaryBuffer) CCFree(BoundaryBuffer);
00508
00509 BoundaryBuffer = NULL;
00510 Bitmap = NULL;
00511 ThePath = NULL;
00512 }
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538 BOOL TraceRegion::UseBitmap(KernelBitmap * pBitmap)
00539 {
00540 if (BoundaryBuffer)
00541 {
00542 CCFree(BoundaryBuffer);
00543 BoundaryBuffer = NULL;
00544 }
00545
00546 xsize=1;
00547 ysize=1;
00548 Bitmap = NULL;
00549
00550 if (pBitmap)
00551 {
00552 INT32 MaxDimension;
00553 BitmapInfo BMInfo;
00554 pBitmap->ActualBitmap->GetInfo(&BMInfo);
00555
00556
00557
00558 MaxDimension = ((BMInfo.PixelWidth>BMInfo.PixelHeight)?BMInfo.PixelWidth:BMInfo.PixelHeight)*8;
00559 ERROR2IF(MaxDimension<=0, FALSE, "Bitmap info structure is dead");
00560 BoundaryRingSize = 1;
00561
00562 if (MaxDimension<80) MaxDimension=80;
00563
00564
00565 while (BoundaryRingSize < MaxDimension) BoundaryRingSize = BoundaryRingSize<<1;
00566 BoundaryRingMask = BoundaryRingSize -1;
00567
00568
00569 if (NULL== (BoundaryBuffer=(TraceBoundaryPoint *)CCMalloc(sizeof(TraceBoundaryPoint) * BoundaryRingSize)) )
00570 return FALSE;
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582 xsize = BMInfo.PixelWidth;
00583 ysize = BMInfo.PixelHeight;
00584 Bitmap=pBitmap;
00585 VirginBuffer = TRUE;
00586 TailDirection = -1;
00587 BoundaryHead =0;
00588 BoundaryTail =0;
00589 TailDirection = 0;
00590 HeadDirection = 0;
00591 InitialDirection = 0;
00592 AtCusp = FALSE;
00593 TailCusp = FALSE;
00594 }
00595 return (TRUE);
00596 }
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615 BOOL TraceRegion::UsePath(Path * pPath)
00616 {
00617 ThePath = NULL;
00618 VirginPath = TRUE;
00619
00620 if (pPath)
00621 {
00622
00623 if (!pPath->ClearPath()) return FALSE;
00624 ThePath = pPath;
00625 }
00626 return (TRUE);
00627 }
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650 BOOL TraceRegion::FindInitialPoint(BOOL * End)
00651 {
00652 INT32 x;
00653 INT32 y;
00654
00655 ERROR2IF((!Bitmap),FALSE,"How about giving us a bitmap first then?");
00656
00657 InitialDirection = 0;
00658 VirginBuffer = TRUE;
00659 BoundaryHead =0;
00660 BoundaryTail =0;
00661 TailDirection = -1;
00662 HeadDirection = 0;
00663 AtCusp=FALSE;
00664 TailCusp = FALSE;
00665 *End = FALSE;
00666
00667 for (y = ysize-1; y>=0; y--) for (x = 0; x < xsize; x++) if (pBfxPixelOp->IsInRegion(x,y))
00668 {
00669 InitialPoint.x = x<<8;
00670 InitialPoint.y = y<<8;
00671 HeadPoint = InitialPoint;
00672 return (TRUE);
00673 }
00674
00675 *End = TRUE;
00676
00677 return(TRUE);
00678 }
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699 BOOL TraceRegion::TraceBoundary(DocCoord Origin,DocCoord Point1,DocCoord Point2)
00700 {
00701 BOOL Done;
00702 ERROR2IF((!Bitmap),FALSE,"How about giving us a bitmap first then?");
00703
00704
00705 if (!(FindInitialPoint(&Done))) return (FALSE);
00706 if (Done) return (TRUE);
00707
00708 do
00709 {
00710 if (!FillBoundaryBuffer(&Done)) return (FALSE);
00711 if (!ProcessBoundaryBuffer(Done)) return (FALSE);
00712 } while (!Done);
00713
00714 ThePath->CloseSubPath();
00715 ThePath->IsFilled = TRUE;
00716
00717 Matrix tMatrix(Div32By32(Point1.x-Origin.x,xsize<<8),Div32By32(Point2.x-Origin.x,xsize<<8),
00718 Div32By32(Point1.y-Origin.y,ysize<<8),Div32By32(Point2.y-Origin.y,ysize<<8),
00719 Origin.x,Origin.y);
00720 Trans2DMatrix Trans(tMatrix);
00721 Trans.Transform( (DocCoord*)ThePath->GetCoordArray(), ThePath->GetNumCoords() );
00722
00723 return (TRUE);
00724 }
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743 BOOL TraceRegion::Trace(INT32 InitialX, INT32 InitialY, BfxPixelOp * thepBfxPixelOp)
00744 {
00745 BOOL Done=FALSE;
00746 ERROR2IF((!Bitmap),FALSE,"How about giving us a bitmap first then?");
00747
00748 pBfxPixelOp = thepBfxPixelOp;
00749
00750 ERROR2IF( ((!pBfxPixelOp->IsInRegion(InitialX,InitialY))), FALSE, "Initial point not in region" );
00751
00752 BOOL Bottom=FALSE;
00753 while (!Bottom)
00754 {
00755 Bottom=TRUE;
00756 if (pBfxPixelOp->IsInRegion(InitialX-1,InitialY-1))
00757 {
00758 InitialY--;
00759 InitialX--;
00760 Bottom=FALSE;
00761 }
00762 if (pBfxPixelOp->IsInRegion(InitialX,InitialY-1))
00763 {
00764 InitialY--;
00765 Bottom=FALSE;
00766 }
00767 if (pBfxPixelOp->IsInRegion(InitialX-1,InitialY))
00768 {
00769 InitialX--;
00770 Bottom=FALSE;
00771 }
00772 }
00773
00774 InitialDirection = 4;
00775 VirginBuffer = TRUE;
00776 BoundaryHead =0;
00777 BoundaryTail =0;
00778 TailDirection = -1;
00779 HeadDirection = 4;
00780 AtCusp=FALSE;
00781 TailCusp = FALSE;
00782
00783 InitialPoint.x = InitialX<<8;
00784 InitialPoint.y = InitialY<<8;
00785 HeadPoint = FirstBufferPoint = InitialPoint;
00786
00787 do
00788 {
00789 if (!FillBoundaryBuffer(&Done)) return (FALSE);
00790 if (!VirginBuffer) { if (!ProcessBoundaryBuffer(Done)) return (FALSE); } else BoundaryHead=0;
00791 } while (!Done);
00792
00793 ERROR2IF(VirginPath, FALSE, "We've just traced a path that wasn't a path. Very odd");
00794
00795 ThePath->CloseSubPath();
00796 ThePath->IsFilled = TRUE;
00797
00798 return (TRUE);
00799 }
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824 BOOL TraceRegion::FillBoundaryBuffer(BOOL * End)
00825 {
00826 INT32 NewDirection;
00827 INT32 Turns;
00828
00829 ERROR2IF((!Bitmap),FALSE,"TraceRegion incorrectly initialised");
00830
00831 *End=FALSE;
00832 while (BoundaryHead<BoundaryRingSize - 6)
00833 {
00834
00835
00836
00837 NewDirection = (HeadDirection-(AtCusp?1:3)) & TR_NUMDIRECTIONMASK;
00838
00839 Turns=0;
00840 TraceBoundaryPoint NewPoint=HeadPoint;
00841
00842
00843 do
00844 {
00845
00846
00847 if ((Turns++)==8)
00848 {
00849 *End=TRUE;
00850
00851 NewDirection=((HeadDirection & 0x6) + 6) & TR_NUMDIRECTIONMASK;
00852 ERROR3("One pixel regions NYI");
00853
00854
00855 break;
00856 }
00857
00858 NewDirection = (NewDirection + 1) & TR_NUMDIRECTIONMASK;
00859 NewPoint = HeadPoint;
00860 NewPoint.translate(Directions[NewDirection]);
00861 } while (!pBfxPixelOp->IsInRegion(((INT32)(NewPoint.x))>>8, ((INT32)(NewPoint.y))>>8));
00862
00863 if (VirginBuffer) InitialDirection = TailDirection = NewDirection;
00864
00865
00866
00867
00868 INT32 HintPoint=0;
00869 if (!VirginBuffer)
00870 {
00871 if (AtCusp)
00872 {
00873
00874 while ((DirectionPoint[HeadDirection][NewDirection][HintPoint].x != -1)
00875 && (HintPoint<4)) {HintPoint++;}
00876 BoundaryBuffer[BoundaryHead] = HeadPoint;
00877 BoundaryBuffer[BoundaryHead++].translate(DirectionPoint[HeadDirection][NewDirection][HintPoint-1]);
00878
00879 }
00880 else
00881 {
00882
00883 while ((DirectionPoint[HeadDirection][NewDirection][HintPoint].x != -1)
00884 && (HintPoint<4))
00885 {
00886 BoundaryBuffer[BoundaryHead] = HeadPoint;
00887 BoundaryBuffer[BoundaryHead++].translate(DirectionPoint[HeadDirection][NewDirection][HintPoint++]);
00888 }
00889 }
00890 } else while ((DirectionPoint[HeadDirection][NewDirection][HintPoint].x != -1)
00891 && (HintPoint<4)) {HintPoint++;}
00892
00893
00894 if (DirectionPoint[HeadDirection][NewDirection][HintPoint].y !=-1)
00895 {
00896 HeadDirection = (INT32)(DirectionPoint[HeadDirection][NewDirection][HintPoint].y);
00897
00898 AtCusp = TRUE;
00899 if (TailDirection == -1) TailDirection = HeadDirection;
00900
00901 return (TRUE);
00902 }
00903
00904
00905
00906 AtCusp = FALSE;
00907
00908
00909
00910
00911 if ( (HeadPoint == InitialPoint) && (NewDirection == InitialDirection) && !VirginBuffer )
00912 {
00913 *End = TRUE;
00914 VirginBuffer = FALSE;
00915 return (TRUE);
00916 }
00917
00918 VirginBuffer = FALSE;
00919
00920 if (TailDirection == -1) TailDirection = NewDirection;
00921
00922
00923 HeadPoint = NewPoint;
00924 HeadDirection = NewDirection;
00925
00926 }
00927
00928 return(TRUE);
00929 }
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951 BOOL TraceRegion::ProcessBoundaryBuffer(BOOL Done)
00952 {
00953 BoundaryTail = 0;
00954
00955
00956 if (((BoundaryHead - BoundaryTail) & BoundaryRingMask) <=0 ) return TRUE;
00957
00958 if (VirginPath)
00959 {
00960 ThePath->FindStartOfPath();
00961 ThePath->InsertMoveTo(DocCoord((INT32)(BoundaryBuffer[BoundaryTail].x), (INT32)(BoundaryBuffer[BoundaryTail].y)));
00962 VirginPath = FALSE;
00963 FirstBufferPoint=BoundaryBuffer[BoundaryTail];
00964 }
00965
00966
00967 if (Done)
00968 {
00969 BoundaryBuffer[BoundaryHead-1]=FirstBufferPoint;
00970 if (BoundaryBuffer[BoundaryHead-2]==FirstBufferPoint) BoundaryHead=(BoundaryHead-1)&BoundaryRingMask;
00971 if (((BoundaryHead - BoundaryTail) & BoundaryRingMask) <=0 ) return TRUE;
00972 }
00973
00974 #if 0
00975 while (BoundaryTail != (BoundaryHead-1))
00976 {
00977 InsertLine(DocCoord((INT32)(BoundaryBuffer[BoundaryTail].x),(INT32)(BoundaryBuffer[BoundaryTail].y)),
00978 DocCoord((INT32)(BoundaryBuffer[BoundaryTail=(BoundaryTail + 1) & BoundaryRingMask].x),
00979 (INT32)(BoundaryBuffer[BoundaryTail].y)), TRUE, TRUE);
00980 }
00981 #else
00982
00983
00984 if (((BoundaryHead-1) & BoundaryRingMask)==BoundaryTail) return TRUE;
00985
00986
00987 TraceBoundaryPoint Tangent1 = LeftTangent(BoundaryTail,BoundaryHead-BoundaryTail);
00988 TraceBoundaryPoint Tangent2 = RightTangent(BoundaryHead-1,BoundaryHead-BoundaryTail);
00989
00990
00991 FitCubic(BoundaryTail, BoundaryHead-1, Tangent1, Tangent2, TailCusp, AtCusp);
00992 #endif
00993
00994 BoundaryBuffer[0]=BoundaryBuffer[BoundaryHead-1];
00995 BoundaryTail = 0;
00996 BoundaryHead = 1;
00997
00998 TailDirection = -1;
00999 TailCusp = AtCusp;
01000 return (TRUE);
01001 }
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029 void TraceRegion::FitCubic(INT32 FirstPoint, INT32 LastPoint, TraceBoundaryPoint Tangent1, TraceBoundaryPoint Tangent2,
01030 BOOL IsStartCusp, BOOL IsEndCusp)
01031 {
01032
01033 TraceBoundaryPoint Bezier[4];
01034 TraceBoundaryPoint CentTangent;
01035 INT32 NumPoints = LastPoint - FirstPoint + 1;
01036 INT32 SplitPoint, Split;
01037
01038
01039
01040 if (IsStartCusp) Tangent1 = LeftTangent(FirstPoint, NumPoints);
01041 if (IsEndCusp) Tangent2 = RightTangent(LastPoint, NumPoints);
01042
01043
01044
01045 if (NumPoints<2) return;
01046 #if 0
01047
01048 if ( NumPoints == 2 )
01049 {
01050 InsertLine( DocCoord((INT32)(BoundaryBuffer[FirstPoint].x), (INT32)(BoundaryBuffer[FirstPoint].y)),
01051 DocCoord((INT32)(BoundaryBuffer[LastPoint].x), (INT32)(BoundaryBuffer[FirstPoint].y)),
01052 IsStartCusp, IsEndCusp);
01053 return;
01054 }
01055 #endif
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111 #if 0
01112
01113 if (NumPoints == 3)
01114 {
01115 INT32 MidPoint = FirstPoint+1;
01116 double Bottom = 0.75 * (Tangent2.x * Tangent1.y - Tangent2.y * Tangent1.x);
01117 if (Abs(Bottom)>0.001)
01118 {
01119 TraceBoundaryPoint F = (BoundaryBuffer[FirstPoint]+BoundaryBuffer[LastPoint]-BoundaryBuffer[MidPoint]*2.0)/Bottom;
01120 double B = F.y * Tangent2.x - F.x * Tangent2.y;
01121 double C = F.x * Tangent1.y - F.y * Tangent1.x;
01122 if ((B<0.0) && (C<0.0))
01123 {
01124 Tangent1 = -(Tangent1 * B);
01125 Tangent2 = -(Tangent2 * C);
01126
01127 if ((Tangent1.SquaredLength()<(1<<14)) && (Tangent2.SquaredLength()<(1<<14)))
01128 {
01129 Bezier[0] = BoundaryBuffer[FirstPoint];
01130 Bezier[3] = BoundaryBuffer[LastPoint];
01131 Bezier[1] = BoundaryBuffer[FirstPoint] + Tangent1;
01132 Bezier[2] = BoundaryBuffer[LastPoint] + Tangent2;
01133 InsertBezier(Bezier, IsStartCusp, IsEndCusp);
01134 return;
01135 }
01136 }
01137 }
01138 }
01139 #endif
01140
01141
01142 if ( NumPoints <=2)
01143 {
01144
01145 INT32 Distance = (1<<8)*2/3;
01146
01147
01148 Bezier[0] = BoundaryBuffer[FirstPoint];
01149 Bezier[3] = BoundaryBuffer[LastPoint];
01150
01151
01152 Bezier[1] = Bezier[0] + Tangent1.SetLength(Distance);
01153 Bezier[2] = Bezier[3] + Tangent2.SetLength(Distance);
01154
01155
01156 InsertBezier(Bezier, IsStartCusp, IsEndCusp);
01157 return;
01158 }
01159
01160
01161 if (NumPoints ==3)
01162 {
01163 Split = FirstPoint + 1;
01164 }
01165 else
01166 {
01167
01168 Parameterize(FirstPoint, LastPoint);
01169
01170 GenerateBezier(FirstPoint, LastPoint, Tangent1, Tangent2, Bezier);
01171
01172 SplitPoint=NumTPoints-1;
01173 double MaxError = 0;
01174 if (!CalcMaxError(0, NumTPoints, Bezier, &SplitPoint, &MaxError, 0))
01175 {
01176
01177
01178 InsertBezier(Bezier, IsStartCusp, IsEndCusp);
01179 return;
01180 }
01181
01182 Split = TPoints[SplitPoint];
01183 }
01184
01185
01186
01187 CentTangent = CentreTangent(Split, MIN(Split-FirstPoint+1,LastPoint-Split+1));
01188
01189 FitCubic(FirstPoint, Split, Tangent1, CentTangent, IsStartCusp, FALSE);
01190
01191 CentTangent = -CentTangent;
01192
01193 FitCubic(Split, LastPoint, CentTangent, Tangent2, FALSE, IsEndCusp);
01194
01195 }
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215 void TraceRegion::Parameterize(INT32 FirstPoint, INT32 LastPoint)
01216 {
01217 INT32 pos, i;
01218
01219 INT32 NumPoints = LastPoint-FirstPoint;
01220
01221
01222 NumTPoints = MIN(NumPoints, FIT_STEPS);
01223
01224 for (pos=0; pos<=NumTPoints; pos++)
01225 {
01226 i = (INT32)(((double)pos/(double)NumTPoints*(double)(NumPoints))+0.5);
01227
01228 TValues[pos] = ((double)i)/((double)NumPoints);
01229 TPoints[pos] = (i+FirstPoint);
01230 }
01231
01232
01233 ERROR3IF(TPoints[0]!=FirstPoint,"TraceRegion::Parameterize fouled up first point");
01234 ERROR3IF(TPoints[NumTPoints]!=LastPoint,"TraceRegion::Parameterize fouled up last point");
01235 return;
01236 }
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261 void TraceRegion::GenerateBezier(INT32 FirstPoint, INT32 LastPoint, TraceBoundaryPoint Tangent1,
01262 TraceBoundaryPoint Tangent2, TraceBoundaryPoint* Bezier)
01263 {
01264 INT32 pos;
01265 INT32 i;
01266
01267
01268
01269 TraceBoundaryPoint A[FIT_STEPS+1][2];
01270
01271
01272 for (pos=0; pos<=NumTPoints; pos++)
01273 {
01274
01275 A[pos][0] = Tangent1.SetLength( Bezier1(TValues[pos]) );
01276 A[pos][1] = Tangent2.SetLength( Bezier2(TValues[pos]) );
01277 }
01278
01279
01280
01281
01282
01283 double C[2][2];
01284 double X[2];
01285
01286 C[0][0] = 0.0;
01287 C[0][1] = 0.0;
01288 C[1][0] = 0.0;
01289 C[1][1] = 0.0;
01290 X[0] = 0.0;
01291 X[1] = 0.0;
01292
01293 TraceBoundaryPoint FirstCoord = BoundaryBuffer[FirstPoint];
01294 TraceBoundaryPoint LastCoord = BoundaryBuffer[LastPoint];
01295 TraceBoundaryPoint ThisCoord, Combo;
01296
01297 for (pos=0; pos<=NumTPoints; pos++)
01298 {
01299 C[0][0] += A[pos][0].SquaredLength();
01300 C[0][1] += A[pos][0].Dot(A[pos][1]);
01301
01302 C[1][1] += A[pos][1].SquaredLength();
01303
01304
01305 ThisCoord = BoundaryBuffer[TPoints[pos]];
01306 Combo = ThisCoord - ((FirstCoord * Bezier0(TValues[pos]))
01307 + (FirstCoord * Bezier1(TValues[pos]))
01308 + (LastCoord * Bezier2(TValues[pos]))
01309 + (LastCoord * Bezier3(TValues[pos])));
01310
01311
01312 X[0] += A[pos][0].Dot( Combo );
01313 X[1] += A[pos][1].Dot( Combo );
01314
01315 }
01316
01317
01318 C[1][0] = C[0][1];
01319
01320
01321 double det_C0_C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1];
01322 double det_C0_X = C[0][0] * X[1] - C[0][1] * X[0];
01323 double det_X_C1 = X[0] * C[1][1] - X[1] * C[0][1];
01324
01325
01326 if (det_C0_C1 == 0.0)
01327 det_C0_C1 = (C[0][0] * C[1][1]) * 10e-12;
01328
01329 double AlphaLeft = det_X_C1 / det_C0_C1;
01330 double AlphaRight = det_C0_X / det_C0_C1;
01331
01332 Bezier[0] = BoundaryBuffer[FirstPoint];
01333 Bezier[3] = BoundaryBuffer[LastPoint];
01334
01335
01336
01337 if ( AlphaLeft < 0.0 || AlphaRight < 0.0)
01338 {
01339 INT32 Distance = ((LastPoint - FirstPoint)<<8) / 3;
01340
01341 Bezier[1] = Bezier[0] + Tangent1.SetLength(Distance);
01342 Bezier[2] = Bezier[3] + Tangent2.SetLength(Distance);
01343 }
01344 else
01345 {
01346 Bezier[1] = Bezier[0] + Tangent1.SetLength(AlphaLeft);
01347 Bezier[2] = Bezier[3] + Tangent2.SetLength(AlphaRight);
01348 }
01349
01350
01351 for (i = 0; i<=2; i++)
01352 {
01353 Q1[i]= (Bezier[i+1]-Bezier[i]) * 3.0;
01354 }
01355
01356
01357 for (i = 0; i<=1; i++)
01358 {
01359 Q2[i] = (Q1[i+1]-Q1[i]) * 2.0;
01360 }
01361
01362 }
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383 TraceBoundaryPoint TraceRegion::BezierPoint( TraceBoundaryPoint* Bez, double u)
01384 {
01385 double OneMinus = 1.0-u;
01386 double uSquared = u*u;
01387 double OneMinusSquared = OneMinus*OneMinus;
01388
01389 TraceBoundaryPoint Coord;
01390 Coord = Bez[0]*(OneMinusSquared*OneMinus);
01391 Coord = Coord + Bez[1]*(3.0*u*OneMinusSquared);
01392 Coord = Coord + Bez[2]*(3.0*uSquared*OneMinus);
01393 Coord = Coord + Bez[3]*(uSquared*u);
01394
01395 return Coord;
01396 }
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426 BOOL TraceRegion::CalcMaxError(INT32 LeftPoint, INT32 RightPoint, TraceBoundaryPoint* Bezier,
01427 INT32* SplitPoint, double * MaxDist, INT32 Level)
01428 {
01429 TraceBoundaryPoint Q_t, Q1_t, Q2_t;
01430 INT32 MidPoint = (LeftPoint + RightPoint+1)/2;
01431 double Distance;
01432
01433 if (!((MidPoint == LeftPoint) || (MidPoint==RightPoint)))
01434 {
01435
01436 for (INT32 iterations=1; iterations<=3; iterations++)
01437 {
01438 double t = TValues[MidPoint];
01439 TraceBoundaryPoint pt = BoundaryBuffer[TPoints[MidPoint]];
01440
01441
01442 Distance = (BezierPoint(Bezier, t) - pt).SquaredLength();
01443
01444 if ((Distance > *MaxDist) && (Distance < Error * 2.0))
01445
01446
01447 {
01448
01449
01450 double OneMinus = 1.0-t;
01451 double tSquared = t*t;
01452 double OneMinusSquared = OneMinus*OneMinus;
01453
01454 Q_t = Bezier[0] *(OneMinusSquared*OneMinus) + Bezier[1]*(3.0*t*OneMinusSquared)
01455 +Bezier[2] *(3.0*tSquared*OneMinus) + Bezier[3]*(tSquared*t);
01456 Q1_t = Q1[0]*(OneMinusSquared) + Q1[1]*(2.0*t*OneMinus) + Q1[2]*(tSquared);
01457 Q2_t = Q2[0]*(OneMinus) + Q2[1]*(t);
01458
01459
01460 TraceBoundaryPoint QtMinuspt = Q_t - pt;
01461
01462
01463
01464
01465 double denom = Q1_t.SquaredLength() + ((QtMinuspt.x) * (Q2_t.x) + (QtMinuspt.y) * (Q2_t.y));
01466 if (fabs(denom)<1e-50)
01467 denom = (denom<0) ? -1e-50 : 1e-50;
01468
01469 t = t - ( (QtMinuspt.x)*(Q1_t.x) + (QtMinuspt.y) * (Q1_t.y) ) / denom;
01470 if (t<0) t=0;
01471 if (t>1) t=1;
01472
01473 TValues[MidPoint] = t;
01474 }
01475 else break;
01476 }
01477
01478 if ( Distance >= *MaxDist)
01479 {
01480 *MaxDist = Distance;
01481 *SplitPoint = MidPoint;
01482 }
01483
01484
01485
01486 if ((*MaxDist<=Error) || (Level<3)) CalcMaxError(LeftPoint, MidPoint,
01487 Bezier, SplitPoint, MaxDist, Level+1);
01488 if ((*MaxDist<=Error) || (Level<3)) CalcMaxError(MidPoint, RightPoint,
01489 Bezier, SplitPoint, MaxDist, Level+1);
01490
01491 }
01492 return(*MaxDist>Error);
01493 }
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514 TraceBoundaryPoint TraceRegion::LeftTangent(INT32 Start, INT32 Points)
01515 {
01516 TraceBoundaryPoint Tangent(0,0);
01517
01518 Points = 1+MIN (Points/2,MAXTANGENTPOINTS);
01519 if (Points<2) Points=2;
01520
01521
01522 while ((Tangent.x==0) && (Tangent.y==0))
01523 {
01524 if ((--Points)>0)
01525 {
01526 Tangent.x = BoundaryBuffer[Start+Points].x - BoundaryBuffer[Start].x;
01527 Tangent.y = BoundaryBuffer[Start+Points].y - BoundaryBuffer[Start].y;
01528 }
01529 else
01530 {
01531 ERROR3("Tangent was a zero length vector in the curve fitter (Left)");
01532 Tangent.x = -1;
01533 }
01534 }
01535
01536 return Tangent;
01537 }
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554 TraceBoundaryPoint TraceRegion::RightTangent(INT32 End, INT32 Points)
01555 {
01556 TraceBoundaryPoint Tangent(0,0);
01557
01558 Points = 1+MIN (Points/2,MAXTANGENTPOINTS);
01559 if (Points<2) Points=2;
01560
01561
01562 while ((Tangent.x==0) && (Tangent.y==0))
01563 {
01564 if ((--Points)>0)
01565 {
01566 Tangent.x = BoundaryBuffer[End-Points].x - BoundaryBuffer[End].x;
01567 Tangent.y = BoundaryBuffer[End-Points].y - BoundaryBuffer[End].y;
01568 }
01569 else
01570 {
01571 ERROR3("Tangent was a zero length vector in the curve fitter (Right)");
01572 Tangent.x = -1;
01573 }
01574 }
01575
01576 return Tangent;
01577 }
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595 TraceBoundaryPoint TraceRegion::CentreTangent(INT32 Centre, INT32 Points)
01596 {
01597 TraceBoundaryPoint Left, Right;
01598 TraceBoundaryPoint Tangent(0,0);
01599
01600 Points = 1+MIN (Points/2,MAXTANGENTPOINTS);
01601 if (Points<2) Points=2;
01602
01603
01604 while ((Tangent.x==0) && (Tangent.y==0))
01605 {
01606 if ((--Points)>0)
01607 {
01608
01609 Left.x = BoundaryBuffer[Centre-Points].x - BoundaryBuffer[Centre].x;
01610 Left.y = BoundaryBuffer[Centre-Points].y - BoundaryBuffer[Centre].y;
01611
01612
01613 Right.x = BoundaryBuffer[Centre].x - BoundaryBuffer[Centre+Points].x;
01614 Right.y = BoundaryBuffer[Centre].y - BoundaryBuffer[Centre+Points].y;
01615
01616
01617 Tangent.x = (Left.x + Right.x) / 2;
01618 Tangent.y = (Left.y + Right.y) / 2;
01619
01620 }
01621 else
01622 {
01623 ERROR3("Tangent was a zero length vector in the curve fitter (Centre)");
01624 Tangent.x = -1;
01625 }
01626 }
01627
01628 return Tangent;
01629 }
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648 void TraceRegion::InsertBezier(TraceBoundaryPoint* Bezier, BOOL IsStartCusp, BOOL IsEndCusp)
01649 {
01650
01651 PathFlags Flags;
01652 Flags.IsSelected = FALSE;
01653 Flags.IsSmooth = FALSE;
01654 Flags.IsRotate = TRUE;
01655
01656
01657 ThePath->InsertCurveTo( DocCoord( (INT32)Bezier[1].x, (INT32)Bezier[1].y),
01658 DocCoord( (INT32)Bezier[2].x, (INT32)Bezier[2].y),
01659 DocCoord( (INT32)Bezier[3].x, (INT32)Bezier[3].y), &Flags);
01660
01661
01662 if (IsStartCusp || IsEndCusp)
01663 {
01664
01665 PathFlags* AllFlags = ThePath->GetFlagArray();
01666 INT32 NumCoords = ThePath->GetNumCoords();
01667
01668 if (IsStartCusp)
01669 {
01670
01671 AllFlags[NumCoords-3].IsRotate = FALSE;
01672 }
01673
01674 if (IsEndCusp)
01675 {
01676
01677 AllFlags[NumCoords-2].IsRotate = FALSE;
01678 AllFlags[NumCoords-1].IsRotate = FALSE;
01679 }
01680 }
01681 }
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706 void TraceRegion::InsertLine(const DocCoord& Start, const DocCoord& End,
01707 BOOL IsStartCusp, BOOL IsEndCusp)
01708 {
01709
01710 PathFlags Flags;
01711 Flags.IsSelected = FALSE;
01712 Flags.IsSmooth = FALSE;
01713 Flags.IsRotate = TRUE;
01714
01715
01716 DocCoord StartPos;
01717 DocCoord EndPos;
01718
01719 StartPos.x = (2 * Start.x + End.x) /3;
01720 StartPos.y = (2 * Start.y + End.y) /3;
01721 EndPos.x = (Start.x + 2 * End.x) /3;
01722 EndPos.y = (Start.y + 2 * End.y) /3;
01723
01724
01725 ThePath->InsertCurveTo( (DocCoord) StartPos, (DocCoord) EndPos, (DocCoord) End, &Flags);
01726
01727
01728 PathVerb * AllVerbs = ThePath->GetVerbArray();
01729 PathFlags* AllFlags = ThePath->GetFlagArray();
01730 INT32 NumCoords = ThePath->GetNumCoords();
01731 ERROR3IF(NumCoords<4,"No initial moveto ?!");
01732
01733 AllFlags[NumCoords-1].IsRotate = !IsEndCusp;
01734 AllFlags[NumCoords-2].IsRotate = !IsEndCusp;
01735
01736 if (AllVerbs[NumCoords-4] == PT_MOVETO)
01737 {
01738 AllFlags[NumCoords-3].IsRotate = FALSE;
01739 AllFlags[NumCoords-4].IsRotate = FALSE;
01740 }
01741 else
01742 {
01743
01744
01745 AllFlags[NumCoords-3].IsRotate = !IsStartCusp;
01746 AllFlags[NumCoords-4].IsRotate = !IsStartCusp;
01747
01748
01749 }
01750
01751 }
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770 void TraceRegion::InsertStraightLine(const DocCoord& End)
01771 {
01772
01773 PathFlags Flags;
01774 Flags.IsSelected = FALSE;
01775 Flags.IsRotate = FALSE;
01776 Flags.IsSmooth = FALSE;
01777
01778
01779 ThePath->InsertLineTo((DocCoord) End, &Flags);
01780 }
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802 void TraceRegion::Test(UndoableOperation * Op)
01803 {
01804
01805 BOOL CarryOn=TRUE;
01806 Range Sel(*(GetApplication()->FindSelection()));
01807
01808 Node* FirstSelectedNode = Sel.FindFirst();
01809 if (FirstSelectedNode != NULL)
01810 {
01811 Node* CurrentNode = FirstSelectedNode;
01812 Node* NextCurrent;
01813
01814
01815 while ((CurrentNode != NULL) && CarryOn)
01816 {
01817 NextCurrent = Sel.FindNext(CurrentNode);
01818 if ( (CurrentNode->IsSelected()) && (CurrentNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeBitmap)) )
01819 {
01820 KernelBitmap * pBitmap = ((NodeBitmap *)(CurrentNode))->GetBitmap();
01821 BitmapInfo BMInfo;
01822 UINT32 bpp;
01823 pBitmap->ActualBitmap->GetInfo(&BMInfo);
01824 bpp=BMInfo.PixelDepth;
01825
01826 TRACEUSER( "Alex", _T("Bitmap found %d bpp\n"),bpp);
01827
01828 if ((bpp==32) || TRUE)
01829 {
01830 CarryOn = FALSE;
01831
01832
01833
01834
01835 Spread *pSpread;
01836 DocCoord Origin;
01837
01838
01839 Node *pNode = (Document::GetSelected())->GetFirstNode()->FindNext()->FindFirstChild();
01840 while ((pNode != NULL) && (!pNode->IsKindOf(CC_RUNTIME_CLASS(Chapter))))
01841 pNode = pNode->FindNext();
01842
01843 ENSURE(pNode->IsKindOf(CC_RUNTIME_CLASS(Chapter)),
01844 "Filter::GetFirstSpread(): Could not find Chapter");
01845 Chapter *pChapter = (Chapter *) pNode;
01846
01847
01848 pSpread = (Spread *) pChapter->FindFirstChild();
01849 ENSURE(pSpread->IsKindOf(CC_RUNTIME_CLASS(Spread)),
01850 "Filter::GetFirstSpread(): Could not find Spread");
01851
01852 Page *pPage = (Page *) pSpread->FindFirstPageInSpread();
01853 ENSURE(pPage->IsKindOf(CC_RUNTIME_CLASS(Page)),
01854 "BaseBitmapFilter::DoImport(): Could not find first Page");
01855
01856
01857 DocRect PageRect = pPage->GetPageRect();
01858 Origin = PageRect.lo;
01859
01860 NodePath * pNewNode;
01861 pNewNode = new NodePath;
01862
01863 TraceRegion TR;
01864
01865
01866
01867 TR.UseBitmap(pBitmap);
01868 TR.UsePath(&(pNewNode->InkPath));
01869 TR.TraceBoundary(((NodeBitmap * )CurrentNode)->Parallel[3],
01870 ((NodeBitmap * )CurrentNode)->Parallel[2],
01871 ((NodeBitmap * )CurrentNode)->Parallel[0]);
01872
01873
01874 if (!Op->DoInsertNewNode(pNewNode, pSpread, FALSE))
01875 {
01876
01877 delete pNewNode;
01878 return;
01879 }
01880
01881
01882 Op->DoInvalidateNodeRegion(pNewNode, TRUE, FALSE);
01883
01884 }
01885 }
01886 CurrentNode = NextCurrent;
01887 }
01888
01889 }
01890
01891
01892
01893 return;
01894 }