Solved

Drawing contours from data supplied on unifrom grid

Posted on 1998-10-15
45
835 Views
Last Modified: 2010-04-03
I am writing a program that models noise. I have a back-end DLL model that produces output into a file with values on a 190 x 190 grid.

I wish to use a TImage and draw on the contours calculated from this output data file. I have found code to do this in Fortran and BASIC but am looking for one in Delphi 3.

I can read the file into a 2 dimensional array. What I want is a routine to draw the contour lines onto the TImage. Full points if you can supply this.

Cheers

Ian
0
Comment
Question by:iwatkins
  • 23
  • 12
  • 4
  • +4
45 Comments
 

Author Comment

by:iwatkins
ID: 1342996
Edited text of question
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342997
why not using TeeChart for this purpose? there is everything you need!
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342999
Hi,

Why making a descendant of TImage, if all these good graphing charts exist!

TChart is standard with Delphi... I find this tool the best!!
If you want to now a freeware one, then look at the sources of this one : http://www.torry.ru/vcl/charts/xygraph3.zip

if you've some money you can buy the professional version of TeeChart and it's sources!

And here is an example of drawing on a TImage (with source!)

http://www.torry.ru/vcl/graphics/mathimge.zip

Regards, Zif.
0
 

Author Comment

by:iwatkins
ID: 1343000
Sorry ZifNab, should have made it clearer. I have looked at the various URLs supplied above. But I will actually be drawing on a TImage type layer with ESRI MapObjects OCX GIS. Hence I need to be able to read my file into an array and say:

(Pseudo Code)
Loop Array
  Moveto(x,y)
  DrawLineTo(x,y,color,width)
  DrawLineTo(x,y,color,width)
  ...
  ...
  etc.
End Loop

TeeChart4.0 is very good but not suited to my needs.

Anymore ideas ?

Cheers

Ian
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343001
mmm... have you looked at the source code of

http://www.torry.ru/vcl/graphics/mathimge.zip

It's a descendant of TImage. So there I'm sure you'll find it.
But I'll look at another way.

Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343002
Hi iwatkins,

what's the problem with writing on screen? here is a little code which draws an ellips on a timage :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with Image1 do begin
    Canvas.brush.color := clRed;
    Canvas.brush.style := bsDiagCross;
    Canvas.Ellipse(0, 0, Image1.Width, Image1.Height);
  end;
end;
end.

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343003
here is a little example of drawing lines, from point to point :

procedure TForm1.BitBtn1Click(Sender: TObject);
var i, j : integer;
begin
Test[1,1] := 10;
Test[2,1] := 10;
Test[1,2] := 100;
Test[2,2] := 10;
Test[1,3] := 100;
Test[2,3] := 100;
Test[1,4] := 10;
Test[2,4] := 100;
with Image1 do begin
    Canvas.pen.color := clRed;
    Canvas.MoveTo(Test[1,1],Test[2,1]);
    For i := 2 to 4 do begin
     Canvas.LineTo(Test[1,i],Test[2,i]);
    end;
  end;
end;

Changing the color and width can be easely done by making a new function LineToEx(x,y, color, width) in which we change the color and width of the line and then draw the line.

Besides, why don't you use PolyDraw... etc?

Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343004
Or use Polygon... the only drawback here is that you can change the color from point to point..., But Polygon already takes an array of TPoints...

iwatkins, am I helping you with this or is this all rubbish for you? Do I've to look to something other (Am I missing the point here?)

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343005
i meant  CAN'T change the color!
0
 

Author Comment

by:iwatkins
ID: 1343006
ZifNab

All this drawing stuff is fine, I can do this no problem. What I need is the contouring code. I.e. a file containing 190 x 190 grid, at each grid point is a value. Draw the 'grid' to the screen but draw lines between euqal valuse, like you see of the weather pressure charts.

Hope that is more clear.
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1343007
Hi iwatkins

This is very interesting.  I have never seen a program that can take numbers from a matrix (the 190x190 grid) and get contour lines.  The closest thing I've seen is for each number in the matrix to be represented by a different color, which allows you to see the contours.

You say you have code in Fortran & Basic which does what you need.  Does it actually draw the lines?

You have me interested in this, partly because of a project I worked on a while back.  I'll look into it...

Cheers,
JB
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1343008
Soo... we're talking about isobars/altitude contours here???
I just wrote an extensive example that I was about to send you, but I'll just have to scrap it now since I was stupid enough to misunderstand your wishes.
Isobars, huuh... Have to scratch my head on that one for a while...

/// John
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343009
Hi iwatkins,

 Can't we just iterate through the grid (aray) and then if the value is the same as the other we draw a line to it?

The best way (at the moment I can think of) is to iterate from outside to inside of the grid... Pick up a value and start drawing... Then if value is used, change it to one which never be looked at...

Another way is using masks.... These masks are passed over the grid and we do some calculations on it... Which gives us another grid. This mask enhances the changes, and reduces the equals.... At the end you only get the border lines (your isobares...)

I even think I've a example of this one here .

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343010
ok, here is some stuff I digged up, let me know if you all find this usefull...

example

000000
000000
000000
003333
003333
003333
003333

now use these filters :

A -1-1    B -11
   1 1      -11

This gives us :

000000       000000
000000       000000
036666       030000
000000       060000
000000       060000
000000       060000

We combine the two :

000000
000000
066666
060000
060000
060000

And viola we get our contour...

Offcourse better filters exist! and other methods, this is just the easy one...

iwatkins, the data in the grid, does it follow some rules?
if it is, then we can better use the iterate method.

Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343011
The filter stuff is hard bussiness now... and you got all in basic?

Can't we just translate the basic stuff to delphi?

Zif
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343012
hey, TeeChart 4.0 has contour series!

New Series types

TRadarSeries ( "spider" charts )
TContourSeries ( 3D contouring )  <-------!!!!!!!!!!!!!!!
TWindRoseSeries ( WindRose polar )
TClockSeries ( Analogic Clock )
TPoint3DSeries ( 3D scatter with optional 3D lines )
TBezierSeries (point smoothing)

Look here for some pics!! Contour= available!!!

http://www.teemach.com/tee4/tee4beta.htm#NewTContourSeries

On this page you can find 2D AND 3D contour examples!!!!

heck, I was right, TeeChart has it !!

Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343013
iwatkins et al.

Seems that I'm only talking to myself at the moment... nobody is around at the moment... well, then I stop too... see you later!

iwatkins, I think TeeChart is the one you need (like I said in my first comment :-)). But if you still want to make it yourself, I still will help you on this subject. Although, I always find reïnventing the wheel not so good for progress (if the wheel is good offcourse (and not so expensive :-))

Let me know..

Zif.


0
 
LVL 4

Expert Comment

by:erajoj
ID: 1343014
I'm still on it...

/// John
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343015
Um... If you have the algorithms already done in BASIC and FORTRAN, converting these to Delphi should be fairly easy...



0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1343016
Hi,

I work in a land survey company which has software for mapping hillsides and roads from a set of irregular longitudes, latitudes and heights. The points do not form a grid, but this is how we do it.

First we take the set of points and form a triangle surface model using the Delauney triangluation algorithm. I won't go into this, if you are interested, then look it up on the net.

So that gave me a set of irregular triangles. You already have a set of squares (since you have regular gridded data) so that will do.

Now choose a contour interval, say 100 metres.

The trick now is to traverse each square one by one. The order you do this is not important.

At each square, take the left edge (from pt1 to pt2). Say the heights are 90 and 110. The interpolated contour is halfway between pt1 and pt2 (remember the height is 100).
Now do the same for the other edges, and draw a line between matching contours. You'll find that adjacent squares will match up, and you'll have contours (made of line segments).

If you want *real* contours (not line segments), then you'll have to remember the interpolated positions for a cell and it's adjacent cells and draw free form curves, beziers or splines.

This is not trivial to do, and there are special cases that you'll discover along the way that you'll have to resolve.

You'd be saving yourself time and effort by translating the BASIC code. I suggest you explore this approach further.

Good luck,
Phil.

0
 

Author Comment

by:iwatkins
ID: 1343017
OK ALL,

Thanks to you all so far.

Zif, TeeChart won't do as I don't want to but it just to draw contours. Also, I need to be able to do it myself, because I will be using a 3rd party component to draw them, namely ESRI's MapObjects OCX.

Phil, glad you understand the problem. The method Zif outlined works in simple cases but I don't think handles cols.

All, see the following URL for the FORTRAN and BASIC source code:
http://www.mhri.edu.au/~pdb/unixsoftware/conrec/  for one technique.

Any further help would be most welcome.

Phil, you are right again. i will eventually be using bezier curves to conect the points.

Cheers

Ian
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343018
Ian,

As you will be using Bezier curves etc you are looking at a whole new ball game. Doesn't ESRI MapObjects do contouring for you. Just give it the points and whoila!

Cheers,

Raymond.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:iwatkins
ID: 1343019
Raymond

If you know how to do this let me know. I can 'load' map files as Shape files but I can't see a way to do as you suggest. ?

Cheers

Ian
0
 
LVL 5

Expert Comment

by:inter
ID: 1343020
Hi friends,
this issue is very related to my academic work-if I do not misinterpret-. I have my connection down for a week so just have a chance to attend now. Any way the regular way of doing such things in image processing is called EDGE DETECTION. mainly you extract a edge map from the image as Zif gives the clues. In the case of real-world complex scenes, there are sophisticated methods of edge detection. One of the most involved one is called Canny Edge Detecter by Canny who is one of the earliest goods of image processing and computer vision. So much for the history, what we can done is as follows-assuming that original image is 8 bit gray- do

1 - Smoothing : apply basic weighted smoothing filter over image the kernel could be 3x3 because the image small (is 190x190)
2 - Apply the basic edge detector for example Sobel or Roberts
3 - Treshold the result to obtain binary image
4 - On the binary image apply basic line detection and obtain control points for the lines. Here we approximate all edges by lines. The other approximation are out of scope as far as the problem is concerned but can be embedded later. SO construct the CHAIN CODES for each countour and store them...
5 - Having obtained the chain codes coresponding to image edges draw each cluster on the image.

Apperantly the method above requires much effort. However it can be tailored if the characteristics of your images are known. If your images does not contain too many  abrupt changes and intensity variation. The image you have obtained at the end of step 3 can be TRANSPARENTLY overlaped with the original image and you have what you seek...

regards, Igor
NOTE :I'd like to see your data but my email system is down, and I do not think I could follow up the discussion regularly so just want to give an idea about how these thing are done from academic approach
0
 
LVL 5

Expert Comment

by:inter
ID: 1343021
HI ALL,
my email and internet connection is back...I can analyze one of your images and try to find the optimum way according to your data if you want. So if you want to sent the data to me mail me -indicate the file format please- one of your images...
inter@kosgeb.tekmer.gov.tr
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343022
How are we so far? Still need that translation? I'm back for a while.. Zif.
0
 

Author Comment

by:iwatkins
ID: 1343023
Hi All,

No code forthcoming on this. Contrary to what some people think the data file is not an image file, it looks a bit like this:

190,345,367,678......
5,344,278,567.....
.....
...

with 190 values on each row and 190 rows.

Cheers

Ian
0
 
LVL 5

Expert Comment

by:inter
ID: 1343024
Every visualization task is related with images so we can assume your 2D data as image. If you want code it is comming -this is my very standart edge detector you should fine tune it according to your data-

Assumtions:
1 - You have a 2d array if integers called Map and resulting 2d map called ResMap
2 - Upon calling the following proc you should load image into Map
3 - The following function tries to obtain edge data of Map with 0 coresponding to background and 255 coresponding to the foreground- edges-

var
  Map, ResMap : T190Map; //I expect you to declare this as your needs  

// Edge detector using 3x3 truncated laplacian kernel
//   1 -1  1
//  -1  0 -1
//   1 -1  1
// at the end values below threshold are set to 0 and up are set to 255
// you can convert the ResMap into Bitmap and display it
const
  EdgeMap = array[-1..1,-1..1] of integer =
((1,-1,1),(-1,0,-1),(1,-1,1));
procedure EdgeExt(Treshold : integer);
var
  i,j,k,l, sum : integer;
begin
  // consider the edge effects and leave the borders empty
  for i := 2 to 187 do
    for j := 2 to 187 do
    begin
      sum := 0;
      for k := -1 to 1 do  
        for l := -1 to 1 do
          sum := sum + EdgeMap[k,l] * Image[i+k,j+l];
      if sum > threshold then sum := 255
      else sum := 0;
      ResMap[i,j] := sum;
    end;
end;

You should experiment with Treshold to find a reasonable treshold
regards, igor
0
 
LVL 5

Expert Comment

by:inter
ID: 1343025
I'd like to make the structure a bit easy since I have time, the following is same but returns the edge map in TBitmap instead(do not forget to release the bitmap returned)

function EdgeExt(Treshold : integer): TBitmap;
var
  i,j,k,l, sum : integer;
  CurPix : PByte;
begin
  Result := TBitmap.Create;
  Result.pixelformat := pf8bit;
  Result.Width := 190;
  Result.Height:= 190;
  // consider the edge effects and leave the borders empty
  for i := 2 to 187 do
  begin
    CurPix := PByte(Result.ScanLine[i]);
    for j := 2 to 187 do
    begin
      sum := 0;
      for k := -1 to 1 do  
       for l := -1 to 1 do
        sum := sum + EdgeMap[k,l] * Image[i+k,j+l];
      if sum > threshold then sum := 255
      else sum := 0;
      CurPix^ := sum; Inc(CurPix);
    end;
  end;
end;
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343026
hehe, inter, filter seems familiar to me... you are totally correct, a laplacian filter is better...
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343027
ok, just answered the q'n to draw attetion from iwatkins...

sorry Inter, but I followed another way (don't think its usefull that we both work on the same method). I took the easiest one and translated the method proposed by iwatkins (I hope it's correct translated, but thats why I'm here now). I hope that you 've some succes with the filter-method. Let us know! I'll bet that the filter is better than this method, but more difficult!

Now it's on test-phase so I would like to get a test pattern (i.e. data array + z-contour array) from you iwatkins... I also can send the translated (buggy?) code to you so you can test it yourself... but then you have to give me a mail address.

Regards, Zif.

Send it to Tom.Deprez@village.uunet.be (I'm there after 20.00 o'clock)

Let me know when you did send it.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343028
ok, just answered the q'n to draw attetion from iwatkins...

sorry Inter, but I followed another way (don't think its usefull that we both work on the same method). I took the easiest one and translated the method proposed by iwatkins (I hope it's correct translated, but thats why I'm here now). I hope that you 've some succes with the filter-method. Let us know! I'll bet that the filter is better than this method, but more difficult!

Now it's on test-phase so I would like to get a test pattern (i.e. data array + z-contour array) from you iwatkins... I also can send the translated (buggy?) code to you so you can test it yourself... but then you have to give me a mail address.

Regards, Zif.

Send it to Tom.Deprez@village.uunet.be (I'm there after 20.00 o'clock)

Let me know when you did send it.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343029
euhm 20.00 o' clock is 10:37 AM PDT
0
 

Author Comment

by:iwatkins
ID: 1343030
Sorry Guys,

I'm out of the office this week, so haven't had time to test any code yet. (Had to scrounge so web time off a customer to do this !!)

I'll be back in the office on Friday and will test some of the answers posted here.

Cheers

Ian
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343031
heck Ian,

can't you even just send us some test files, before you go to home?????
f***, why did I translated this! sorry, for my language, here.

Zif.
0
 

Author Comment

by:iwatkins
ID: 1343032
Hi All,

back in the office after an awful week. Haven't yet tested above stuff but I have produced a test data file:

http://www.netcomuk.co.uk/~iwatkins/test.csv

this is a 15 x 15 test file. Let me know how you get on with it. It is comma delimited.

Cheers

Ian
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343033
Hi iwatkins,

 Hope life is better now (after awful week).

 I paste here the source I translated... I must say, I haven't tested it at all! the problem is, that I don't know what the result has to be of your test-file and thus not know if the source works...

 For the translated source you need two things :

 1. Your data
 2. Z data.

Let me know if there are some troubles!


unit Conrec;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Math, StdCtrls, ExtCtrls;


 const
   im : array[0..3] of integer = (0,1,1,1);
   jm : array[0..3] of integer = (0,1,1,1);
   castab : array[0..2,0..2,0..2] of integer = (((0,0,8),(0,2,5),(7,6,9))
                                                ,((0,3,4),(1,3,1),(4,3,0))
                                                ,((9,6,7),(5,2,0),(8,0,0)));
 
  nc  = 10;  // for simplification!
   iub = 190; // for simplification!
   jub = 190; // for simplification!

 type
  TfConrec = class(TForm)
    Panel1: TPanel;
    Start: TButton;
    Memo1: TMemo;
    procedure StartClick(Sender: TObject);
  private
    { Private declarations }
    h : array[0..4] of double;
    sh : array[0..4] of integer;  // sign of h
  public
    { Public declarations }
    iub, jub : integer;
    xh : array[0..3] of double;
    yh : array[0..3] of double;
    x : array[0..iub] of double;     // data array for column coördinates
    y : array[0..jub] of double;     // data array for row coördinates
    z : array[0..nc-1] of integer; // contour levels in increasing order
    procedure Init;
    function InputError: boolean;
    procedure ScanArray;
  end;

var
  fConrec: TfConrec;

implementation
{$R *.DFM}

procedure TfConrec.Init;
begin
 // fill in matrixes here!
 // x,y matrix, z matrix
end;

function TfConrec.InputError:boolean;
var c : integer;
begin
 result := false;
 if (iub<=0) or (jub<=0) then result := true;
 if (nc<=0) or (nc>11) {//Change} then result := true;
 for c:=1 to nc-1 do begin
  if (z[c] <= z[c-1]) then result:= true
 end;
end;

procedure TfConrec.ScanArray;
var i,j,k : integer;
    d : array[0..1,0..1] of double;
    dMin, dMax : double;
    x1, y1, x2, y2 : double;
    m, m1, m2, m3, case_value : integer;

begin
 for j:=jub-1 downto 0 do begin
  for i:=0 to iub-1 do begin
   { find the lowest vertex }
    if (d[i,j] < d[i, j+1]) then
     dMin := d[i, j]
      else dMin := d[i, j+1];
    if (d[i+1,j] < dMin) then
     dMin := d[i+1,j];
    if (d[i+1, j+1] < dMin) then
     dMin := d[i+1, j+1];
    { find the highest vertex }
    if (d[i,j] > d[i, j+1]) then
     dMax := d[i, j]
      else dMin := d[i, j+1];
    if (d[i+1,j] > dMax) then
     dMax := d[i+1,j];
    if (d[i+1, j+1] > dMax) then
     dMax := d[i+1, j+1];

  { Test if in box }
   if not((dMax < z[0]) or (dMin > z[nc-1])) then begin
    { Draw each contour within this box }
    for k:= 0 to nc-1 do begin
     if not((z[k]<dMin) or (z[k]>dMax)) then begin
      for m:= 4 downto 0 do begin
       if (m > 0) then begin
        h[m]:=d[(i+im[m-1]), (j+jm[m-1])]-z[k];
        xh[m] := x[(i+im[i-1])];
        yh[m] := y[(j+jm[m-1])];
       end
        else begin
         h[0] := 0.24*(h[1]+h[2]+h[3]+h[4]);
         xh[0] := 0.5*(x[i]+x[i+1]);
         yh[0] := 0.5*(y[j]+y[j+1]);
        end;
       if (h[m] > 0) then sh[m] := 1
        else if (h[m]<0) then sh[m]:= -1
         else sh[m] := 0;
      end; {end m}

     { Scan each triangle in the box }
      for m:=1 to 4 do begin
       m1 := m;
       m2 := 0;
       m3 := m+1;
       if m3=5 then m3:=1;
       case_value := castab[sh[m1]+1,sh[m2]+1,sh[m3]+1];
       case case_value of
       { Line between vertices m1 and m2 }
        1 : begin
             x1 := xh[m1];
             y1 := yh[m1];
             x2 := xh[m2];
             y2 := yh[m2];
            end;
       { Line between vertices m2 and m3 }
        2 : begin
             x1 := xh[m2];
             y1 := yh[m2];
             x2 := xh[m3];
             y2 := yh[m3];
            end;
       { Line between vertices m3 and m1 }
        3 : begin
             x1 := xh[m3];
             y1 := yh[m3];
             x2 := xh[m1];
             y2 := yh[m1];
            end;
       { Line between vertex m1 and side m2-m3 }
        4 : begin
             x1 := xh[m1];
             y1 := yh[m1];
             x2 := (h[m3]*xh[m2]-h[m2]*xh[m3])/(h[m3]-h[m2]);
             y2 := (h[m3]*yh[m2]-h[m2]*yh[m3])/(h[m3]-h[m2]);
            end;
       { Line between vertex m2 and side m3-m1 }
        5 : begin
             x1 := xh[m2];
             y1 := yh[m2];
             x2 := (h[m1]*xh[m3]-h[m3]*xh[m1])/(h[m1]-h[m3]);
             y2 := (h[m1]*yh[m3]-h[m3]*yh[m1])/(h[m1]-h[m3]);
            end;
       { Line between vertex m3 and side m1-m2 }
        6 : begin
             x1 := xh[m3];
             y1 := yh[m3];
             x2 := (h[m2]*xh[m1]-h[m1]*xh[m2])/(h[m2]-h[m1]);
             y2 := (h[m2]*yh[m1]-h[m1]*yh[m2])/(h[m2]-h[m1]);
            end;
       { Line between sides m1-m2 and m2-m3 }
        7 : begin
             x1 := (h[m2]*xh[m1]-h[m1]*xh[m2])/(h[m2]-h[m1]);
             y1 := (h[m2]*yh[m1]-h[m1]*yh[m2])/(h[m2]-h[m1]);
             x2 := (h[m3]*xh[m2]-h[m2]*xh[m3])/(h[m3]-h[m2]);
             y2 := (h[m3]*yh[m2]-h[m2]*yh[m3])/(h[m3]-h[m2]);
            end;
       { Line between sides m2-m3 and m2-m3 }
        8 : begin
             x1 := (h[m3]*xh[m2]-h[m2]*xh[m3])/(h[m3]-h[m2]);
             y1 := (h[m3]*yh[m2]-h[m2]*yh[m3])/(h[m3]-h[m2]);
             x2 := (h[m1]*xh[m3]-h[m3]*xh[m1])/(h[m1]-h[m3]);
             y2 := (h[m1]*yh[m3]-h[m3]*yh[m1])/(h[m1]-h[m3]);
            end;
       { Line between sides m3-m1 and m1-m2 }
        9 : begin
             x1 := (h[m1]*xh[m3]-h[m3]*xh[m1])/(h[m1]-h[m3]);
             y1 := (h[m1]*yh[m3]-h[m3]*yh[m1])/(h[m1]-h[m3]);
             x2 := (h[m2]*xh[m1]-h[m1]*xh[m2])/(h[m2]-h[m1]);
             y2 := (h[m2]*yh[m1]-h[m1]*yh[m2])/(h[m2]-h[m1]);
            end;
       end; {end case}

    { ************** Call here the draw or other routine! ******************* }
       memo1.lines.add('Draw line from point ['+FloatToStr(x1)+', '
                                        + FloatToStr(y1)+'] to point ['
                                        + FloatToStr(x2)+', '
                                        + FloatToStr(y2)+'] with height ['
                                        + IntToStr(z[k]));

      end; {end m}
     end;
    end; {end k}
   end; {end inbox}
  end; {end iub}
 end; {end jub}
end;

procedure TfConrec.StartClick(Sender: TObject);
begin
 Init;
 if InputError then showmessage('Given values are not totally correct');
 ScanArray;
 showmessage('finished!');
end;

end.

Ok, after you tested it, we can make it better... e.g. better coding, sort method for z-array, dynamic arrays... maybe even a component

Regards, Zif.
0
 

Author Comment

by:iwatkins
ID: 1343034
Nice.

Have it working.

Everything is good :-)

I guess you are right. It could be tweaked a bit, some file handling to read in the data and z-order etc. Maybe a component ?

Anyway, I am happy with all this and will probably do some further development myself.

Thanks to all, but the points go to Zif.

Cheers

Ian
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 500 total points
ID: 1343035
Hi Ian,

 Great, it works! Did you need to make some changes to the code?
 If you don't mind then I'll make a component of it. Just say what you need extra, etc... It would be great making a component of it.

Regards, Zif.
0
 

Author Comment

by:iwatkins
ID: 1343036
Hi All

I don't seem to be able to grade Zif's answer. The only options available to me are:

 1. Increase points
 2. Add a comment
 3. Checkbox for Email

So how do I award the points ?

Cheers

Ian
0
 

Author Comment

by:iwatkins
ID: 1343037
OK, panic over.

Found the way to add the points to you Zif.

If you do make a component of it, let me know.

For features, I would suggest it was a non-visible component that you loaded the gridded data into plus the Z-order stuff. It then produces a 'list' of commands to draw onto whatever component (TImage, TPanel etc. anything that can take line drawing commands). Also make the component, very easy to use with loads of examples. And then post the whole thing to DSP and Torry's

Good luck Zif

Cheers

Ian
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343038
Ok Ian, I'll work on it.

PS. was the code ok that way, or did you've to change something.
If so let me know what you've changed.

Regards, Zif.
0
 

Author Comment

by:iwatkins
ID: 1343039
Code was fine.

Obviously I added some code to read the data file in and some code to draw on a TImage etc. but apart from that it seemed to work OK. I haven't fully tested it yet, but will let you know if I find anything wrong.

Cheers

Ian
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343040
Ok, thanks for letting me know. Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343041
iwatkins, it's strange I think I get funny stuff here. Or maybe I just expect something else? Can you send me some examples with there results? Can you send all the input parameters also? So I know what I've to look for. Zif.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now