File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -288,19 +288,27 @@ function TKDPointTree.Nearest(pt:TPoint; notEqual:Boolean=False): TPoint;
288288
289289
290290function TKDPointTree.RawKNearest (pt:TPoint; k:Integer; notEqual:Boolean=False): TNodeRefArray;
291- var i,c:Integer;
291+ var
292+ i,c:Integer;
293+ hidden: TIntegerArray;
292294begin
293295 SetLength(Result, k);
294296 c := 0 ;
295297 while c < k do
296298 begin
297299 Result[c] := self.RawNearest(pt, notEqual);
298300 if Result[c] = nil then break;
299- Result[c]^.hidden := True;
301+ if not Result[c]^.hidden then
302+ begin
303+ Result[c]^.hidden := True;
304+ SetLength(hidden, Length(hidden)+1 );
305+ hidden[High(hidden)] := c;
306+ end ;
300307 inc(c);
301308 end ;
302309
303- for i:=0 to c-1 do Result[i]^.hidden := False;
310+ for i:=0 to High(hidden) do
311+ Result[hidden[i]]^.hidden := False;
304312 SetLength(Result, c);
305313end ;
306314
You can’t perform that action at this time.
0 commit comments