SRL Archive - Help

TPA Filter


Nexz

2013-01-13 14:58:19

I need to remove points from a TPA that are outside of a box.

I made something like this:

for II := 0 to High(TPA1) do
if (InRange(TPA1[II].X, Box1.X1, Box1.X2) and InRange(TPA1[II].Y, Box1.Y1, Box1.Y2)) then
TPA4 := CombineTPA(TPA4, [TPA1[II]]);

It works but it's slow. Is there a faster way?

Ty.

Le Jingle

2013-01-13 15:37:46


Function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray;

Afaik, this will do what I presume you are looking/asking for.
Simply put your TPA that you want, TotalTPA, and then the Box that you want, Box -> and use this function to assign a TPA of points that you do not want. Next line could be ClearTPAFromTPA.

Altogether it might looking something like this:

procedure doSomething;
var
b : TBox;
TPA, clearPoints : TPointArray;
begin
b := IntToBox(0, 0, 2, 2);
TPA := [Point(1,1), Point(5,5), Point(10,10)];
clearPoints := ReturnPointsNotInTPA(TPA, b);
ClearTPAFromTPAWrap(TPA, clearPoints, TPA);
Writeln(TPA);
end;
Wrote this in browser, so may not work, but should give an idea.

-Lj