Bug in PntInPoly function ? (Dcal for Delphi)
Posted: Mon Jul 31, 2017 6:48 pm
Hi,
I'm having trouble with the PntInPoly function provided in the DCAL for Delphi libraries. It kept crashing when called in an Offset macro I am writing, so I checked all the passed parameters in Debugger and they all appeared to be initialised with valid values. In desperation I wrote the simple test program as below:
This test program also falls over on the PntInPoly call. It gets the exact same exception as my Offset macro: exception class $C0000005 with message 'access violation at 0x00000000: read of address 0x00000000'.
There seem to be a lot of zeros in the addresses in the error message, which makes me think something might not be initialised?
Perhaps I am doing something wrong and should be initialising something else before making the call? If there is an error in the above code I would be grateful if somebody could help me out. Sometimes I miss the obvious, but at the moment I'm thinking there may be a bug in the D4D function ...
Thanks,
David H
I'm having trouble with the PntInPoly function provided in the DCAL for Delphi libraries. It kept crashing when called in an Offset macro I am writing, so I checked all the passed parameters in Debugger and they all appeared to be initialised with valid values. In desperation I wrote the simple test program as below:
Code: Select all
library Tests;
uses
System.sysutils,
//DCAL for Delphi Header Files
UConstants in '../../Header Files/UConstants.pas',
UInterfaces in '../../Header Files/UInterfaces.pas',
UInterfacesRecords in '../../Header Files/UInterfacesRecords.pas',
URecords in '../../Header Files/URecords.pas',
UVariables in '../../Header Files/UVariables.pas';
{$E dmx} //dmx is the extension for DCAL Dll's
{$R *.res}
function Main(dcalstate : asint; act : action; pl, pargs : Pointer) : wantType; stdcall;
var
testpnt, minpt, maxpt : point;
ply : polyarr;
i : integer;
arg : getIntArg;
res : asInt;
begin
setpoint(testpnt, 0.0);
ply[1].x := -100;
ply[1].y := -100;
ply[2].x := -100;
ply[2].y := 100;
ply[3].x := 100;
ply[3].y := 100;
ply[4].x := 100;
ply[4].y := -100;
for i:= 1 to 4 do ply[i].z := 0.0;
minpt := ply[1];
maxpt := ply[3];
i := pntinpoly(testpnt, ply, 4, minpt, maxpt);
getint (i, arg, res);
Result := XDone;
end;
exports
Main;
begin
end.
This test program also falls over on the PntInPoly call. It gets the exact same exception as my Offset macro: exception class $C0000005 with message 'access violation at 0x00000000: read of address 0x00000000'.
There seem to be a lot of zeros in the addresses in the error message, which makes me think something might not be initialised?
Perhaps I am doing something wrong and should be initialising something else before making the call? If there is an error in the above code I would be grateful if somebody could help me out. Sometimes I miss the obvious, but at the moment I'm thinking there may be a bug in the D4D function ...
Thanks,
David H