unit Unit3; { This software has been designed and it is CopyLefted by Han de Bruijn: (===) @-O^O-@ #/_\# ### DELAUNAY TESSELLATION FIELD ESTIMATOR TEST ========================================== } INTERFACE uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Algemeen, Grafisch, Shamos, Sterren, PaulBourke; type TForm1 = class(TForm) Image1: TImage; procedure Toetsdruk(Sender: TObject; var Key: Char); procedure Scheppen(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; IMPLEMENTATION {$R *.dfm} var even : boolean; { Make your choice } procedure tekenen(M,N,veel : integer); { Calculate and Draw } var zero : double; i,j,k,L,F,t : integer; rij : punten; mesh : drietal; r : punt; DTFE : dubbel; a,b,c : punt3D; p,q : punt; OK : boolean; begin Voorbeeld(M,N-1,rij,mesh); { Sample mesh } Form1.Image1.Canvas.Pen.Color := clGray; Form1.Image1.Canvas.Brush.Color := clGray; for k := 0 to Length(rij)-1 do { Nodes } begin i := x2i(rij[k].x); j := y2j(rij[k].y); Form1.Image1.Canvas.Ellipse(i-2,j-2,i+2,j+2); end; F := Length(mesh); for L := 0 to F-1 do { Triangles } begin i := mesh[L].A; j := mesh[L].B; k := mesh[L].C; Form1.Image1.Canvas.MoveTo(x2i(rij[i].x),y2j(rij[i].y)); Form1.Image1.Canvas.LineTo(x2i(rij[j].x),y2j(rij[j].y)); Form1.Image1.Canvas.LineTo(x2i(rij[k].x),y2j(rij[k].y)); Form1.Image1.Canvas.LineTo(x2i(rij[i].x),y2j(rij[i].y)); omcirkel(rij[i],rij[j],rij[k],r); Form1.Image1.Canvas.Ellipse(x2i(r.x)-2,y2j(r.y)-2,x2i(r.x)+2,y2j(r.y)+2); end; SetLength(DTFE,0); if even then Histogram(rij,mesh,DTFE) { Voronoi method } else Makkelijk(rij,mesh,DTFE); { Delaunay method } Setup_Contours; { Isolines with triangles } Form1.Image1.Canvas.Pen.Color := clRed; for t := 0 to veel do { Contour Levels } begin zero := t/veel; for L := 0 to F-1 do { Triangles } begin i := mesh[L].A; j := mesh[L].B; k := mesh[L].C; a.x := rij[i].x; a.y := rij[i].y; a.z := DTFE[i]-zero; b.x := rij[j].x; b.y := rij[j].y; b.z := DTFE[j]-zero; c.x := rij[k].x; c.y := rij[k].y; c.z := DTFE[k]-zero; OK := Contour_Driehoek(a,b,c,p,q); if not OK then Continue; Form1.Image1.Canvas.MoveTo(x2i(p.x),y2j(p.y)); Form1.Image1.Canvas.LineTo(x2i(q.x),y2j(q.y)); end; end; if even then Form1.Image1.Picture.SaveToFile('acht_V_img.bmp') else Form1.Image1.Picture.SaveToFile('acht_D_img.bmp'); end; procedure TForm1.Toetsdruk(Sender: TObject; var Key: Char); { On KeyPress } begin ClearDevice; even := not even; Tekenen(20,10,11); end; procedure TForm1.Scheppen(Sender: TObject); { At moment of creation } begin xmin := -1.1; xmax := +1.1; ymin := -1.1; ymax := +1.1; TV(Form1.Image1); even := true; ClearDevice; Tekenen(20,10,11); end; END.