- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
function TMFinder.FindDTMs(DTM: TMDTM; out Points: TPointArray; x1, y1, x2, y2, maxToFind: Integer): Boolean;
var
Len: integer;
DPoints: PMDTMPoint;
b: array of array of Integer;
ch: array of array of integer;
W, H: integer;
MA: TBox;
MaxX, MaxY: integer;
xx, yy: integer;
i, xxx, yyy: Integer;
StartX, StartY, EndX, EndY: integer;
cd: TPRGB32Array;
PtrData: TRetData;
pc: Integer = 0;
Found: boolean;
goodPoints: array of Boolean;
col_arr, tol_arr: array of Integer;
ctsinfoarray: TCTSInfoArray;
compare: TCTSCompareFunction;
label
theEnd;
begin
MA := ValidMainPointBox(DTM, x1, y1, x2, y2);
Len := dtm.Count;
DPoints := dtm.PPoints;
setlength(goodPoints, Len);
for i := 0 to Len - 1 do
goodPoints[i] := not DPoints[i].bp;
W := x2 - x1;
H := y2 - y1;
setlength(b, (W + 1));
setlength(ch, (W + 1));
for i := 0 to W do
begin
setlength(ch[i], (H + 1));
FillChar(ch[i][0], SizeOf(Integer) * (H + 1), 0);
setlength(b[i], (H + 1));
FillChar(b[i][0], SizeOf(Integer) * (H + 1), 0);
end;
PtrData := TClient(Client).IOManager.ReturnData(x1, y1, W + 1, H + 1);
SetLength(col_arr, Len);
SetLength(tol_arr, Len);
for i := 0 to Len - 1 do
begin
col_arr[i] := DPoints[i].c;
tol_arr[i] := DPoints[i].t;
end;
ctsinfoarray := Create_CTSInfoArray(col_arr, tol_arr);
compare := Get_CTSCompare(Self.CTS);
cd := CalculateRowPtrs(PtrData, h + 1);
MA.x1 := MA.x1 - x1;
MA.y1 := MA.y1 - y1;
MA.x2 := MA.x2 - x1;
MA.y2 := MA.y2 - y1;
MaxX := x2 - x1;
MaxY := y2 - y1;
for yy := MA.y1 to MA.y2 do
for xx := MA.x1 to MA.x2 do
begin
for i := 0 to Len - 1 do
begin
Found := false;
StartX := max(0, xx - DPoints[i].asz + DPoints[i].x);
StartY := max(0, yy - DPoints[i].asz + DPoints[i].y);
EndX := Min(MaxX, xx + DPoints[i].asz + DPoints[i].x);
EndY := Min(MaxY, yy + DPoints[i].asz + DPoints[i].y);
for xxx := StartX to EndX do
begin
for yyy := StartY to EndY do
begin
if ch[xxx][yyy] and (1 shl i) = 0 then
begin
ch[xxx][yyy] := ch[xxx][yyy] or (1 shl i);
if compare(ctsinfoarray[i], @ cd[yyy][xxx]) then
b[xxx][yyy] := b[xxx][yyy] or (1 shl i);
end;
if (b[xxx][yyy] and (1 shl i) <> 0) then
begin
if GoodPoints[i] then
begin
Found := true;
break;
end
else
goto AnotherLoopEnd;
end;
end;
if Found then
Break;
end;
if (not found) and (GoodPoints[i]) then
goto AnotherLoopEnd;
end;
ClientTPA[pc] := Point(xx + x1, yy + y1);
Inc(pc);
if (pc = maxToFind) then
goto theEnd;
end;
TheEnd: Free_CTSInfoArray(ctsinfoarray);
Комментарии (0) RSS