SRL Archive - Research & Development Lounge

KillBoxes


caused

2009-08-31 04:36:52

I'll let the image talk :'D



Basicly i'm looking for ideas to improve the performance/efficiency.



// atpax is your atpa, remember to make boxes first with splittpaex or tpatoatpaex for example.
// minw,maxw -> minimum and maximun box width.
// minh, maxh -> min and max box height.
Function FilterATPASize(var ATPAx: T2DPointArray; minw,maxw,minh,maxh:Integer):T2dPointarray;
var
B: TBox;
W,H,i,lengthcounter: Integer;
temp,temp2,temptpa : T2DPointArray;
begin
SortATPASize(ATPAx,True);
setarraylength(temp,length(atpax));
lengthcounter:=0;

for i:= 0 to high(atpax) do
begin

B := GetTPABounds(ATPAx[i]);
W := B.x2 - B.x1;
H := B.y2 - B.y1;
// WriteLn('Box '+inttostr(i)+'dimensions: '+inttostr(W)+'*'+inttostr(H));
If ((W >= minw) AND (W <= maxw) AND (H >= minh) AND (H <= maxh)) then
begin
inc(lengthcounter);
temp[i] := CombineTPA(atpax[i],temp[i]);
// writeLn('Boxes Found: '+inttostr(lengthcounter));
end;

end;
//InvertAtpa(temp);
SetArrayLength(temp,lengthcounter+1);
result := temp;
end;


noidea

2009-08-31 04:56:09

Couldnt you just do an area check, and see if the area is < a certain number?

Sabzi

2009-08-31 13:18:15

Ahh, no credit?
And I wanted to do this today :(
Never mind! I will do it on my way!

marpis

2009-08-31 14:21:11

Looks brilliant, but name could be FilterATPASize?

Naum

2009-08-31 14:25:13

If PointInBox()Then
RemoveDistTPointArray();

?
Anyone?

caused

2009-08-31 22:11:38

noidea: Yes, but that wouldnt filter the boxes in the atpa.

sabzi: hah go ahead :). I'm sure it can be made more efficient :).

marpis: Right, my name is much to aggressive anyways :'D.. I'll take that one if you dont mind :).

nauman: uhm ?___? :D

Baked0420

2009-08-31 22:17:19

wow nice before and after, good piece of little coding. I like it, rep++

Sabzi

2009-08-31 22:54:54

From: caused

sabzi: hah go ahead :). I'm sure it can be made more efficient :).


Done. Although I don't know the efficiency. And I didn't make fancy pictures :p
And mine don't get anything :(
Somehow when I try to contribute I get no replies. Not the first case.

caused

2009-09-02 15:02:38

Baked: Thanks :). It's really brilliant for filtering objects. Gotta writea Tutorial for my function :'D.

Sabzi: Feel Free to post yours so we can compare and maybe merge our functions :).

~caused

Sabzi

2009-09-02 17:33:12

From: caused
Baked: Thanks :). It's really brilliant for filtering objects. Gotta writea Tutorial for my function :'D.

Sabzi: Feel Free to post yours so we can compare and maybe merge our functions :).

~caused


Me thought I have linked it XD
Because it was already complete before I posted here.
I think I forgot to link it.
http://www.villavu.com/forum/showthread.php?t=50206

spicynachos2

2009-09-03 04:09:15

Hmm the image does talk a little but i am confused. Are those all the boxes that the script would find when you ran the procedure?

caused

2009-09-03 04:11:24

From: spicynachos2
Hmm the image does talk a little but i am confused. Are those all the boxes that the script would find when you ran the procedure?


Yes. Thats what it found in this case. It filters boxes by size.

It's a function not a procedure though ;).

~caused

Sabzi

2009-09-03 16:45:59

Mine can filter by more :(
Still no response so I must said something XD