mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-23 17:52:16 -05:00
TPA: Removed FilterTPACustom and FilterTPADistEx
This commit is contained in:
parent
696a75b3d9
commit
c58268335a
@ -143,16 +143,6 @@ begin
|
|||||||
FilterPointsLine(points,radial,radius,mx,my);
|
FilterPointsLine(points,radial,radius,mx,my);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ps_FilterTPACustom(TPA: TPointArray; compare: function(a, b: integer): boolean);
|
|
||||||
begin
|
|
||||||
FilterTPACustom(TPA, @compare);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure ps_FilterTPADistEx(var TPA: TPointArray; maxL, maxW: integer);
|
|
||||||
begin
|
|
||||||
FilterTPADistEx(TPA, maxL, maxW);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure ps_FilterTPADist(var TPA: TPointArray; maxDist: integer);
|
procedure ps_FilterTPADist(var TPA: TPointArray; maxDist: integer);
|
||||||
begin
|
begin
|
||||||
FilterTPADist(TPA, maxDist);
|
FilterTPADist(TPA, maxDist);
|
||||||
|
@ -458,8 +458,6 @@ AddFunction(@ps_FloodFillTPA,'function FloodFillTPA(const TPA : TPointArray) : T
|
|||||||
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_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_filterpointsdist,'procedure FilterPointsDist(var Points: TPointArray; const MinDist, MaxDist: Extended; Mx, My: Integer);');
|
AddFunction(@ps_filterpointsdist,'procedure FilterPointsDist(var Points: TPointArray; const MinDist, MaxDist: Extended; Mx, My: Integer);');
|
||||||
AddFunction(@ps_filterTPACustom, 'procedure FilterTPACustom(var TPA: TPointArray; compare: function(a, b: integer): boolean);');
|
|
||||||
AddFunction(@ps_filterTPADistEx, 'procedure FilterTPADistEx(var TPA: TPointArray; maxL, maxW: integer);');
|
|
||||||
AddFunction(@ps_filterTPADist, 'procedure FilterTPADist(var TPA: TPointArray; maxDist: integer);');
|
AddFunction(@ps_filterTPADist, 'procedure FilterTPADist(var TPA: TPointArray; maxDist: integer);');
|
||||||
AddFunction(@ps_GetATPABounds,'function GetATPABounds(const ATPA: T2DPointArray): TBox;');
|
AddFunction(@ps_GetATPABounds,'function GetATPABounds(const ATPA: T2DPointArray): TBox;');
|
||||||
AddFunction(@ps_GetTPABounds,'function GetTPABounds(const TPA: TPointArray): TBox;');
|
AddFunction(@ps_GetTPABounds,'function GetTPABounds(const TPA: TPointArray): TBox;');
|
||||||
|
@ -67,8 +67,6 @@ 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 FilterPointsDist(var Points: TPointArray; const MinDist,MaxDist: Extended; Mx, My: Integer);
|
procedure FilterPointsDist(var Points: TPointArray; const MinDist,MaxDist: 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);
|
||||||
procedure FilterTPACustom(var TPA: TPointArray; compare: function(a, b: integer): boolean);
|
|
||||||
procedure FilterTPADistEx(var TPA: TPointArray; maxL, maxW: integer);
|
|
||||||
procedure FilterTPADist(var TPA: TPointArray; maxDist: integer);
|
procedure FilterTPADist(var TPA: TPointArray; maxDist: integer);
|
||||||
function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
|
function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
|
||||||
function GetATPABounds(const ATPA: T2DPointArray): TBox;
|
function GetATPABounds(const ATPA: T2DPointArray): TBox;
|
||||||
@ -1172,36 +1170,37 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{/\
|
{/\
|
||||||
Removes points in the TPA using the funciton 'compare'. If 'compare' returns
|
Removes points in the TPA that are within maxDist of each other.
|
||||||
true, point b is removed from the TPA.
|
|
||||||
/\}
|
/\}
|
||||||
procedure FilterTPACustom(TPA: TPointArray; compare: function(a, b: integer): boolean);
|
procedure FilterTPADist(var TPA: TPointArray; maxDist: integer);
|
||||||
var
|
var
|
||||||
c, i, j, l, h: integer;
|
c, i, j, l, h, maxDistSq: integer;
|
||||||
newTPA: TPointArray;
|
newTPA: TPointArray;
|
||||||
inBadElements: TBooleanArray;
|
inBadElements: TBooleanArray;
|
||||||
begin
|
begin
|
||||||
h := high(TPA);
|
h := high(TPA);
|
||||||
l := (h + 1); // i.e. length(TPA);
|
l := (h + 1);
|
||||||
|
maxDistSq := (maxDist * maxDist);
|
||||||
|
|
||||||
setLength(inBadElements, l);
|
setLength(inBadElements, l);
|
||||||
setLength(newTPA, l);
|
setLength(newTPA, l);
|
||||||
|
|
||||||
for i := 0 to h do
|
for i := 0 to h do
|
||||||
inBadElements[i] := false; // just in case..
|
inBadElements[i] := false;
|
||||||
|
|
||||||
for i := 0 to (h - 1) do
|
for i := 0 to (h - 1) do
|
||||||
begin
|
begin
|
||||||
if (inBadElements[i]) then // increases speed significantly
|
if (inBadElements[i]) then
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for j := (i + 1) to h do
|
for j := (i + 1) to h do
|
||||||
begin
|
begin
|
||||||
if (inBadElements[j]) then // increases speed significantly
|
if (inBadElements[j]) then
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (compare(TPA[i], TPA[j])) then
|
// simplified -> a^2 + b^2 <= c^2
|
||||||
inBadElements[j] := true;
|
if (((TPA[i].x - TPA[j].x) * (TPA[i].x - TPA[j].x)) + ((TPA[i].y - TPA[j].y) * (TPA[i].y - TPA[j].y)) <= maxDistSq) then
|
||||||
|
inBadElements[j] := true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1219,30 +1218,6 @@ begin
|
|||||||
TPA := newTPA;
|
TPA := newTPA;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{/\
|
|
||||||
Removes points in the TPA that are within maxL or maxW of each other.
|
|
||||||
/\}
|
|
||||||
procedure FilterTPADistEx(var TPA: TPointArray; maxL, maxW: integer);
|
|
||||||
function lwComp(a,b: TPoint): Boolean;
|
|
||||||
begin
|
|
||||||
result := (abs(a.x-b.x) <= maxW) or (abs(a.y-b.y) <= maxL); // lambda would be nice..
|
|
||||||
end;
|
|
||||||
begin
|
|
||||||
FilterTPACustom(TPA, @lwComp);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{/\
|
|
||||||
Removes points in the TPA that are within 'maxDist' of each other.
|
|
||||||
/\}
|
|
||||||
procedure FilterTPADist(var TPA: TPointArray; maxDist: integer);
|
|
||||||
function distComp(a, b: TPoint): boolean;
|
|
||||||
begin
|
|
||||||
result := (((a.x-b.x)*(a.x-b.x)) + ((a.y-b.y)*(a.y-b.y)) <= (maxDist*maxDist));
|
|
||||||
end;
|
|
||||||
begin
|
|
||||||
FilterTPACustom(TPA, @distComp);
|
|
||||||
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.
|
||||||
/\}
|
/\}
|
||||||
|
Loading…
Reference in New Issue
Block a user