mirror of
https://github.com/moparisthebest/Simba
synced 2025-02-07 02:30:19 -05:00
FindRotatedDTM now has Alternating or Start-End search routines.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@570 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
f336a20625
commit
a2df7c159b
@ -44,7 +44,7 @@ uses
|
||||
ColorBox , about, framefunctionlist, ocr, updateform, simbasettings;
|
||||
|
||||
const
|
||||
SimbaVersion = 569;
|
||||
SimbaVersion = 570;
|
||||
|
||||
type
|
||||
|
||||
|
@ -48,14 +48,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps_FindDTMRotated(DTM: Integer; out x, y: Integer; x1, y1, x2, y2:
|
||||
function ps_FindDTMRotatedAlternating(DTM: Integer; out x, y: Integer; x1, y1, x2, y2:
|
||||
Integer; sAngle, eAngle, aStep: Extended;
|
||||
out aFound: Extended): Boolean; extdecl;
|
||||
var
|
||||
temp: pDTM;
|
||||
begin
|
||||
if CurrThread.Client.MDTM.GetDTM(DTM, temp) then
|
||||
Result := CurrThread.Client.MFinder.FindDTMRotated(temp, x, y, x1, y1, x2, y2, sAngle, eAngle, aStep, aFound)
|
||||
Result := CurrThread.Client.MFinder.FindDTMRotated(temp, x, y, x1, y1, x2, y2, sAngle, eAngle, aStep, aFound,true)
|
||||
else
|
||||
begin
|
||||
x := 0;
|
||||
@ -64,13 +64,40 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps_FindDTMsRotated(DTM: Integer; out Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray): Boolean; extdecl;
|
||||
function ps_FindDTMRotatedSE(DTM: Integer; out x, y: Integer; x1, y1, x2, y2:
|
||||
Integer; sAngle, eAngle, aStep: Extended;
|
||||
out aFound: Extended): Boolean; extdecl;
|
||||
var
|
||||
temp: pDTM;
|
||||
begin
|
||||
if CurrThread.Client.MDTM.GetDTM(DTM, temp) then
|
||||
Result := CurrThread.Client.MFinder.FindDTMRotated(temp, x, y, x1, y1, x2, y2, sAngle, eAngle, aStep, aFound,false)
|
||||
else
|
||||
begin
|
||||
x := 0;
|
||||
y := 0;
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps_FindDTMsRotatedAlternating(DTM: Integer; out Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray): Boolean; extdecl;
|
||||
var
|
||||
temp: pDTM;
|
||||
begin
|
||||
if CurrThread.Client.MDTM.GetDTM(DTM, temp) then
|
||||
Result := CurrThread.Client.MFinder.FindDTMsRotated(temp, Points, x1, y1, x2, y2,
|
||||
sAngle, eAngle, aStep, aFound, 0)
|
||||
sAngle, eAngle, aStep, aFound, 0,true)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function ps_FindDTMsRotatedSE(DTM: Integer; out Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray): Boolean; extdecl;
|
||||
var
|
||||
temp: pDTM;
|
||||
begin
|
||||
if CurrThread.Client.MDTM.GetDTM(DTM, temp) then
|
||||
Result := CurrThread.Client.MFinder.FindDTMsRotated(temp, Points, x1, y1, x2, y2,
|
||||
sAngle, eAngle, aStep, aFound, 0,false)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
@ -35,8 +35,10 @@ AddFunction(@ps_DTMFromString, 'function DTMFromString(DTMString: String): Integ
|
||||
AddFunction(@ps_FreeDTM, 'procedure FreeDTM(DTM: Integer);');
|
||||
AddFunction(@ps_FindDTM, 'function FindDTM(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;');
|
||||
AddFunction(@ps_FindDTMs, 'function FindDTMs(DTM: Integer; var p: TPointArray; x1, y1, x2, y2: Integer): Boolean;');
|
||||
AddFunction(@ps_FindDTMRotated, 'function FindDTMRotated(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended): Boolean;');
|
||||
AddFunction(@ps_FindDTMsRotated, 'function FindDTMsRotated(DTM: Integer; var Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; var aFound: T2DExtendedArray) : Boolean;');
|
||||
AddFunction(@ps_FindDTMRotatedSE, 'function FindDTMRotatedSE(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended): Boolean;');
|
||||
AddFunction(@ps_FindDTMRotatedAlternating, 'function FindDTMRotatedAlternating(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended): Boolean;');
|
||||
AddFunction(@ps_FindDTMsRotatedSE, 'function FindDTMsRotatedSE(DTM: Integer; var Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; var aFound: T2DExtendedArray) : Boolean;');
|
||||
AddFunction(@ps_FindDTMsRotatedAlternating, 'function FindDTMsRotatedAlternating(DTM: Integer; var Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; var aFound: T2DExtendedArray) : Boolean;');
|
||||
AddFunction(@ps_addDTM, 'function AddDTM(d: TDTM): Integer;');
|
||||
AddFunction(@ps_addpDTM, 'function AddpDTM(d: pDTM): Integer;');
|
||||
|
||||
|
@ -84,8 +84,8 @@ type
|
||||
|
||||
function FindDTM(DTM: pDTM; out x, y: Integer; x1, y1, x2, y2: Integer): Boolean;
|
||||
function FindDTMs(DTM: pDTM; out Points: TPointArray; x1, y1, x2, y2, maxToFind: Integer): Boolean;
|
||||
function FindDTMRotated(DTM: pDTM; out x, y: Integer; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended): Boolean;
|
||||
function FindDTMsRotated(_DTM: pDTM; out Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray; maxToFind: Integer): Boolean;
|
||||
function FindDTMRotated(DTM: pDTM; out x, y: Integer; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended; Alternating : boolean): Boolean;
|
||||
function FindDTMsRotated(_DTM: pDTM; out Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray; maxToFind: Integer; Alternating : boolean): Boolean;
|
||||
//Donno
|
||||
function GetColors(Coords: TPointArray): TIntegerArray;
|
||||
// tol speeds
|
||||
@ -2048,13 +2048,13 @@ begin
|
||||
Result := (pc > 0);
|
||||
end;
|
||||
|
||||
function TMFinder.FindDTMRotated(DTM: pDTM; out x, y: Integer; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended): Boolean;
|
||||
function TMFinder.FindDTMRotated(DTM: pDTM; out x, y: Integer; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended; Alternating : boolean): Boolean;
|
||||
|
||||
var
|
||||
P: TPointArray;
|
||||
F: T2DExtendedArray;
|
||||
begin
|
||||
FindDTMsRotated(dtm, P, x1, y1, x2, y2, sAngle, eAngle, aStep, F, 1);
|
||||
FindDTMsRotated(dtm, P, x1, y1, x2, y2, sAngle, eAngle, aStep, F, 1,Alternating);
|
||||
if Length(P) = 0 then
|
||||
exit(false);
|
||||
aFound := F[0][0];
|
||||
@ -2063,7 +2063,7 @@ begin
|
||||
Exit(True);
|
||||
end;
|
||||
|
||||
function TMFinder.FindDTMsRotated(_DTM: pDTM; out Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray; maxToFind: Integer): Boolean;
|
||||
function TMFinder.FindDTMsRotated(_DTM: pDTM; out Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray; maxToFind: Integer; Alternating : boolean): Boolean;
|
||||
var
|
||||
DTM: pDTM;
|
||||
// Colours of DTMs
|
||||
@ -2093,6 +2093,12 @@ var
|
||||
|
||||
PtrData: TRetData;
|
||||
|
||||
//If we search alternating, we start in the middle and then +,-,+,- the angle step outwars
|
||||
MiddleAngle : extended;
|
||||
//Count the amount of anglesteps, mod 2 determines whether it's a + or a - search, and div 2 determines the amount of steps
|
||||
//you have to take.
|
||||
AngleSteps : integer;
|
||||
|
||||
// point count
|
||||
pc: Integer = 0;
|
||||
ac: Integer = 0;
|
||||
@ -2155,8 +2161,13 @@ begin
|
||||
cd := CalculateRowPtrs(PtrData, h + 1);
|
||||
SetLength(aFound, 0);
|
||||
SetLength(Points, 0);
|
||||
|
||||
s := sAngle;
|
||||
if Alternating then
|
||||
begin
|
||||
MiddleAngle := (sAngle + eAngle) / 2.0;
|
||||
s := MiddleAngle; //Start in the middle!
|
||||
AngleSteps := 0;
|
||||
end else
|
||||
s := sAngle;
|
||||
while s < eAngle do
|
||||
begin
|
||||
dtm := RotateDTM(_dtm, s);
|
||||
@ -2222,8 +2233,16 @@ begin
|
||||
goto theEnd;
|
||||
AnotherLoopEnd:
|
||||
end;
|
||||
s := s + aStep;
|
||||
ac := 0;
|
||||
if Alternating then
|
||||
begin
|
||||
if AngleSteps mod 2 = 0 then //This means it's an even number, thus we must add a positive step
|
||||
s := MiddleAngle + (aStep * (anglesteps div 2 + 1)) //Angle steps starts at 0, so we must add 1.
|
||||
else
|
||||
s := MiddleAngle - (aStep * (anglesteps div 2 + 1)); //We must search in the negative direction
|
||||
inc(AngleSteps);
|
||||
end else
|
||||
s := s + aStep;
|
||||
end;
|
||||
TheEnd:
|
||||
TClient(Client).IOManager.FreeReturnData;
|
||||
|
Loading…
Reference in New Issue
Block a user