Skip to content

Commit

Permalink
Export pointbuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Oct 1, 2023
1 parent 32a7553 commit baed483
Show file tree
Hide file tree
Showing 38 changed files with 287 additions and 153 deletions.
6 changes: 5 additions & 1 deletion Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
<PackageName Value="LCL"/>
</Item5>
</RequiredPackages>
<Units Count="149">
<Units Count="150">
<Unit0>
<Filename Value="Simba.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -1021,6 +1021,10 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit148>
<Unit149>
<Filename Value="script/imports/simba/simba.import_pointbuffer.pas"/>
<IsPartOfProject Value="True"/>
</Unit149>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand Down
10 changes: 5 additions & 5 deletions Source/algorithms/simba.algo_unique.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Algo_Unique_String(const Arr: TStringArray): TStringArray;
implementation

uses
simba.tpa, simba.overallocatearray, simba.math;
simba.tpa, simba.arraybuffer, simba.math;

generic function Unique<T>(const Arr: specialize TArray<T>): specialize TArray<T>;
var
Expand Down Expand Up @@ -133,7 +133,7 @@ function Algo_Unique_Integer(const Arr: TIntegerArray): TIntegerArray;
Bucket: TIntegerArray;
Count: Integer;
end;
Buffer: specialize TSimbaOverAllocateArray<Integer>;
Buffer: TSimbaIntegerBuffer;
label
Next;
begin
Expand Down Expand Up @@ -164,7 +164,7 @@ function Algo_Unique_Integer(const Arr: TIntegerArray): TIntegerArray;
Next:
end;

Result := Buffer.Trim();
Result := Buffer.ToArray(False);
end;

function Algo_Unique_String(const Arr: TStringArray): TStringArray;
Expand All @@ -175,7 +175,7 @@ function Algo_Unique_String(const Arr: TStringArray): TStringArray;
Bucket: TStringArray;
Count: Integer;
end;
Buffer: specialize TSimbaOverAllocateArray<String>;
Buffer: TSimbaStringBuffer;
label
Next;
begin
Expand Down Expand Up @@ -206,7 +206,7 @@ function Algo_Unique_String(const Arr: TStringArray): TStringArray;
Next:
end;

Result := Buffer.Trim();
Result := Buffer.ToArray(False);
end;

end.
Expand Down
4 changes: 2 additions & 2 deletions Source/box.inc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ begin
if Contains(Points[I]) then
Buffer.Add(Points[I]);

Result := Buffer.Trim();
Result := Buffer.ToArray(False);
end;

function TBoxHelper.Exclude(Points: TPointArray): TPointArray;
Expand All @@ -282,7 +282,7 @@ begin
if not Contains(Points[I]) then
Buffer.Add(Points[I]);

Result := Buffer.Trim();
Result := Buffer.ToArray(False);
end;

function TBoxHelper.NearestEdge(P: TPoint): TPoint;
Expand Down
2 changes: 1 addition & 1 deletion Source/components/simba.component_tabcontrol.pas
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TSimbaTabControl = class(TCustomControl)
implementation

uses
simba.main, simba.mufasatypes, simba.theme, simba.fonthelpers, simba.ide_utils;
simba.main, simba.mufasatypes, simba.theme, simba.ide_utils;

function TSimbaTab.GetImageIndex: TImageIndex;
begin
Expand Down
4 changes: 1 addition & 3 deletions Source/editor/simba.editor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TSimbaEditor = class(TSimbaSynEdit)
implementation

uses
SynEditPointClasses, SynGutterBase, SynGutter, SynEditMarkupWordGroup, SynHighlighterPas_Simba, SynEditMarkupHighAll,
SynEditPointClasses, SynGutterBase, SynGutter, SynHighlighterPas_Simba, SynEditMarkupHighAll,
LazSynEditMouseCmdsTypes, Forms,
simba.fonthelpers, simba.editor_blockcompletion,
simba.editor_docgenerator, simba.editor_commentblock,
Expand Down Expand Up @@ -291,8 +291,6 @@ procedure TSimbaEditor.MaybeReplaceModifiers;
end;

procedure TSimbaEditor.SimbaSettingChanged(Setting: TSimbaSetting);
var
I: Integer;
begin
case Setting.Name of
'Editor.FontSize':
Expand Down
4 changes: 2 additions & 2 deletions Source/finders/simba.finder_color.pas
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function MatchColorsOnTarget(Target: TSimbaTarget; Bounds: TBox;
implementation

uses
simba.overallocatearray, simba.colormath_distance_unrolled, simba.threadpool, simba.atpa, simba.datetime, simba.singlematrix;
simba.arraybuffer, simba.colormath_distance_unrolled, simba.threadpool, simba.atpa, simba.singlematrix;

// How much to "Slice" (vertically) the image up for multithreading.
function CalculateSlices(SearchWidth, SearchHeight: Integer): Integer;
Expand Down Expand Up @@ -196,7 +196,7 @@ function FindColorsOnBuffer(Formula: EColorSpace; Color: TColor; Tolerance: Sing
PointBuffer.Add(X + OffsetX, Y + OffsetY);
}
{$DEFINE MACRO_FINDCOLORS_END :=
Result := PointBuffer.Trim();
Result := PointBuffer.ToArray(False);
}
MACRO_FINDCOLORS

Expand Down
6 changes: 3 additions & 3 deletions Source/finders/simba.finder_dtm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function FindDTMRotatedOnTarget(Target: TSimbaTarget;
implementation

uses
simba.colormath_distance, simba.math, simba.overallocatearray;
simba.colormath_distance, simba.arraybuffer;

type
TSearchPoint = record
Expand Down Expand Up @@ -178,7 +178,7 @@ function FindDTMOnBuffer(var Limit: TSimpleThreadsafeLimit; DTM: TDTM; Buffer: P
Break;
end;

Result := PointBuffer.Trim();
Result := PointBuffer.ToArray(False);
end;

function FindDTMRotatedOnBuffer(var Limit: TSimpleThreadsafeLimit; Buffer: PColorBGRA; BufferWidth: Integer; SearchWidth, SearchHeight: Integer; DTM: TDTM; StartDegrees, EndDegrees: Double; Step: Double; out FoundDegrees: TDoubleArray; OffsetX, OffsetY: Integer): TPointArray;
Expand Down Expand Up @@ -257,7 +257,7 @@ function FindDTMRotatedOnBuffer(var Limit: TSimpleThreadsafeLimit; Buffer: PColo

type
TMatch = record X,Y: Integer; Deg: Double; end;
TMatchBuffer = specialize TSimbaOverAllocateArray<TMatch>;
TMatchBuffer = specialize TSimbaArrayBuffer<TMatch>;
var
I, X, Y: Integer;
MainPointArea: TBox;
Expand Down
4 changes: 2 additions & 2 deletions Source/finders/simba.finder_image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function FindBitmapOnBuffer(var Limit: TSimpleThreadsafeLimit;
implementation

uses
simba.datetime, simba.overallocatearray, simba.threadpool, simba.tpa, simba.atpa;
simba.arraybuffer, simba.threadpool, simba.tpa, simba.atpa;

// How much to "Slice" (vertically) the image up for multithreading.
function CalculateSlices(SearchWidth, SearchHeight: Integer): Integer;
Expand Down Expand Up @@ -267,7 +267,7 @@ function FindBitmapOnBuffer(var Limit: TSimpleThreadsafeLimit; Image: TSimbaImag
Break;
end;

Result := PointBuffer.Trim();
Result := PointBuffer.ToArray(False);
finally
FreeMem(BitmapColors);
end;
Expand Down
8 changes: 4 additions & 4 deletions Source/generics.inc
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ end;
generic function IndicesOf<_T>(const Item: _T; const Arr: specialize TArray<_T>): TIntegerArray;
var
I: Integer;
Res: specialize TSimbaOverAllocateArray<Integer>;
Res: TSimbaIntegerBuffer;
begin
Res.Init(4);

for I := 0 to High(Arr) do
if (Item = Arr[I]) then
Res.Add(I);

Result := Res.Trim();
Result := Res.ToArray(False);
end;

generic function Mode<_T>(const Arr: specialize TArray<_T>): Integer;
Expand Down Expand Up @@ -197,14 +197,14 @@ end;
generic function IndicesOf_SameValue<_T>(const Item: _T; const Arr: specialize TArray<_T>): TIntegerArray;
var
I: Integer;
Buffer: specialize TSimbaOverAllocateArray<Integer>;
Buffer: TSimbaIntegerBuffer;
begin
Buffer.Init(4);

for I := 0 to High(Arr) do
if SameValue(Item, Arr[I]) then
Buffer.Add(I);

Result := Buffer.Trim();
Result := Buffer.ToArray(False);
end;
{$ENDIF}
2 changes: 1 addition & 1 deletion Source/imagebox/simba.imagebox.pas
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, ComCtrls, LCLType,
simba.mufasatypes, simba.image, simba.dtm, simba.imagebox_image,
simba.colormath, simba.colormath_distance;
simba.colormath;

type
TSimbaImageBox_ScrollBox = class(TScrollBox)
Expand Down
2 changes: 1 addition & 1 deletion Source/imagebox/simba.imagebox_image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TSimbaImageBoxBitmap = class(TObject)
implementation

uses
simba.image_lazbridge, simba.singlematrix, simba.integermatrix;
simba.image_lazbridge;

const
HEATMAP_LOOKUP_TABLE: array[0..837] of TColor = (
Expand Down
2 changes: 1 addition & 1 deletion Source/matchtemplate/simba.matchtemplate_ccoeff.pas
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ TSliceCache = record

function TMatchTemplateCache_CCOEFF.GetSliceCache(Lo, Hi: Integer): TSliceCache;
var
I, Y: Integer;
I: Integer;
ImgSlice: TRGBMatrix;
begin
Lock.Enter();
Expand Down
4 changes: 2 additions & 2 deletions Source/matchtemplate/simba.matchtemplate_ccorr.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ implementation

uses
simba.threadpool, simba.simplelock,
simba.singlematrix, simba.integermatrix;
simba.singlematrix;

// MatchTemplate_CCORR
function __MatchTemplate_CCORR(Image, Templ: TIntegerMatrix; Normed: Boolean): TSingleMatrix;
Expand Down Expand Up @@ -181,7 +181,7 @@ TSliceCache = record
function TMatchTemplateCache_CCORR.GetSliceCache(Lo, Hi: Integer): TSliceCache;
var
ImgSlice: TRGBMatrix;
I, Y: Integer;
I: Integer;
begin
Lock.Enter();

Expand Down
4 changes: 2 additions & 2 deletions Source/matchtemplate/simba.matchtemplate_sqdiff.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ implementation

uses
simba.threadpool, simba.simplelock,
simba.singlematrix, simba.integermatrix;
simba.singlematrix;

// MatchTemplate_SQDIFF
function __MatchTemplate_SQDIFF(Image, Templ: TIntegerMatrix; Normed: Boolean): TSingleMatrix;
Expand Down Expand Up @@ -187,7 +187,7 @@ TSliceCache = record
function TMatchTemplateCache_SQDIFF.GetSliceCache(Lo, Hi: Integer): TSliceCache;
var
ImgSlice: TRGBMatrix;
I, Y: Integer;
I: Integer;
begin
Lock.Enter();

Expand Down
2 changes: 1 addition & 1 deletion Source/package/simba.package_installer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ implementation

uses
Forms, FileUtil,
simba.mufasatypes, simba.files, simba.threading, simba.env;
simba.mufasatypes, simba.threading, simba.env;

function TSimbaPackageInstaller.InternalInstall(URL: String; Path: String; IgnoreList: TStringArray; Flat: Boolean): Boolean;

Expand Down
Loading

0 comments on commit baed483

Please sign in to comment.