Page 1 of 1

Tsurface contour effect

Posted: Mon Apr 28, 2014 9:04 am
by 16567936
Hello,

I want to draw a round surface with a hole inside.
The result is not what I expect. There are side effects at the contour.
Is there a way to remove these drawings not very nice and which are not par tof the real surface ?

Image

I joined an example code.
It runs under Delphi XE2 VCL and teechart 2013

Thanks in advance.

Nicolas

Re: Tsurface contour effect

Posted: Mon Apr 28, 2014 1:49 pm
by yeray
Hello Nicolas,

I'm not sure if this is what you where looking for but if I comment the last AddXYZ call in your code, I get this:
2014-04-28_1546.png
2014-04-28_1546.png (181.55 KiB) Viewed 4538 times

Code: Select all

  n := 10;
  Series1.Clear;
  for i := -n to n do
  begin
    for j := -n to n do
    begin
      r := sqrt(sqr(i)+sqr(j));
      if (r<=n) then
      begin
        if (r>4) then
        begin
         Series1.AddXYZ(i, Cos(2*pi*r/n), j);
        end else
         Series1.AddXYZ(i, 0, j, '', clNone);
      end else
//         Series1.AddXYZ(i, 0, j, '', clNone);
    end;
  end;
If this is not what you where trying to draw, please try to highlight what exact polygons you find to be not expected given the data you've entered.
Thanks in advance.

Re: Tsurface contour effect

Posted: Tue Apr 29, 2014 9:23 am
by 16567936
Hello,

Thank you for your answer, it's what I want to get. I want too that the contour of the hole inside has not this effect.
HoleEffect.png
HoleEffect.png (137.6 KiB) Viewed 4523 times
I tried your correction, but I've got a violation access (I just comment the last AddXYZ line).
Maybe I have a wrong installation because if I don't fill all the points of the series (it means 10x10 points), I have this access violation.
First I've just wanted to add points where the data are valid.
ViolationAccess.png
ViolationAccess.png (21.52 KiB) Viewed 4527 times
I think it should be possible to fill the series with any number of points. So I don't understand this behavior.
My goal is to draw a surface in which there are holes with any number of points.

Nicolas

Re: Tsurface contour effect

Posted: Tue Apr 29, 2014 10:38 am
by yeray
Hi Nicolas,

If I remove another line I get this:
2014-04-29_1232.png
2014-04-29_1232.png (152.13 KiB) Viewed 4511 times
Here is the code I have:

Code: Select all

procedure TForm2.BDisplayClick(Sender: TObject);
var i, j : integer;
    n : integer;
    r : double;
begin
  n := 10;
  Series1.Clear;
  for i := -n to n do
  begin
    for j := -n to n do
    begin
      r := sqrt(sqr(i)+sqr(j));
      if (r<=n) then
      begin
        if (r>4) then
        begin
         Series1.AddXYZ(i, Cos(2*pi*r/n), j);
        end; {else
         Series1.AddXYZ(i, 0, j, '', clNone);}
      end; {else
         Series1.AddXYZ(i, 0, j, '', clNone);}
    end;
  end;
end;
And here the complete project:
TeeChartTest.zip
(1.95 KiB) Downloaded 312 times
Maybe you are not using the latest TeeChart version, are you?
What IDE are you using?

You could also try setting IrregularGrid to true. See this for more info on how to populate this kind of series.

Re: Tsurface contour effect

Posted: Tue Apr 29, 2014 11:22 am
by 16567936
Hello,

I was using Delphi XE2 with Teechart VCL 2013.
I installed the new version 2014 of Teechart for XE2 and it solved my issue of violation access.

Now I will try to customize my drawing by removing the line and by smoothing the colors between cells.

Thank you for your answers.

Best regards

Nicolas