Problem while drawing 3D contour and surface
Posted: Sat Nov 14, 2009 11:28 pm
Hello,
I currently have a problem with drawing 3D contour/surface.
I try to read a file which contains 3 colums: x,y and z. While reading (using readln(textfile,x,y,z), I put the data into a Tcontour as follows:
if OpenDialog1.execute then begin
AssignFile(Datafile,OpenDialog1.filename);
Reset(Datafile);
Series1.clear; // Series1 is a TContour
while not(eof(Datafile)) do begin
Readln(Datafile,x,y,z);
Series1.AddXYZ(x,z,z,'',clTeeColor); // add point to the contour
Memo1.Lines.Add(Num2Str(cnt,0,0)+' '+Num2Str(x,2,2) + ' ' + Num2Str(y,2,2) +' ' +Num2Str(z,2,2)); // add values to a TMemo for visualization
end; // end of eof()
CloseFile(Datafile);
end;
The problem is no contour appears on the chart, although the axes correspond to the x and y extents, and the 20 levels legend corresponds to the z values. (please see the attached GIF image).
Just before reading the file, I have tried to populate the chart with for commands, and the following code works:
inherited;
{ First we add XYZ points to the Contour series... }
With Series1 do
begin
Clear;
{ We add values from 0 to 1000. 21x21 cells = 441 }
for x:= -10 to 10 do
for z:= -10 to 10 do
AddXYZ( x, RandomXYZ(x,z) ,z, '', clTeeColor);
end;
I sup
{ Then we specify how many "contour levels" we want }
Series1.NumLevels:=20;
I currently have a problem with drawing 3D contour/surface.
I try to read a file which contains 3 colums: x,y and z. While reading (using readln(textfile,x,y,z), I put the data into a Tcontour as follows:
if OpenDialog1.execute then begin
AssignFile(Datafile,OpenDialog1.filename);
Reset(Datafile);
Series1.clear; // Series1 is a TContour
while not(eof(Datafile)) do begin
Readln(Datafile,x,y,z);
Series1.AddXYZ(x,z,z,'',clTeeColor); // add point to the contour
Memo1.Lines.Add(Num2Str(cnt,0,0)+' '+Num2Str(x,2,2) + ' ' + Num2Str(y,2,2) +' ' +Num2Str(z,2,2)); // add values to a TMemo for visualization
end; // end of eof()
CloseFile(Datafile);
end;
The problem is no contour appears on the chart, although the axes correspond to the x and y extents, and the 20 levels legend corresponds to the z values. (please see the attached GIF image).
Just before reading the file, I have tried to populate the chart with for commands, and the following code works:
inherited;
{ First we add XYZ points to the Contour series... }
With Series1 do
begin
Clear;
{ We add values from 0 to 1000. 21x21 cells = 441 }
for x:= -10 to 10 do
for z:= -10 to 10 do
AddXYZ( x, RandomXYZ(x,z) ,z, '', clTeeColor);
end;
I sup
{ Then we specify how many "contour levels" we want }
Series1.NumLevels:=20;