1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-22 01:02:17 -05:00

Added few TPA functions (OffsetTPA,OffsetATPA,FloodFillTPA,CopyTPA,CopyATPA).. Changed most of the Array parameters to be Consts (this saves the need of copying the whole array just to pass it to the method). Changed the debug image borders back to toolwin.. Added constants MaxInt/MaxLongInt

This commit is contained in:
Raymond 2010-05-08 03:20:26 +02:00
parent 4dc83e9397
commit 1575c1ec11
7 changed files with 332 additions and 155 deletions

View File

@ -4,7 +4,7 @@ object DebugImgForm: TDebugImgForm
Top = 278 Top = 278
Width = 400 Width = 400
BorderIcons = [biSystemMenu, biMinimize] BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle BorderStyle = bsToolWindow
Caption = 'DebugImgForm' Caption = 'DebugImgForm'
ClientHeight = 300 ClientHeight = 300
ClientWidth = 400 ClientWidth = 400

View File

@ -28,12 +28,12 @@ begin
RAaSTPA(a,dist); RAaSTPA(a,dist);
end; end;
function ps_NearbyPointInArrayEx(const P: TPoint; w, h:Integer; a: TPointArray): Boolean;extdecl; function ps_NearbyPointInArrayEx(const P: TPoint; w, h:Integer;const a: TPointArray): Boolean;extdecl;
begin begin
result := NearbyPointInArrayEx(p,w,h,a); result := NearbyPointInArrayEx(p,w,h,a);
end; end;
function ps_NearbyPointInArray(const P: TPoint; Dist:Integer; a: TPointArray): Boolean; extdecl; function ps_NearbyPointInArray(const P: TPoint; Dist:Integer;const a: TPointArray): Boolean; extdecl;
begin begin
result := NearbyPointInArray(p,dist,a); result := NearbyPointInArray(p,dist,a);
end; end;
@ -73,12 +73,12 @@ begin
InvertATPA(a); InvertATPA(a);
end; end;
function ps_MiddleTPAEx(TPA: TPointArray; var x, y: Integer): Boolean; extdecl; function ps_MiddleTPAEx(const TPA: TPointArray; var x, y: Integer): Boolean; extdecl;
begin begin
Result := MiddleTPAEx(tpa,x,y); Result := MiddleTPAEx(tpa,x,y);
end; end;
function ps_MiddleTPA(tpa: TPointArray): TPoint; extdecl; function ps_MiddleTPA(const tpa: TPointArray): TPoint; extdecl;
begin begin
result := MiddleTPA(tpa); result := MiddleTPA(tpa);
end; end;
@ -93,12 +93,12 @@ begin
SortATPAFromSize(a,size,closefirst); SortATPAFromSize(a,size,closefirst);
end; end;
function ps_InIntArrayEx(a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean;extdecl; function ps_InIntArrayEx(const a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean;extdecl;
begin begin
result := InIntArrayEx(a,where,number); result := InIntArrayEx(a,where,number);
end; end;
function ps_InIntArray(a: TIntegerArray; Number: Integer): Boolean; extdecl; function ps_InIntArray(const a: TIntegerArray; Number: Integer): Boolean; extdecl;
begin begin
result := InIntArray(a,number); result := InIntArray(a,number);
end; end;
@ -113,42 +113,47 @@ begin
ClearSameIntegersAndTPA(a,p); ClearSameIntegersAndTPA(a,p);
end; end;
function ps_SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray; extdecl; function ps_SplitTPAEx(const arr: TPointArray; w, h: Integer): T2DPointArray; extdecl;
begin begin
result := SplitTPAEx(arr,w,h); result := SplitTPAEx(arr,w,h);
end; end;
function ps_SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray; extdecl; function ps_SplitTPA(const arr: TPointArray; Dist: Integer): T2DPointArray; extdecl;
begin begin
result := SplitTPA(arr,dist); result := SplitTPA(arr,dist);
end; end;
function ps_FloodFillTPA(const TPA : TPointArray) : T2DPointArray; extdecl;
begin
result := FloodFillTPA(TPA);
end;
procedure ps_FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer);extdecl; procedure ps_FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer);extdecl;
begin begin
FilterPointsPie(points,sd,ed,minr,maxr,mx,my); FilterPointsPie(points,sd,ed,minr,maxr,mx,my);
end; end;
function ps_GetATPABounds(ATPA: T2DPointArray): TBox;extdecl; function ps_GetATPABounds(const ATPA: T2DPointArray): TBox;extdecl;
begin begin
result := GetATPABounds(ATPA); result := GetATPABounds(ATPA);
end; end;
function ps_GetTPABounds(TPA: TPointArray): TBox; extdecl; function ps_GetTPABounds(const TPA: TPointArray): TBox; extdecl;
begin begin
result := GetTPABounds(TPA); result := GetTPABounds(TPA);
end; end;
function ps_FindTPAinTPA(SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean; extdecl; function ps_FindTPAinTPA(const SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean; extdecl;
begin begin
Result := FindTPAinTPA(searchTPA,totaltpa,matches); Result := FindTPAinTPA(searchTPA,totaltpa,matches);
end; end;
function ps_GetSamePointsATPA( ATPA : T2DPointArray; var Matches : TPointArray) : boolean;extdecl; function ps_GetSamePointsATPA(const ATPA : T2DPointArray; var Matches : TPointArray) : boolean;extdecl;
begin begin
result := GetSamePointsATPA(ATPA,Matches); result := GetSamePointsATPA(ATPA,Matches);
end; end;
function ps_FindTextTPAinTPA(Height : integer; SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;extdecl; function ps_FindTextTPAinTPA(Height : integer;const SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;extdecl;
begin begin
result := FindTextTPAinTPA(height,searchtpa,totaltpa,matches); result := FindTextTPAinTPA(height,searchtpa,totaltpa,matches);
end; end;
@ -168,47 +173,47 @@ begin
result := RotatePoint(p,angle,mx,my); result := RotatePoint(p,angle,mx,my);
end; end;
function ps_FindGapsTPA(TPA: TPointArray; MinPixels: Integer): T2DPointArray; extdecl; function ps_FindGapsTPA(const TPA: TPointArray; MinPixels: Integer): T2DPointArray; extdecl;
begin begin
result := FindGapsTPA(TPA,minpixels); result := FindGapsTPA(TPA,minpixels);
end; end;
function ps_RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray; extdecl; function ps_RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray; extdecl;
begin begin
Result := RemoveDistTPointArray(x,y,dist,thepoints,removehigher); Result := RemoveDistTPointArray(x,y,dist,thepoints,removehigher);
end; end;
function ps_CombineTPA(Ar1, Ar2: TPointArray): TPointArray; extdecl; function ps_CombineTPA(const Ar1, Ar2: TPointArray): TPointArray; extdecl;
begin begin
result := CombineTPA(ar1,ar2); result := CombineTPA(ar1,ar2);
end; end;
function ps_ReArrangeandShortenArrayEx(a: TPointArray; w, h: Integer): TPointArray;extdecl; function ps_ReArrangeandShortenArrayEx(const a: TPointArray; w, h: Integer): TPointArray;extdecl;
begin begin
result := ReArrangeandShortenArrayEx(a,w,h); result := ReArrangeandShortenArrayEx(a,w,h);
end; end;
function ps_ReArrangeandShortenArray(a: TPointArray; Dist: Integer): TPointArray; extdecl; function ps_ReArrangeandShortenArray(const a: TPointArray; Dist: Integer): TPointArray; extdecl;
begin begin
result := ReArrangeandShortenArray(a,dist); result := ReArrangeandShortenArray(a,dist);
end; end;
function ps_TPAtoATPAEx(TPA: TPointArray; w, h: Integer): T2DPointArray; extdecl; function ps_TPAtoATPAEx(const TPA: TPointArray; w, h: Integer): T2DPointArray; extdecl;
begin begin
result := TPAtoATPAEx(tpa,w,h); result := TPAtoATPAEx(tpa,w,h);
end; end;
function ps_TPAtoATPA(TPA: TPointArray; Dist: Integer): T2DPointArray;extdecl; function ps_TPAtoATPA(const TPA: TPointArray; Dist: Integer): T2DPointArray;extdecl;
begin begin
Result := TPAtoATPA(tpa,dist); Result := TPAtoATPA(tpa,dist);
end; end;
function ps_CombineIntArray(Ar1, Ar2: TIntegerArray): TIntegerArray; extdecl; function ps_CombineIntArray(const Ar1, Ar2: TIntegerArray): TIntegerArray; extdecl;
begin begin
result := CombineIntArray(ar1,ar2); result := CombineIntArray(ar1,ar2);
end; end;
function ps_MergeATPA(ATPA : T2DPointArray) : TPointArray; extdecl; function ps_MergeATPA(const ATPA : T2DPointArray) : TPointArray; extdecl;
begin begin
result := MergeATPA(ATPA); result := MergeATPA(ATPA);
end; end;
@ -223,12 +228,12 @@ begin
Result := RotatePoints(p,a,cx,cy); Result := RotatePoints(p,a,cx,cy);
end; end;
function ps_FindTPAEdges(p: TPointArray): TPointArray;extdecl; function ps_FindTPAEdges(const p: TPointArray): TPointArray;extdecl;
begin begin
result := FindTPAEdges(p); result := FindTPAEdges(p);
end; end;
function ps_ClearTPAFromTPA(arP, ClearPoints: TPointArray): TPointArray; extdecl; function ps_ClearTPAFromTPA(const arP, ClearPoints: TPointArray): TPointArray; extdecl;
begin begin
result := ClearTPAFromTPA(arP,ClearPoints); result := ClearTPAFromTPA(arP,ClearPoints);
end; end;
@ -238,7 +243,7 @@ begin
result := ReturnPointsNotInTPA(totaltpa,box); result := ReturnPointsNotInTPA(totaltpa,box);
end; end;
function ps_PointInTPA(p: TPoint; arP: TPointArray): Boolean; extdecl; function ps_PointInTPA(p: TPoint;const arP: TPointArray): Boolean; extdecl;
begin begin
result := PointInTPA(p,arp); result := PointInTPA(p,arp);
end; end;
@ -263,64 +268,64 @@ begin
InvertTIA(ti); InvertTIA(ti);
end; end;
function ps_SumIntegerArray(Ints : TIntegerArray): Integer; extdecl; function ps_SumIntegerArray(const Ints : TIntegerArray): Integer; extdecl;
begin begin
result := SumIntegerArray(ints); result := SumIntegerArray(ints);
end; end;
function ps_AverageTIA(tI: TIntegerArray): Integer; extdecl; function ps_AverageTIA(const tI: TIntegerArray): Integer; extdecl;
begin begin
result := AverageTIA(ti); result := AverageTIA(ti);
end; end;
function ps_AverageExtended(tE: TExtendedArray): Extended; extdecl; function ps_AverageExtended(const tE: TExtendedArray): Extended; extdecl;
begin begin
result := AverageExtended(te); result := AverageExtended(te);
end; end;
procedure ps_SplitTPAExWrap(arr: TPointArray; w, h: Integer; var res : T2DPointArray);extdecl; procedure ps_SplitTPAExWrap(const arr: TPointArray; w, h: Integer; var res : T2DPointArray);extdecl;
begin begin
res := SplitTPAEx(arr,w,h); res := SplitTPAEx(arr,w,h);
end; end;
procedure ps_SplitTPAWrap(arr: TPointArray; Dist: Integer; var res: T2DPointArray);extdecl; procedure ps_SplitTPAWrap(const arr: TPointArray; Dist: Integer; var res: T2DPointArray);extdecl;
begin begin
res := SplitTPA(arr,dist); res := SplitTPA(arr,dist);
end; end;
procedure ps_FindGapsTPAWrap(TPA: TPointArray; MinPixels: Integer; var Res : T2DPointArray); extdecl; procedure ps_FindGapsTPAWrap(const TPA: TPointArray; MinPixels: Integer; var Res : T2DPointArray); extdecl;
begin begin
Res := FindGapsTPA(TPA,MinPixels); Res := FindGapsTPA(TPA,MinPixels);
end; end;
procedure ps_RemoveDistTPointArrayWrap(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean; var Res : TPointArray);extdecl; procedure ps_RemoveDistTPointArrayWrap(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean; var Res : TPointArray);extdecl;
begin begin
Res := RemoveDistTPointArray(x,y,dist,thepoints,removehigher); Res := RemoveDistTPointArray(x,y,dist,thepoints,removehigher);
end; end;
procedure ps_CombineTPAWrap(Ar1, Ar2: TPointArray; var Res : TPointArray);extdecl; procedure ps_CombineTPAWrap(const Ar1, Ar2: TPointArray; var Res : TPointArray);extdecl;
begin begin
Res := CombineTPA(Ar1,Ar2); Res := CombineTPA(Ar1,Ar2);
end; end;
procedure ps_ReArrangeandShortenArrayExWrap(a: TPointArray; w, h: Integer; var Res : TPointArray);extdecl; procedure ps_ReArrangeandShortenArrayExWrap(const a: TPointArray; w, h: Integer; var Res : TPointArray);extdecl;
begin begin
Res := ReArrangeandShortenArrayEx(a,w,h); Res := ReArrangeandShortenArrayEx(a,w,h);
end; end;
procedure ps_ReArrangeandShortenArrayWrap(a: TPointArray; Dist: Integer; var Res : TPointArray);extdecl; procedure ps_ReArrangeandShortenArrayWrap(const a: TPointArray; Dist: Integer; var Res : TPointArray);extdecl;
begin begin
Res := ReArrangeandShortenArray(a,dist); Res := ReArrangeandShortenArray(a,dist);
end; end;
procedure ps_TPAtoATPAExWrap(TPA: TPointArray; w, h: Integer; var Res : T2DPointArray);extdecl; procedure ps_TPAtoATPAExWrap(const TPA: TPointArray; w, h: Integer; var Res : T2DPointArray);extdecl;
begin begin
Res := TPAtoATPAEx(TPA,w,h); Res := TPAtoATPAEx(TPA,w,h);
end; end;
procedure ps_TPAtoATPAWrap(TPA: TPointArray; Dist: Integer; var Res : T2DPointArray);extdecl; procedure ps_TPAtoATPAWrap(const TPA: TPointArray; Dist: Integer; var Res : T2DPointArray);extdecl;
begin begin
Res := TPAtoATPA(TPA,Dist); Res := TPAtoATPA(TPA,Dist);
end; end;
procedure ps_CombineIntArrayWrap(Ar1, Ar2: TIntegerArray; var Res : TIntegerArray);extdecl; procedure ps_CombineIntArrayWrap(const Ar1, Ar2: TIntegerArray; var Res : TIntegerArray);extdecl;
begin begin
Res := CombineIntArray(Ar1,Ar2); Res := CombineIntArray(Ar1,Ar2);
end; end;
procedure ps_MergeATPAWrap(ATPA : T2DPointArray; var Res: TPointArray); extdecl; procedure ps_MergeATPAWrap(const ATPA : T2DPointArray; var Res: TPointArray); extdecl;
begin begin
Res := MergeATPA(ATPA); Res := MergeATPA(ATPA);
end; end;
@ -332,11 +337,11 @@ procedure ps_RotatePointsWrap(Const P: TPointArray; A, cx, cy: Extended; var Res
begin begin
Res := RotatePoints(P,a,cx,cy); Res := RotatePoints(P,a,cx,cy);
end; end;
procedure ps_FindTPAEdgesWrap(p: TPointArray; var Res : TPointArray);extdecl; procedure ps_FindTPAEdgesWrap(const p: TPointArray; var Res : TPointArray);extdecl;
begin begin
Res := FindTPAEdges(p); Res := FindTPAEdges(p);
end; end;
procedure ps_ClearTPAFromTPAWrap(arP, ClearPoints: TPointArray; var Res : TPointArray);extdecl; procedure ps_ClearTPAFromTPAWrap(const arP, ClearPoints: TPointArray; var Res : TPointArray);extdecl;
begin begin
Res := ClearTPAFromTPA(arP, clearpoints); Res := ClearTPAFromTPA(arP, clearpoints);
end; end;
@ -350,12 +355,35 @@ begin
FilterPointsLine(points,radial,radius,mx,my); FilterPointsLine(points,radial,radius,mx,my);
end; end;
function ps_SameTPA(aTPA, bTPA: TPointArray): Boolean;extdecl; function ps_SameTPA(const aTPA, bTPA: TPointArray): Boolean;extdecl;
begin begin
result := SameTPA(atpa,btpa); result := SameTPA(atpa,btpa);
end; end;
function ps_TPAInATPA(TPA: TPointArray; InATPA: T2DPointArray; var Index: LongInt): Boolean;extdecl; function ps_TPAInATPA(const TPA: TPointArray;const InATPA: T2DPointArray; var Index: LongInt): Boolean;extdecl;
begin begin
result := TPAInATPA(tpa,inatpa,index); result := TPAInATPA(tpa,inatpa,index);
end; end;
procedure ps_OffsetTPA(var TPA : TPointArray; const Offset : TPoint); extdecl;
begin
OffsetTPA(TPA,offset);
end;
procedure ps_OffsetATPA(var ATPA : T2DPointArray; const Offset : TPoint);extdecl;
begin
OffsetATPA(atpa,offset);
end;
function ps_CopyTPA(const TPA : TPointArray) : TPointArray;extdecl;
begin
result := Copy(TPA,0,Length(TPA));
end;
function ps_CopyATPA(const ATPA : T2DPointArray) : T2DPointArray; extdecl;
var
i,l : integer;
begin
l := high(ATPA);
SetLength(result,l+1);
for i := 0 to l do
result[i] := copy(ATPA[i],0,Length(ATPA[i]));
end;

View File

@ -26,6 +26,8 @@ x.AddConstantN('ScriptPath','string').SetString(Self.ScriptPath);
x.AddConstantN('IncludePath','string').SetString(Self.IncludePath); x.AddConstantN('IncludePath','string').SetString(Self.IncludePath);
x.AddConstantN('PluginPath','string').SetString(Self.PluginPath); x.AddConstantN('PluginPath','string').SetString(Self.PluginPath);
x.AddConstantN('FontPath','string').SetString(Self.FontPath); x.AddConstantN('FontPath','string').SetString(Self.FontPath);
x.AddConstantN('MaxLongInt','integer').SetInt(maxLongint);
x.AddConstantN('MaxInt','integer').SetInt(maxLongint);
x.AddTypeS('TReplaceFlag', '(rfReplaceAll, rfIgnoreCase)'); x.AddTypeS('TReplaceFlag', '(rfReplaceAll, rfIgnoreCase)');
x.AddTypeS('TReplaceFlags','set of TReplaceFlag'); x.AddTypeS('TReplaceFlags','set of TReplaceFlag');
x.AddTypeS('StrExtr','(Numbers, Letters, Others);'); x.AddTypeS('StrExtr','(Numbers, Letters, Others);');

View File

@ -318,8 +318,8 @@ AddFunction(@ps_tpaSwap,'procedure tpaSwap(var a, b: TPointArray);');
AddFunction(@ps_SwapE,'procedure SwapE(var a, b: Extended);'); AddFunction(@ps_SwapE,'procedure SwapE(var a, b: Extended);');
AddFunction(@ps_RAaSTPAEx,'procedure RAaSTPAEx(var a: TPointArray; const w, h: Integer);'); AddFunction(@ps_RAaSTPAEx,'procedure RAaSTPAEx(var a: TPointArray; const w, h: Integer);');
AddFunction(@ps_RAaSTPA,'procedure RAaSTPA(var a: TPointArray; const Dist: Integer);'); AddFunction(@ps_RAaSTPA,'procedure RAaSTPA(var a: TPointArray; const Dist: Integer);');
AddFunction(@ps_NearbyPointInArrayEx,'function NearbyPointInArrayEx(const P: TPoint; w, h:Integer; a: TPointArray): Boolean;'); AddFunction(@ps_NearbyPointInArrayEx,'function NearbyPointInArrayEx(const P: TPoint; w, h:Integer;const a: TPointArray): Boolean;');
AddFunction(@ps_NearbyPointInArray,'function NearbyPointInArray(const P: TPoint; Dist:Integer; a: TPointArray): Boolean;'); AddFunction(@ps_NearbyPointInArray,'function NearbyPointInArray(const P: TPoint; Dist:Integer;const a: TPointArray): Boolean;');
AddFunction(@ps_QuickTPASort,'procedure QuickTPASort(var A: TIntegerArray; var B: TPointArray; iLo, iHi: Integer; SortUp: Boolean);'); AddFunction(@ps_QuickTPASort,'procedure QuickTPASort(var A: TIntegerArray; var B: TPointArray; iLo, iHi: Integer; SortUp: Boolean);');
AddFunction(@ps_QuickATPASort,'procedure QuickATPASort(var A: TIntegerArray; var B: T2DPointArray; iLo, iHi: Integer; SortUp: Boolean);'); AddFunction(@ps_QuickATPASort,'procedure QuickATPASort(var A: TIntegerArray; var B: T2DPointArray; iLo, iHi: Integer; SortUp: Boolean);');
AddFunction(@ps_SortTPAFrom,'procedure SortTPAFrom(var a: TPointArray; const From: TPoint);'); AddFunction(@ps_SortTPAFrom,'procedure SortTPAFrom(var a: TPointArray; const From: TPoint);');
@ -327,66 +327,71 @@ AddFunction(@ps_SortATPAFrom,'procedure SortATPAFrom(var a: T2DPointArray; const
AddFunction(@ps_SortATPAFromFirstPoint,'procedure SortATPAFromFirstPoint(var a: T2DPointArray; const From: TPoint);'); AddFunction(@ps_SortATPAFromFirstPoint,'procedure SortATPAFromFirstPoint(var a: T2DPointArray; const From: TPoint);');
AddFunction(@ps_InvertTPA,'procedure InvertTPA(var a: TPointArray);'); AddFunction(@ps_InvertTPA,'procedure InvertTPA(var a: TPointArray);');
AddFunction(@ps_InvertATPA,'procedure InvertATPA(var a: T2DPointArray);'); AddFunction(@ps_InvertATPA,'procedure InvertATPA(var a: T2DPointArray);');
AddFunction(@ps_MiddleTPAEx,'function MiddleTPAEx(TPA: TPointArray; var x, y: Integer): Boolean;'); AddFunction(@ps_MiddleTPAEx,'function MiddleTPAEx(const TPA: TPointArray; var x, y: Integer): Boolean;');
AddFunction(@ps_MiddleTPA,'function MiddleTPA(tpa: TPointArray): TPoint;'); AddFunction(@ps_MiddleTPA,'function MiddleTPA(const tpa: TPointArray): TPoint;');
AddFunction(@ps_SortATPASize,'procedure SortATPASize(var a: T2DPointArray; const BigFirst: Boolean);'); AddFunction(@ps_SortATPASize,'procedure SortATPASize(var a: T2DPointArray; const BigFirst: Boolean);');
AddFunction(@ps_SortATPAFromSize,'procedure SortATPAFromSize(var a: T2DPointArray; const Size: Integer; CloseFirst: Boolean);'); AddFunction(@ps_SortATPAFromSize,'procedure SortATPAFromSize(var a: T2DPointArray; const Size: Integer; CloseFirst: Boolean);');
AddFunction(@ps_InIntArrayEx,'function InIntArrayEx(a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean;'); AddFunction(@ps_InIntArrayEx,'function InIntArrayEx(const a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean;');
AddFunction(@ps_InIntArray,'function InIntArray(a: TIntegerArray; Number: Integer): Boolean;'); AddFunction(@ps_InIntArray,'function InIntArray(const a: TIntegerArray; Number: Integer): Boolean;');
AddFunction(@ps_ClearSameIntegers,'procedure ClearSameIntegers(var a: TIntegerArray);'); AddFunction(@ps_ClearSameIntegers,'procedure ClearSameIntegers(var a: TIntegerArray);');
AddFunction(@ps_ClearSameIntegersAndTPA,'procedure ClearSameIntegersAndTPA(var a: TIntegerArray; var p: TPointArray);'); AddFunction(@ps_ClearSameIntegersAndTPA,'procedure ClearSameIntegersAndTPA(var a: TIntegerArray; var p: TPointArray);');
AddFunction(@ps_SplitTPAEx,'function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray;'); AddFunction(@ps_SplitTPAEx,'function SplitTPAEx(const arr: TPointArray; w, h: Integer): T2DPointArray;');
AddFunction(@ps_SplitTPA,'function SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray;'); AddFunction(@ps_SplitTPA,'function SplitTPA(const arr: TPointArray; Dist: Integer): T2DPointArray;');
AddFunction(@ps_FloodFillTPA,'function FloodFillTPA(const TPA : TPointArray) : T2DPointArray;');
AddFunction(@ps_FilterPointsPie,'procedure FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer);'); AddFunction(@ps_FilterPointsPie,'procedure FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer);');
AddFunction(@ps_GetATPABounds,'function GetATPABounds(ATPA: T2DPointArray): TBox;'); AddFunction(@ps_GetATPABounds,'function GetATPABounds(const ATPA: T2DPointArray): TBox;');
AddFunction(@ps_GetTPABounds,'function GetTPABounds(TPA: TPointArray): TBox;'); AddFunction(@ps_GetTPABounds,'function GetTPABounds(const TPA: TPointArray): TBox;');
AddFunction(@ps_FindTPAinTPA,'function FindTPAinTPA(SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;'); AddFunction(@ps_FindTPAinTPA,'function FindTPAinTPA(const SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;');
AddFunction(@ps_GetSamePointsATPA,'function GetSamePointsATPA( ATPA : T2DPointArray; var Matches : TPointArray) : boolean;'); AddFunction(@ps_GetSamePointsATPA,'function GetSamePointsATPA(const ATPA : T2DPointArray; var Matches : TPointArray) : boolean;');
AddFunction(@ps_FindTextTPAinTPA,'function FindTextTPAinTPA(Height : integer; SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;'); AddFunction(@ps_FindTextTPAinTPA,'function FindTextTPAinTPA(Height : integer;const SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;');
AddFunction(@ps_SortCircleWise,'procedure SortCircleWise(var tpa: TPointArray; const cx, cy, StartDegree: Integer; SortUp, ClockWise: Boolean);'); AddFunction(@ps_SortCircleWise,'procedure SortCircleWise(var tpa: TPointArray; const cx, cy, StartDegree: Integer; SortUp, ClockWise: Boolean);');
AddFunction(@ps_LinearSort,'procedure LinearSort(var tpa: TPointArray; cx, cy, sd: Integer; SortUp: Boolean);'); AddFunction(@ps_LinearSort,'procedure LinearSort(var tpa: TPointArray; cx, cy, sd: Integer; SortUp: Boolean);');
AddFunction(@ps_RotatePoint,'function RotatePoint(Const p: TPoint; angle, mx, my: Extended): TPoint;'); AddFunction(@ps_RotatePoint,'function RotatePoint(Const p: TPoint; angle, mx, my: Extended): TPoint;');
AddFunction(@ps_FindGapsTPA,'function FindGapsTPA(TPA: TPointArray; MinPixels: Integer): T2DPointArray;'); AddFunction(@ps_FindGapsTPA,'function FindGapsTPA(const TPA: TPointArray; MinPixels: Integer): T2DPointArray;');
AddFunction(@ps_RemoveDistTPointArray,'function RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;'); AddFunction(@ps_RemoveDistTPointArray,'function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;');
AddFunction(@ps_CombineTPA,'function CombineTPA(Ar1, Ar2: TPointArray): TPointArray;'); AddFunction(@ps_CombineTPA,'function CombineTPA(const Ar1, Ar2: TPointArray): TPointArray;');
AddFunction(@ps_ReArrangeandShortenArrayEx,'function ReArrangeandShortenArrayEx(a: TPointArray; w, h: Integer): TPointArray;'); AddFunction(@ps_ReArrangeandShortenArrayEx,'function ReArrangeandShortenArrayEx(const a: TPointArray; w, h: Integer): TPointArray;');
AddFunction(@ps_ReArrangeandShortenArray,'function ReArrangeandShortenArray(a: TPointArray; Dist: Integer): TPointArray;'); AddFunction(@ps_ReArrangeandShortenArray,'function ReArrangeandShortenArray(const a: TPointArray; Dist: Integer): TPointArray;');
AddFunction(@ps_TPAtoATPAEx,'function TPAtoATPAEx(TPA: TPointArray; w, h: Integer): T2DPointArray;'); AddFunction(@ps_TPAtoATPAEx,'function TPAtoATPAEx(const TPA: TPointArray; w, h: Integer): T2DPointArray;');
AddFunction(@ps_TPAtoATPA,'function TPAtoATPA(TPA: TPointArray; Dist: Integer): T2DPointArray;'); AddFunction(@ps_TPAtoATPA,'function TPAtoATPA(const TPA: TPointArray; Dist: Integer): T2DPointArray;');
AddFunction(@ps_CombineIntArray,'function CombineIntArray(Ar1, Ar2: TIntegerArray): TIntegerArray;'); AddFunction(@ps_CombineIntArray,'function CombineIntArray(const Ar1, Ar2: TIntegerArray): TIntegerArray;');
AddFunction(@ps_MergeATPA,'function MergeATPA(ATPA : T2DPointArray) : TPointArray;'); AddFunction(@ps_MergeATPA,'function MergeATPA(const ATPA : T2DPointArray) : TPointArray;');
AddFunction(@ps_TPAFromBox,'function TPAFromBox(const Box : TBox) : TPointArray;'); AddFunction(@ps_TPAFromBox,'function TPAFromBox(const Box : TBox) : TPointArray;');
AddFunction(@ps_RotatePoints,'function RotatePoints(Const P: TPointArray; A, cx, cy: Extended): TPointArray ;'); AddFunction(@ps_RotatePoints,'function RotatePoints(Const P: TPointArray; A, cx, cy: Extended): TPointArray ;');
AddFunction(@ps_FindTPAEdges,'function FindTPAEdges(p: TPointArray): TPointArray;'); AddFunction(@ps_FindTPAEdges,'function FindTPAEdges(const p: TPointArray): TPointArray;');
AddFunction(@ps_ClearTPAFromTPA,'function ClearTPAFromTPA(arP, ClearPoints: TPointArray): TPointArray;'); AddFunction(@ps_ClearTPAFromTPA,'function ClearTPAFromTPA(const arP, ClearPoints: TPointArray): TPointArray;');
AddFunction(@ps_ReturnPointsNotInTPA,'function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray;'); AddFunction(@ps_ReturnPointsNotInTPA,'function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray;');
AddFunction(@ps_PointInTPA,'function PointInTPA(p: TPoint; arP: TPointArray): Boolean;'); AddFunction(@ps_PointInTPA,'function PointInTPA(p: TPoint;const arP: TPointArray): Boolean;');
AddFunction(@ps_ClearDoubleTPA,'procedure ClearDoubleTPA(var TPA: TPointArray);'); AddFunction(@ps_ClearDoubleTPA,'procedure ClearDoubleTPA(var TPA: TPointArray);');
AddFunction(@ps_TPACountSort,'procedure TPACountSort(Var TPA: TPointArray;const max: TPoint;Const SortOnX : Boolean);'); AddFunction(@ps_TPACountSort,'procedure TPACountSort(Var TPA: TPointArray;const max: TPoint;Const SortOnX : Boolean);');
AddFunction(@ps_TPACountSortBase,'procedure TPACountSortBase(Var TPA: TPointArray;const maxx, base: TPoint; const SortOnX : Boolean);'); AddFunction(@ps_TPACountSortBase,'procedure TPACountSortBase(Var TPA: TPointArray;const maxx, base: TPoint; const SortOnX : Boolean);');
AddFunction(@ps_InvertTIA,'procedure InvertTIA(var tI: TIntegerArray);'); AddFunction(@ps_InvertTIA,'procedure InvertTIA(var tI: TIntegerArray);');
AddFunction(@ps_SumIntegerArray,'function SumIntegerArray(Ints : TIntegerArray): Integer;'); AddFunction(@ps_SumIntegerArray,'function SumIntegerArray(const Ints : TIntegerArray): Integer;');
AddFunction(@ps_AverageTIA,'function AverageTIA(tI: TIntegerArray): Integer;'); AddFunction(@ps_AverageTIA,'function AverageTIA(const tI: TIntegerArray): Integer;');
AddFunction(@ps_AverageExtended,'function AverageExtended(tE: TExtendedArray): Extended;'); AddFunction(@ps_AverageExtended,'function AverageExtended(const tE: TExtendedArray): Extended;');
AddFunction(@ps_SplitTPAExWrap,'procedure SplitTPAExWrap(arr: TPointArray; w, h: Integer; var res : T2DPointArray);'); AddFunction(@ps_SplitTPAExWrap,'procedure SplitTPAExWrap(const arr: TPointArray; w, h: Integer; var res : T2DPointArray);');
AddFunction(@ps_SplitTPAWrap,'procedure SplitTPAWrap(arr: TPointArray; Dist: Integer; var res: T2DPointArray);'); AddFunction(@ps_SplitTPAWrap,'procedure SplitTPAWrap(const arr: TPointArray; Dist: Integer; var res: T2DPointArray);');
AddFunction(@ps_FindGapsTPAWrap,'procedure FindGapsTPAWrap(TPA: TPointArray; MinPixels: Integer; var Res : T2DPointArray);'); AddFunction(@ps_FindGapsTPAWrap,'procedure FindGapsTPAWrap(const TPA: TPointArray; MinPixels: Integer; var Res : T2DPointArray);');
AddFunction(@ps_RemoveDistTPointArrayWrap,'procedure RemoveDistTPointArrayWrap(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean; var Res : TPointArray);'); AddFunction(@ps_RemoveDistTPointArrayWrap,'procedure RemoveDistTPointArrayWrap(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean; var Res : TPointArray);');
AddFunction(@ps_CombineTPAWrap,'procedure CombineTPAWrap(Ar1, Ar2: TPointArray; var Res : TPointArray);'); AddFunction(@ps_CombineTPAWrap,'procedure CombineTPAWrap(const Ar1, Ar2: TPointArray; var Res : TPointArray);');
AddFunction(@ps_ReArrangeandShortenArrayExWrap,'procedure ReArrangeandShortenArrayExWrap(a: TPointArray; w, h: Integer; var Res : TPointArray);'); AddFunction(@ps_ReArrangeandShortenArrayExWrap,'procedure ReArrangeandShortenArrayExWrap(const a: TPointArray; w, h: Integer; var Res : TPointArray);');
AddFunction(@ps_ReArrangeandShortenArrayWrap,'procedure ReArrangeandShortenArrayWrap(a: TPointArray; Dist: Integer; var Res : TPointArray);'); AddFunction(@ps_ReArrangeandShortenArrayWrap,'procedure ReArrangeandShortenArrayWrap(const a: TPointArray; Dist: Integer; var Res : TPointArray);');
AddFunction(@ps_TPAtoATPAExWrap,'procedure TPAtoATPAExWrap(TPA: TPointArray; w, h: Integer; var Res : T2DPointArray);'); AddFunction(@ps_TPAtoATPAExWrap,'procedure TPAtoATPAExWrap(const TPA: TPointArray; w, h: Integer; var Res : T2DPointArray);');
AddFunction(@ps_TPAtoATPAWrap,'procedure TPAtoATPAWrap(TPA: TPointArray; Dist: Integer; var Res : T2DPointArray);'); AddFunction(@ps_TPAtoATPAWrap,'procedure TPAtoATPAWrap(const TPA: TPointArray; Dist: Integer; var Res : T2DPointArray);');
AddFunction(@ps_CombineIntArrayWrap, 'procedure CombineIntArrayWrap(Ar1, Ar2: TIntegerArray; var Res : TIntegerArray);'); AddFunction(@ps_CombineIntArrayWrap, 'procedure CombineIntArrayWrap(const Ar1, Ar2: TIntegerArray; var Res : TIntegerArray);');
AddFunction(@ps_ReturnPointsNotInTPAWrap,'procedure ReturnPointsNotInTPAWrap(Const TotalTPA: TPointArray; const Box: TBox; var Res : TPointArray);'); AddFunction(@ps_ReturnPointsNotInTPAWrap,'procedure ReturnPointsNotInTPAWrap(Const TotalTPA: TPointArray; const Box: TBox; var Res : TPointArray);');
AddFunction(@ps_MergeATPAWrap,'procedure MergeATPAWrap(ATPA : T2DPointArray; var Res: TPointArray);'); AddFunction(@ps_MergeATPAWrap,'procedure MergeATPAWrap(const ATPA : T2DPointArray; var Res: TPointArray);');
AddFunction(@ps_TPAFromBoxWrap,'procedure TPAFromBoxWrap(const Box : TBox; var Res : TPointArray);'); AddFunction(@ps_TPAFromBoxWrap,'procedure TPAFromBoxWrap(const Box : TBox; var Res : TPointArray);');
AddFunction(@ps_RotatePointsWrap,'procedure RotatePointsWrap(Const P: TPointArray; A, cx, cy: Extended; var Res : TPointArray);'); AddFunction(@ps_RotatePointsWrap,'procedure RotatePointsWrap(Const P: TPointArray; A, cx, cy: Extended; var Res : TPointArray);');
AddFunction(@ps_FindTPAEdgesWrap,'procedure FindTPAEdgesWrap(p: TPointArray; var Res : TPointArray);'); AddFunction(@ps_FindTPAEdgesWrap,'procedure FindTPAEdgesWrap(const p: TPointArray; var Res : TPointArray);');
AddFunction(@ps_ClearTPAFromTPAWrap,'procedure ClearTPAFromTPAWrap(arP, ClearPoints: TPointArray; var Res : TPointArray);'); AddFunction(@ps_ClearTPAFromTPAWrap,'procedure ClearTPAFromTPAWrap(const arP, ClearPoints: TPointArray; var Res : TPointArray);');
AddFunction(@ps_FilterPointsLine,'procedure FilterPointsLine(var Points: TPointArray; Radial: Extended; Radius, MX, MY: Integer);'); AddFunction(@ps_FilterPointsLine,'procedure FilterPointsLine(var Points: TPointArray; Radial: Extended; Radius, MX, MY: Integer);');
AddFunction(@ps_SameTPA,'function SameTPA(aTPA, bTPA: TPointArray): Boolean;'); AddFunction(@ps_SameTPA,'function SameTPA(const aTPA, bTPA: TPointArray): Boolean;');
AddFunction(@ps_TPAInATPA,'function TPAInATPA(TPA: TPointArray; InATPA: T2DPointArray; var Index: LongInt): Boolean;'); AddFunction(@ps_TPAInATPA,'function TPAInATPA(const TPA: TPointArray;const InATPA: T2DPointArray; var Index: LongInt): Boolean;');
AddFunction(@ps_offsetTPA,'procedure OffsetTPA(var TPA : TPointArray; const Offset : TPoint);');
AddFunction(@ps_offsetATPA,'procedure OffsetATPA(var ATPA : T2DPointArray; const Offset : TPoint);');
AddFunction(@ps_copyTPA,'function CopyTPA(const TPA : TPointArray) : TPointArray;');
AddFunction(@ps_CopyATPA,'function CopyATPA(const ATPA : T2DPointArray) : T2DPointArray;');
SetCurrSection('Settings'); SetCurrSection('Settings');
AddFunction(@ps_KeyIsSetting, 'function KeyIsSetting(const KeyName: String): Boolean;'); AddFunction(@ps_KeyIsSetting, 'function KeyIsSetting(const KeyName: String): Boolean;');

View File

@ -24,7 +24,7 @@
unit bitmaps; unit bitmaps;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
{$Inline on}
interface interface
uses uses
Classes, SysUtils, FPImage,IntfGraphics,graphtype,MufasaTypes,MufasaBase,graphics; Classes, SysUtils, FPImage,IntfGraphics,graphtype,MufasaTypes,MufasaBase,graphics;
@ -542,7 +542,7 @@ var
SIndex : Integer; SIndex : Integer;
CurrX,CurrY : integer; CurrX,CurrY : integer;
Search,Replace : LongWord; Search,Replace : LongWord;
procedure AddToStack(x,y : integer); procedure AddToStack(x,y : integer);inline;
begin begin
if LongWord(FData[y * w + x]) = Search then if LongWord(FData[y * w + x]) = Search then
begin begin

View File

@ -24,6 +24,7 @@
unit colour_conv; unit colour_conv;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
{$Inline on}
interface interface

View File

@ -29,7 +29,7 @@ interface
uses uses
Classes, SysUtils, mufasatypes; Classes, SysUtils, mufasatypes;
function FastTPASort(TPA: TPointArray; Dists: TIntegerArray; maxDist: Integer; CloseFirst: Boolean): TPointArray; function FastTPASort(const TPA: TPointArray;const Dists: TIntegerArray; maxDist: Integer; CloseFirst: Boolean): TPointArray;
procedure QuickSort(var A: TIntegerArray; iLo, iHi: Integer); procedure QuickSort(var A: TIntegerArray; iLo, iHi: Integer);
//Start Wizzyplugin //Start Wizzyplugin
@ -40,10 +40,10 @@ procedure RAaSTPAEx(var a: TPointArray; const w, h: Integer);
procedure RAaSTPA(var a: TPointArray; const Dist: Integer); procedure RAaSTPA(var a: TPointArray; const Dist: Integer);
function NearbyPointInArrayEx(const P: TPoint; w, h:Integer; a: TPointArray): Boolean; function NearbyPointInArrayEx(const P: TPoint; w, h:Integer; a: TPointArray): Boolean;
function NearbyPointInArray(const P: TPoint; Dist:Integer; a: TPointArray): Boolean; function NearbyPointInArray(const P: TPoint; Dist:Integer; a: TPointArray): Boolean;
function ReArrangeandShortenArrayEx(a: TPointArray; w, h: Integer): TPointArray; function ReArrangeandShortenArrayEx(const a: TPointArray; w, h: Integer): TPointArray;
function ReArrangeandShortenArray(a: TPointArray; Dist: Integer): TPointArray; function ReArrangeandShortenArray(const a: TPointArray; Dist: Integer): TPointArray;
function TPAtoATPAEx(TPA: TPointArray; w, h: Integer): T2DPointArray; function TPAtoATPAEx(const TPA: TPointArray; w, h: Integer): T2DPointArray;
function TPAtoATPA(TPA: TPointArray; Dist: Integer): T2DPointArray; function TPAtoATPA(const TPA: TPointArray; Dist: Integer): T2DPointArray;
procedure QuickTPASort(var A: TIntegerArray; var B: TPointArray; iLo, iHi: Integer; SortUp: Boolean); procedure QuickTPASort(var A: TIntegerArray; var B: TPointArray; iLo, iHi: Integer; SortUp: Boolean);
procedure QuickATPASort(var A: TIntegerArray; var B: T2DPointArray; iLo, iHi: Integer; SortUp: Boolean); procedure QuickATPASort(var A: TIntegerArray; var B: T2DPointArray; iLo, iHi: Integer; SortUp: Boolean);
procedure SortTPAFrom(var a: TPointArray; const From: TPoint); procedure SortTPAFrom(var a: TPointArray; const From: TPoint);
@ -51,46 +51,49 @@ procedure SortATPAFrom(var a: T2DPointArray; const From: TPoint);
procedure SortATPAFromFirstPoint(var a: T2DPointArray; const From: TPoint); procedure SortATPAFromFirstPoint(var a: T2DPointArray; const From: TPoint);
procedure InvertTPA(var a: TPointArray); procedure InvertTPA(var a: TPointArray);
procedure InvertATPA(var a: T2DPointArray); procedure InvertATPA(var a: T2DPointArray);
function MiddleTPAEx(TPA: TPointArray; var x, y: Integer): Boolean; function MiddleTPAEx(const TPA: TPointArray; var x, y: Integer): Boolean;
function MiddleTPA(tpa: TPointArray): TPoint; function MiddleTPA(const tpa: TPointArray): TPoint;
procedure SortATPASize(var a: T2DPointArray; const BigFirst: Boolean); procedure SortATPASize(var a: T2DPointArray; const BigFirst: Boolean);
procedure SortATPAFromSize(var a: T2DPointArray; const Size: Integer; CloseFirst: Boolean); procedure SortATPAFromSize(var a: T2DPointArray; const Size: Integer; CloseFirst: Boolean);
function CombineTPA(Ar1, Ar2: TPointArray): TPointArray; function CombineTPA(const Ar1, Ar2: TPointArray): TPointArray;
function CombineIntArray(Ar1, Ar2: TIntegerArray): TIntegerArray; function CombineIntArray(const Ar1, Ar2: TIntegerArray): TIntegerArray;
function InIntArrayEx(a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean; function InIntArrayEx(const a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean;
function InIntArray(a: TIntegerArray; Number: Integer): Boolean; function InIntArray(const a: TIntegerArray; Number: Integer): Boolean;
procedure ClearSameIntegers(var a: TIntegerArray); procedure ClearSameIntegers(var a: TIntegerArray);
procedure ClearSameIntegersAndTPA(var a: TIntegerArray; var p: TPointArray); procedure ClearSameIntegersAndTPA(var a: TIntegerArray; var p: TPointArray);
function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray; function SplitTPAEx(const arr: TPointArray; w, h: Integer): T2DPointArray;
function SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray; function SplitTPA(const arr: TPointArray; Dist: Integer): T2DPointArray;
function FloodFillTPA(const TPA : TPointArray) : T2DPointArray;
procedure FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer); procedure FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer);
procedure FilterPointsLine(var Points: TPointArray; Radial: Extended; Radius, MX, MY: Integer); procedure FilterPointsLine(var Points: TPointArray; Radial: Extended; Radius, MX, MY: Integer);
function RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray; function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
function GetATPABounds(ATPA: T2DPointArray): TBox; function GetATPABounds(const ATPA: T2DPointArray): TBox;
function GetTPABounds(TPA: TPointArray): TBox; function GetTPABounds(const TPA: TPointArray): TBox;
function FindTPAinTPA(SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean; function FindTPAinTPA(SearchTPA: TPointArray; const TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
function FindTextTPAinTPA(Height : integer; SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean; function FindTextTPAinTPA(Height : integer;const SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
function GetSamePointsATPA( ATPA : T2DPointArray; var Matches : TPointArray) : boolean; function GetSamePointsATPA(const ATPA : T2DPointArray; var Matches : TPointArray) : boolean;
function FindGapsTPA(TPA: TPointArray; MinPixels: Integer): T2DPointArray; function FindGapsTPA(const TPA: TPointArray; MinPixels: Integer): T2DPointArray;
procedure SortCircleWise(var tpa: TPointArray; const cx, cy, StartDegree: Integer; SortUp, ClockWise: Boolean); procedure SortCircleWise(var tpa: TPointArray; const cx, cy, StartDegree: Integer; SortUp, ClockWise: Boolean);
procedure LinearSort(var tpa: TPointArray; cx, cy, sd: Integer; SortUp: Boolean); procedure LinearSort(var tpa: TPointArray; cx, cy, sd: Integer; SortUp: Boolean);
Function MergeATPA(ATPA : T2DPointArray) : TPointArray; Function MergeATPA(const ATPA : T2DPointArray) : TPointArray;
function TPAFromBox(const Box : TBox) : TPointArray; function TPAFromBox(const Box : TBox) : TPointArray;
Function RotatePoints(Const P: TPointArray; A, cx, cy: Extended): TPointArray ; Function RotatePoints(Const P: TPointArray; A, cx, cy: Extended): TPointArray ;
Function RotatePoint(Const p: TPoint; angle, mx, my: Extended): TPoint; inline; Function RotatePoint(Const p: TPoint; angle, mx, my: Extended): TPoint; inline;
function FindTPAEdges(p: TPointArray): TPointArray; function FindTPAEdges(const p: TPointArray): TPointArray;
function PointInTPA(p: TPoint; arP: TPointArray): Boolean; function PointInTPA(const p: TPoint;const arP: TPointArray): Boolean;
function ClearTPAFromTPA(arP, ClearPoints: TPointArray): TPointArray; function ClearTPAFromTPA(const arP, ClearPoints: TPointArray): TPointArray;
procedure ClearDoubleTPA(var TPA: TPointArray); procedure ClearDoubleTPA(var TPA: TPointArray);
Function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray; Function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray;
Procedure TPACountSort(Var TPA: TPointArray;const max: TPoint;Const SortOnX : Boolean); Procedure TPACountSort(Var TPA: TPointArray;const max: TPoint;Const SortOnX : Boolean);
Procedure TPACountSortBase(Var TPA: TPointArray;const maxx, base: TPoint; const SortOnX : Boolean); Procedure TPACountSortBase(Var TPA: TPointArray;const maxx, base: TPoint; const SortOnX : Boolean);
procedure InvertTIA(var tI: TIntegerArray); procedure InvertTIA(var tI: TIntegerArray);
function SumIntegerArray(Ints : TIntegerArray): Integer; function SumIntegerArray(const Ints : TIntegerArray): Integer;
function AverageTIA(tI: TIntegerArray): Integer; function AverageTIA(const tI: TIntegerArray): Integer;
function AverageExtended(tE: TExtendedArray): Extended; function AverageExtended(const tE: TExtendedArray): Extended;
function SameTPA(aTPA, bTPA: TPointArray): Boolean; function SameTPA(const aTPA, bTPA: TPointArray): Boolean;
function TPAInATPA(TPA: TPointArray; InATPA: T2DPointArray; var Index: LongInt): Boolean; function TPAInATPA(const TPA: TPointArray;const InATPA: T2DPointArray; var Index: LongInt): Boolean;
procedure OffsetTPA(var TPA : TPointArray; const Offset : TPoint);
procedure OffsetATPA(var ATPA : T2DPointArray; const Offset : TPoint);
implementation implementation
@ -104,7 +107,7 @@ uses
Very Fast TPA Sort, uses an adepted CountSort algorithm. Very Fast TPA Sort, uses an adepted CountSort algorithm.
/\} /\}
Function FastTPASort(TPA: TPointArray; Dists: TIntegerArray; maxDist: Integer; CloseFirst: Boolean): TPointArray; Function FastTPASort(const TPA: TPointArray;const Dists: TIntegerArray; maxDist: Integer; CloseFirst: Boolean): TPointArray;
{ {
If you want to understand this algorithm, it might be helpful to read about If you want to understand this algorithm, it might be helpful to read about
@ -353,7 +356,7 @@ end;
Results the TPointArray a with one point per box with side lengths W and H left. Results the TPointArray a with one point per box with side lengths W and H left.
/\} /\}
function ReArrangeandShortenArrayEx(a: TPointArray; w, h: Integer): TPointArray; function ReArrangeandShortenArrayEx(const a: TPointArray; w, h: Integer): TPointArray;
var var
i, t, c, l: Integer; i, t, c, l: Integer;
Found: Boolean; Found: Boolean;
@ -384,7 +387,7 @@ end;
Results the TPointArray a with one point per box with side length Dist left. Results the TPointArray a with one point per box with side length Dist left.
/\} /\}
function ReArrangeandShortenArray(a: TPointArray; Dist: Integer): TPointArray; function ReArrangeandShortenArray(const a: TPointArray; Dist: Integer): TPointArray;
var var
i, t, c, l: Integer; i, t, c, l: Integer;
Found: Boolean; Found: Boolean;
@ -415,7 +418,7 @@ end;
Splits the TPA to boxes with sidelengths W and H and results them as a T2DPointArray. Splits the TPA to boxes with sidelengths W and H and results them as a T2DPointArray.
/\} /\}
function TPAtoATPAEx(TPA: TPointArray; w, h: Integer): T2DPointArray; function TPAtoATPAEx(const TPA: TPointArray; w, h: Integer): T2DPointArray;
var var
a, b, c, l: LongInt; a, b, c, l: LongInt;
Found: Boolean; Found: Boolean;
@ -451,7 +454,7 @@ end;
Splits the TPA to boxes with sidelength Dist and results them as a T2DPointArray. Splits the TPA to boxes with sidelength Dist and results them as a T2DPointArray.
/\} /\}
function TPAtoATPA(TPA: TPointArray; Dist: Integer): T2DPointArray; function TPAtoATPA(const TPA: TPointArray; Dist: Integer): T2DPointArray;
var var
a, b, c, l: LongInt; a, b, c, l: LongInt;
Found: Boolean; Found: Boolean;
@ -646,7 +649,7 @@ end;
Stores the coordinates of the middle of the TPointArray a to X and Y. Stores the coordinates of the middle of the TPointArray a to X and Y.
/\} /\}
function MiddleTPAEx(TPA: TPointArray; var x, y: Integer): Boolean; function MiddleTPAEx(const TPA: TPointArray; var x, y: Integer): Boolean;
var var
i, l: Integer; i, l: Integer;
begin begin
@ -669,7 +672,7 @@ end;
Returns the middle of the TPointArray tpa. Returns the middle of the TPointArray tpa.
/\} /\}
function MiddleTPA(tpa: TPointArray): TPoint; function MiddleTPA(const tpa: TPointArray): TPoint;
var var
i, l: Integer; i, l: Integer;
begin begin
@ -725,7 +728,7 @@ end;
Combines the TPointArrays Ar1 and Ar2, and results the combination. Combines the TPointArrays Ar1 and Ar2, and results the combination.
/\} /\}
function CombineTPA(Ar1, Ar2: TPointArray): TPointArray; function CombineTPA(const Ar1, Ar2: TPointArray): TPointArray;
var var
i, l1, l2: Integer; i, l1, l2: Integer;
begin begin
@ -741,7 +744,7 @@ end;
Combines the TIntegerArrays Ar1 and Ar2, and results the combination. Combines the TIntegerArrays Ar1 and Ar2, and results the combination.
/\} /\}
function CombineIntArray(Ar1, Ar2: TIntegerArray): TIntegerArray; function CombineIntArray(const Ar1, Ar2: TIntegerArray): TIntegerArray;
var var
i, l1, l2: Integer; i, l1, l2: Integer;
begin begin
@ -757,7 +760,7 @@ end;
Returns true if the integer Number was found in the integer array a, and stores the index to Where. Returns true if the integer Number was found in the integer array a, and stores the index to Where.
/\} /\}
function InIntArrayEx(a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean; function InIntArrayEx(const a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean;
var var
i, l: Integer; i, l: Integer;
begin begin
@ -776,7 +779,7 @@ end;
Returns true if the integer Number was found in the integer array a. Returns true if the integer Number was found in the integer array a.
/\} /\}
function InIntArray(a: TIntegerArray; Number: Integer): Boolean; function InIntArray(const a: TIntegerArray; Number: Integer): Boolean;
var var
i, l: Integer; i, l: Integer;
begin begin
@ -861,7 +864,7 @@ end;
Splits the points with max X and Y distances W and H to their own TPointArrays. Splits the points with max X and Y distances W and H to their own TPointArrays.
/\} /\}
function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray; function SplitTPAEx(const arr: TPointArray; w, h: Integer): T2DPointArray;
var var
t1, t2, c, ec, tc, l: Integer; t1, t2, c, ec, tc, l: Integer;
tpa: TPointArray; tpa: TPointArray;
@ -908,7 +911,7 @@ end;
Dist 1 puts the points that are next to eachother to their own arrays. Dist 1 puts the points that are next to eachother to their own arrays.
/\} /\}
function SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray; function SplitTPA(const arr: TPointArray; Dist: Integer): T2DPointArray;
var var
t1, t2, c, ec, tc, l: Integer; t1, t2, c, ec, tc, l: Integer;
tpa: TPointArray; tpa: TPointArray;
@ -950,6 +953,104 @@ begin
SetLength(Result, c); SetLength(Result, c);
end; end;
function FloodFillTPA(const TPA : TPointArray) : T2DPointArray;
var
x,y,i,CurrentArray, LengthTPA,CurrentStack : integer;
TempBox : TBox;
PointsToFill : T2DBoolArray;
Lengths : TIntegerArray;
TempTPA : TPointArray;
Stack : TPointArray;
fx,fy : integer;
begin;
LengthTPA := High(TPA);
if LengthTPA < 1 then
begin;
if LengthTPA = 0 then
begin;
SetLength(Result,1,1);
Result[0][0] := TPA[0];
end else
SetLength(Result,0);
exit;
end;
TempBox := GetTPABounds(TPA);
SetLength(PointsToFill,TempBox.x2 - TempBox.x1+3,TempBox.y2 - TempBox.y1+3); //W + 2, H + 2 so that we can check the borders
fy := TempBox.y2 - TempBox.y1+3;
fx := TempBox.x2 - TempBox.x1+2;
for i := 0 to fx do
FillChar(PointsToFill[i][0],fy*sizeof(boolean),0);
x := TempBox.x1 - 1;
y := TempBox.y1 - 1;
CurrentArray := -1;
SetLength(Stack , LengthTPA + 1);
SetLength(Lengths , LengthTPA + 1);
SetLength(TempTPA , LengthTPA + 1);
For I := 0 to LengthTPA do
begin;
TempTPA[I].x := TPA[I].x - x;
TempTPA[I].y := TPA[I].y - y;
end;
For I := 0 to LengthTPA do
PointsToFill[TempTPA[I].x][TempTPA[I].y] := True;
For I := 0 to LengthTPA do
if PointsToFill[TempTPA[I].x][TempTPA[I].y] then
begin;
inc(CurrentArray);
SetLength(Result,CurrentArray + 1);
SetLength(Result[CurrentArray],LengthTPA - I + 1);
Lengths[CurrentArray] := 0;
CurrentStack := 0;
Stack[0].x := TempTPA[I].x;
Stack[0].y := TempTPA[I].y;
While CurrentStack > -1 do
begin;
fx := stack[CurrentStack].x;
fy := stack[CurrentStack].y;
dec(CurrentStack);
Result[CurrentArray][Lengths[CurrentArray]].x := fx + x;
Result[CurrentArray][Lengths[CurrentArray]].y := fy + y;
inc(Lengths[CurrentArray]);
if PointsToFill[fx+1][fy] then
begin
inc(CurrentStack);Stack[CurrentStack].x := fx+1;Stack[Currentstack].y := fy;PointsToFill[fx+1][fy] := false;
end;
if PointsToFill[fx][fy+1] then
begin
inc(CurrentStack);Stack[CurrentStack].x := fx;Stack[Currentstack].y := fy+1;PointsToFill[fx][fy+1] := false;
end;
if PointsToFill[fx-1][fy] then
begin
inc(CurrentStack);Stack[CurrentStack].x := fx-1;Stack[Currentstack].y := fy;PointsToFill[fx-1][fy] := false;
end;
if PointsToFill[fx][fy-1] then
begin
inc(CurrentStack);Stack[CurrentStack].x := fx;Stack[Currentstack].y := fy-1;PointsToFill[fx][fy-1] := false;
end;
if PointsToFill[fx+1][fy+1] then
begin
inc(CurrentStack);Stack[CurrentStack].x := fx+1;Stack[Currentstack].y := fy+1;PointsToFill[fx+1][fy+1] := false;
end;
if PointsToFill[fx-1][fy-1] then
begin
inc(CurrentStack);Stack[CurrentStack].x := fx-1;Stack[Currentstack].y := fy-1;PointsToFill[fx-1][fy-1] := false;
end;
if PointsToFill[fx-1][fy+1] then
begin
inc(CurrentStack);Stack[CurrentStack].x := fx-1;Stack[Currentstack].y := fy+1;PointsToFill[fx-1][fy+1] := false;
end;
if PointsToFill[fx+1][fy-1] then
begin
inc(CurrentStack);Stack[CurrentStack].x := fx+1;Stack[Currentstack].y := fy-1;PointsToFill[fx+1][fy-1] := false;
end;
end;
SetLength(Result[CurrentArray],Lengths[CurrentArray]);
end;
SetLength(Stack,0);
SetLength(TempTPA,0);
SetLength(Lengths,0);
end;
{/\ {/\
Removes the points in the TPointArray Points that are not within the degrees Removes the points in the TPointArray Points that are not within the degrees
\\ SD (StartDegree) and ED (EndDegree) and the distances MinR (MinRadius) and \\ SD (StartDegree) and ED (EndDegree) and the distances MinR (MinRadius) and
@ -1007,7 +1108,7 @@ var
I, Hi, Ind, y: Integer; I, Hi, Ind, y: Integer;
P: TPointArray; P: TPointArray;
Box: TBox; Box: TBox;
B: Array of Array of Boolean; B: T2DBoolArray;
SinAngle,CosAngle : Extended; SinAngle,CosAngle : Extended;
begin begin
Ind := 0; Ind := 0;
@ -1017,7 +1118,10 @@ begin
SetLength(B, max(Box.x2, Round(SinAngle * Radius + MX)) + 1); SetLength(B, max(Box.x2, Round(SinAngle * Radius + MX)) + 1);
y:= max(Box.x2, -Round(CosAngle * Radius) + MY); y:= max(Box.x2, -Round(CosAngle * Radius) + MY);
for I:= 0 to High(B) do for I:= 0 to High(B) do
begin;
SetLength(B[I], y + 1); SetLength(B[I], y + 1);
FillChar(B[i][0],y+1,0);
end;
Hi:= High(Points); Hi:= High(Points);
for I:= 0 to Hi do for I:= 0 to Hi do
B[Points[I].x][Points[I].y]:= True; B[Points[I].x][Points[I].y]:= True;
@ -1039,7 +1143,7 @@ end;
Removes the points that are inside or outside the distance Dist from the point (x, y) from the TPointArray ThePoints. Removes the points that are inside or outside the distance Dist from the point (x, y) from the TPointArray ThePoints.
/\} /\}
function RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray; function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
var var
I, L, LL: integer; I, L, LL: integer;
begin; begin;
@ -1070,7 +1174,7 @@ end;
Returns the boundaries of the ATPA as a TBox. Returns the boundaries of the ATPA as a TBox.
/\} /\}
function GetATPABounds(ATPA: T2DPointArray): TBox; function GetATPABounds(const ATPA: T2DPointArray): TBox;
var var
I,II,L2,L : Integer; I,II,L2,L : Integer;
begin; begin;
@ -1106,7 +1210,7 @@ end;
Returns the boundaries of the TPA as a TBox. Returns the boundaries of the TPA as a TBox.
/\} /\}
function GetTPABounds(TPA: TPointArray): TBox; function GetTPABounds(const TPA: TPointArray): TBox;
var var
I,L : Integer; I,L : Integer;
begin; begin;
@ -1135,11 +1239,11 @@ end;
\\ to the TPA Matches. Returns true if there were atleast one match(es). \\ to the TPA Matches. Returns true if there were atleast one match(es).
/\} /\}
function FindTPAinTPA(SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean; function FindTPAinTPA(SearchTPA : TPointArray; const TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
var var
Len, I,II,LenSearch,xOff,yOff : integer; Len, I,II,LenSearch,xOff,yOff : integer;
tx,ty,MatchCount : integer; tx,ty,MatchCount : integer;
Screen : Array of Array of Boolean; Screen : T2DBoolArray;
ScreenBox,SearchBox : TBox; ScreenBox,SearchBox : TBox;
Found: Boolean; Found: Boolean;
begin; begin;
@ -1153,6 +1257,8 @@ begin;
SearchBox := GetTPABounds(SearchTPA); SearchBox := GetTPABounds(SearchTPA);
try try
SetLength(Screen,ScreenBox.x2 + 1,ScreenBox.y2 + 1); SetLength(Screen,ScreenBox.x2 + 1,ScreenBox.y2 + 1);
for i := ScreenBox.x2 downto 0 do
FillChar(Screen[i][0],screenbox.y2+1,0);
except except
Exit; Exit;
end; end;
@ -1212,12 +1318,12 @@ end;
Read the description of FindTPAinTPA. Additional Height parameter. Read the description of FindTPAinTPA. Additional Height parameter.
/\} /\}
function FindTextTPAinTPA(Height : integer; SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean; function FindTextTPAinTPA(Height : integer;const SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
var var
Len, I,II,LenSearch,LenTPA,xOff,yOff,x,y: integer; Len, I,II,LenSearch,LenTPA,xOff,yOff,x,y: integer;
tx,ty,MatchCount : integer; tx,ty,MatchCount : integer;
Found : boolean; Found : boolean;
Screen : Array of Array of Boolean; Screen : T2DBoolArray;
ScreenBox,SearchBox : TBox; ScreenBox,SearchBox : TBox;
InversedTPA : TPointArray; InversedTPA : TPointArray;
begin; begin;
@ -1235,6 +1341,8 @@ begin;
Screenbox.y2 := Screenbox.y2 + (height - SearchBox.y2); Screenbox.y2 := Screenbox.y2 + (height - SearchBox.y2);
SearchBox.y2 := Height; SearchBox.y2 := Height;
SetLength(Screen, SearchBox.x2 + 1,Searchbox.y2 + 1); SetLength(Screen, SearchBox.x2 + 1,Searchbox.y2 + 1);
for i := ScreenBox.x2 downto 0 do
FillChar(screen[i][0],screenbox.y2+1,0);
SetLength(InversedTPA,(SearchBox.x2 + 1) * (Searchbox.y2 + 1)); SetLength(InversedTPA,(SearchBox.x2 + 1) * (Searchbox.y2 + 1));
for I := 0 to LenSearch do for I := 0 to LenSearch do
Screen[ SearchTPA[I].x,SearchTPA[I].y] := True; Screen[ SearchTPA[I].x,SearchTPA[I].y] := True;
@ -1262,6 +1370,8 @@ begin;
try try
SetLength(Screen,0); SetLength(Screen,0);
SetLength(Screen,ScreenBox.x2 + 1,ScreenBox.y2 + 1); SetLength(Screen,ScreenBox.x2 + 1,ScreenBox.y2 + 1);
for i := ScreenBox.x2 downto 0 do
FillChar(screen[i][0],screenbox.y2+1,0);
except except
Exit; Exit;
end; end;
@ -1309,7 +1419,7 @@ end;
Finds the points that exist in all TPA's in the ATPA. Finds the points that exist in all TPA's in the ATPA.
/\} /\}
function GetSamePointsATPA( ATPA : T2DPointArray; var Matches : TPointArray) : boolean; function GetSamePointsATPA(const ATPA : T2DPointArray; var Matches : TPointArray) : boolean;
var var
I,ii,Len,MatchesC : integer; I,ii,Len,MatchesC : integer;
MinBox,TempBox : TBox; MinBox,TempBox : TBox;
@ -1381,10 +1491,10 @@ end;
\\ Only horizontal, sorry folks. \\ Only horizontal, sorry folks.
/\} /\}
function FindGapsTPA(TPA: TPointArray; MinPixels: Integer): T2DPointArray; function FindGapsTPA(const TPA: TPointArray; MinPixels: Integer): T2DPointArray;
var var
Len,TotalLen,LenRes,I,II,III : integer; Len,TotalLen,LenRes,I,II,III : integer;
Screen : Array of Array of Boolean; Screen : T2DBoolArray;
Height,Width : Integer; Height,Width : Integer;
Box : TBox; Box : TBox;
begin; begin;
@ -1397,6 +1507,8 @@ begin;
III := 0; III := 0;
try try
SetLength(Screen,Width + 1,Height + 1); SetLength(Screen,Width + 1,Height + 1);
for i := 0 to Width do
FillChar(Screen[i][0],(Height+1),0);
except except
Exit; Exit;
end; end;
@ -1530,7 +1642,7 @@ end;
Merges the TPointArrays of the T2DPointArray ATPA in to one TPA. Merges the TPointArrays of the T2DPointArray ATPA in to one TPA.
/\} /\}
Function MergeATPA(ATPA: T2DPointArray): TPointArray; Function MergeATPA(const ATPA: T2DPointArray): TPointArray;
var var
I, II, Len, TempL, CurrentL: integer; I, II, Len, TempL, CurrentL: integer;
begin; begin;
@ -1614,9 +1726,9 @@ End;
Returns the edges of the given TPA. Returns the edges of the given TPA.
/\} /\}
function FindTPAEdges(p: TPointArray): TPointArray; function FindTPAEdges(const p: TPointArray): TPointArray;
var var
b: array of array of Boolean; b: T2DBoolArray;
i, x, y, l, c: Integer; i, x, y, l, c: Integer;
Box: TBox; Box: TBox;
begin begin
@ -1628,7 +1740,10 @@ begin
y := (Box.y2 - Box.y1) + 3; y := (Box.y2 - Box.y1) + 3;
SetLength(b, x); SetLength(b, x);
for i := 0 to x -1 do for i := 0 to x -1 do
begin
SetLength(b[i], y); SetLength(b[i], y);
FillChar(b[i][0],y,0);
end;
for i := 0 to l -1 do for i := 0 to l -1 do
b[p[i].x +1 - Box.x1][p[i].y +1 - Box.y1] := True; b[p[i].x +1 - Box.x1][p[i].y +1 - Box.y1] := True;
SetLength(Result, l); SetLength(Result, l);
@ -1659,7 +1774,7 @@ end;
Notes: In actuallys means IN the array, not in the box shaped by the array. Notes: In actuallys means IN the array, not in the box shaped by the array.
/\} /\}
function PointInTPA(p: TPoint; arP: TPointArray): Boolean; function PointInTPA(const p: TPoint;const arP: TPointArray): Boolean;
var var
i, l: Integer; i, l: Integer;
begin begin
@ -1677,11 +1792,12 @@ end;
Removes the given ClearPoints from arP. Removes the given ClearPoints from arP.
/\} /\}
function ClearTPAFromTPA(arP, ClearPoints: TPointArray): TPointArray; function ClearTPAFromTPA(const arP, ClearPoints: TPointArray): TPointArray;
var var
i, j, l, l2: Integer; i, j, l, l2: Integer;
Found: Boolean; Found: Boolean;
begin begin
Setlength(result,0);
l := High(arP); l := High(arP);
l2 := High(ClearPoints); l2 := High(ClearPoints);
for i := 0 to l do for i := 0 to l do
@ -1734,13 +1850,15 @@ end;
Function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray; Function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray;
var var
x, y, w, h, i, l: integer; x, y, w, h, i, l: integer;
B: Array of Array of Boolean; B: T2DBoolArray;
begin; begin;
w := Box.x2 - Box.x1; w := Box.x2 - Box.x1;
h := Box.y2 - Box.y1; h := Box.y2 - Box.y1;
if (w = 0) and (h = 0) then if (w = 0) and (h = 0) then
Exit; Exit;
SetLength(b, w + 1, h + 1); SetLength(b, w + 1, h + 1);
for i := w downto 0 do
FillChar(b[i][0],h+1,0);
l := High(TotalTPA); l := High(TotalTPA);
x := 0; x := 0;
for i := 0 to l do for i := 0 to l do
@ -1772,13 +1890,15 @@ end;
Procedure TPACountSort(Var TPA: TPointArray;const max: TPoint;Const SortOnX : Boolean); Procedure TPACountSort(Var TPA: TPointArray;const max: TPoint;Const SortOnX : Boolean);
Var Var
c: Array Of Array Of Integer; c: T2DIntegerArray;
I, II, III, hTPA, cc: Integer; I, II, III, hTPA, cc: Integer;
Begin Begin
hTPA := High(TPA); hTPA := High(TPA);
if hTPA < 1 then if hTPA < 1 then
Exit; Exit;
SetLength(c, max.X + 1,max.Y + 1); SetLength(c, max.X + 1,max.Y + 1);
for i := max.x downto 0 do
FillChar(c[i][0],(max.y+1)*sizeof(Integer),0);
For I := 0 To hTPA Do For I := 0 To hTPA Do
c[TPA[I].x][TPA[I].y] := c[TPA[i].x][TPA[i].y] + 1; c[TPA[I].x][TPA[I].y] := c[TPA[i].x][TPA[i].y] + 1;
@ -1817,7 +1937,7 @@ End;
Procedure TPACountSortBase(Var TPA: TPointArray;const maxx, base: TPoint; const SortOnX : Boolean); Procedure TPACountSortBase(Var TPA: TPointArray;const maxx, base: TPoint; const SortOnX : Boolean);
Var Var
c: Array Of Array Of Integer; c: T2DIntegerArray;
I, II, III, hTPA, cc: Integer; I, II, III, hTPA, cc: Integer;
Max : TPoint; Max : TPoint;
Begin Begin
@ -1827,6 +1947,8 @@ Begin
max.X := maxx.X - base.X; max.X := maxx.X - base.X;
max.Y := maxx.Y - base.Y; max.Y := maxx.Y - base.Y;
SetLength(c, max.X + 1,max.Y + 1); SetLength(c, max.X + 1,max.Y + 1);
for i := max.x downto 0 do
FillChar(c[i][0],(max.y+1)*sizeof(integer),0);
hTPA := High(TPA); hTPA := High(TPA);
For I := 0 To hTPA Do For I := 0 To hTPA Do
c[TPA[I].x - base.X][TPA[I].y - base.Y] := c[TPA[i].x- base.X][TPA[i].y- base.Y] + 1; c[TPA[I].x - base.X][TPA[I].y - base.Y] := c[TPA[i].x- base.X][TPA[i].y- base.Y] + 1;
@ -1862,7 +1984,7 @@ End;
{/\ {/\
Returns the sum of all integers in the array Returns the sum of all integers in the array
/\} /\}
function SumIntegerArray(Ints : TIntegerArray): Integer; function SumIntegerArray(const Ints : TIntegerArray): Integer;
var var
I, H: Integer; I, H: Integer;
begin begin
@ -1890,7 +2012,7 @@ end;
Results the Average of an IntegerArray Results the Average of an IntegerArray
/\} /\}
function AverageTIA(tI: TIntegerArray): Integer; function AverageTIA(const tI: TIntegerArray): Integer;
begin begin
try Result := (SumIntegerArray(tI) div Length(tI)); except Result := 0; end; try Result := (SumIntegerArray(tI) div Length(tI)); except Result := 0; end;
end; end;
@ -1898,7 +2020,7 @@ end;
{/\ {/\
Results the Average of an ExtendedArray Results the Average of an ExtendedArray
/\} /\}
function AverageExtended(tE: TExtendedArray): Extended; function AverageExtended(const tE: TExtendedArray): Extended;
var var
i, h: Integer; i, h: Integer;
begin begin
@ -1916,7 +2038,7 @@ end;
{/\ {/\
Returns true if the two inputed TPA's are exactly the same (so the order matters) Returns true if the two inputed TPA's are exactly the same (so the order matters)
/\} /\}
function SameTPA(aTPA, bTPA: TPointArray): Boolean; function SameTPA(const aTPA, bTPA: TPointArray): Boolean;
var var
I: LongInt; I: LongInt;
h : integer; h : integer;
@ -1933,7 +2055,7 @@ end;
{/\ {/\
Returns true if the TPA is found as one of ATPA's sub-TPA's.. And again, order matters Returns true if the TPA is found as one of ATPA's sub-TPA's.. And again, order matters
/\} /\}
function TPAInATPA(TPA: TPointArray; InATPA: T2DPointArray; var Index: LongInt): Boolean; function TPAInATPA(const TPA: TPointArray;const InATPA: T2DPointArray; var Index: LongInt): Boolean;
var var
I: LongInt; I: LongInt;
h : integer; h : integer;
@ -1949,6 +2071,25 @@ begin
Result := False; Result := False;
end; end;
procedure OffsetTPA(var TPA: TPointArray; const Offset: TPoint);
var
i : integer;
begin
for i := high(TPA) downto 0 do
begin;
inc(TPA[i].x,offset.x);
inc(TPA[i].y,offset.y);
end;
end;
procedure OffsetATPA(var ATPA: T2DPointArray; const Offset: TPoint);
var
i : integer;
begin
for i := high(ATPA) downto 0 do
OffsetTPA(ATPA[i],Offset);
end;
end. end.