unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls,Math,Delau,Types; type TForma = class(TForm) Image1: TImage; Edit1: TEdit; Label1: TLabel; Point: TSpeedButton; Ligne: TSpeedButton; PLigne: TSpeedButton; Polygone: TSpeedButton; Button1: TButton; Memo1: TMemo; BitBtn1: TBitBtn; BitBtn2: TBitBtn; Timer1: TTimer; BitBtn3: TBitBtn; Memo2: TMemo; Memo3: TMemo; SpeedButton1: TSpeedButton; SpeedButton2: TSpeedButton; SpeedButton3: TSpeedButton; SpeedButton5: TSpeedButton; LabeledEdit1: TLabeledEdit; Label2: TLabel; Button2: TButton; Button3: TButton; SpeedButton4: TSpeedButton; SpeedButton6: TSpeedButton; SpeedButton7: TSpeedButton; SpeedButton9: TSpeedButton; Memo4: TMemo; SpeedButton10: TSpeedButton; Memo5: TMemo; Button4: TButton; SpeedButton11: TSpeedButton; Button5: TButton; Label3: TLabel; SpeedButton8: TSpeedButton; BitBtn4: TBitBtn; Memo6: TMemo; Button6: TButton; procedure Edit1Change(Sender: TObject); procedure Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Image1DblClick(Sender: TObject); procedure PointClick(Sender: TObject); procedure LigneClick(Sender: TObject); procedure PLigneClick(Sender: TObject); procedure PolygoneClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure SpeedButton5Click(Sender: TObject); procedure SpeedButton2Click(Sender: TObject); procedure SpeedButton3Click(Sender: TObject); procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure SpeedButton1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure SpeedButton4Click(Sender: TObject); procedure SpeedButton6Click(Sender: TObject); procedure SpeedButton7Click(Sender: TObject); procedure SpeedButton9Click(Sender: TObject); procedure SpeedButton10Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure SpeedButton11Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure SpeedButton8Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure Button6Click(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } end; Type TPoint=Record X,Y:integer; end; Type Objet=Record Nature : String; ListePoint:array of Unit1.TPoint; end; Type PointR=Record X,Y:real; end; Type ObjetR=Record Nature : String; ListePoint:array of PointR; end; Type Chemin=Record TA,TP:ptriangle; LesP:array of tpoint; EstFerme,EstSupprime:boolean; end; Type TabPoints=array of unit1.tpoint; var Forma: TForma; ListeObjets:array of Objet; ListeObjetsR:array of ObjetR; NouvelObjet:String; Sweep:integer; clique:integer; MaxX,MaxY,MinX,MinY:Integer; Enveloppe:array of TPoint; ptanglobant:types.tpoint; Chemins:array of Chemin; function DistPoint(P1,P2:tpoint):real; function DistSegment(P,P1,P2:tPoint;M:tmemo):real; function homothetie(T:array of unit1.tpoint;f:real):TabPoints; function DansPolygone(p,pinfini:ppoint):boolean; procedure RectangleAnglobant(o:objet;out minx,miny,maxx,maxy:integer); implementation function TriangleAnglobant(o:objet):TabPoints; var b1,b2:real; x1,x2,x3,y1,y2,y3,i,X,Y:integer; p,pp,ppp:ppoint; ListPP: array of ppoint; T:TabPoints; mnx,mny,mxx,mxy,ymx,ymn:integer; begin RectangleAnglobant(o,mnx,mny,mxx,mxy); ymx:=500-mny;ymn:=500-mxy; b1:=ymx-mnx; b2:=ymx+mxx; x1:=trunc((b2-b1)/2);y1:=trunc(x1+b1); x2:=trunc(ymn-b1);y2:=ymn; x3:=trunc(-ymn+b2);y3:=ymn; setlength(T,3);T[0].X:=x1;T[0].Y:=500-y1;T[1].X:=x2;T[1].Y:=500-y2;T[2].X:=x3;T[2].Y:=500-y3; T:=homothetie(T,2); {just pour le besoin de supptriangles}ptanglobant.x:=T[0].x;ptanglobant.Y:=T[0].Y; setlength(Delau.ListePoint,0); setlength(Delau.Listetriangle,0); Delau.maxPoint:=0; Delau.maxTriangle:=0; p:=Delau.AddPoint(T[0].X,T[0].Y);pp:=Delau.AddPoint(T[1].X,T[1].Y);ppp:=Delau.AddPoint(T[2].X,T[2].Y); Delau.AddTriangle(Delau.CreateTriangle(p,pp,ppp)); TriangleAnglobant:=t; end; procedure RectangleAnglobant(o:objet;out minx,miny,maxx,maxy:integer); var i,N:Integer; MxX,MxY,MnX,MnY:integer; begin MxX:=o.ListePoint[0].X;MxY:=o.ListePoint[0].Y;MnX:=o.ListePoint[0].X;MnY:=o.ListePoint[0].Y;//Initialisation N:=length(o.ListePoint); for i:=1 to N-1 do begin if MxXo.ListePoint[i].X then MnX:=o.ListePoint[i].X; if MnY>o.ListePoint[i].Y then MnY:=o.ListePoint[i].Y; end; minx:=mnx;miny:=mny;maxx:=mxx;maxy:=mxy; end; function DansPolygone(p,pinfini:ppoint):boolean; var i,x,y,compteur,n:integer; p1,p2:pPoint; d1,d2:tDroite; begin new(p1);new(p2); //Premiere droite forma.image1.Canvas.Pen.Color:=clred;forma.image1.Canvas.Ellipse(p.X-2,p.Y-2,p.X+2,p.Y+2); d1.a:=(p.y-pinfini.y); d1.b:=-(p.x-pinfini.x); d1.c:=-(d1.a*p.x+d1.b*p.y); forma.image1.Canvas.Pen.Color:=clblue; for x:=0 to 500 do for y:=0 to 500 do if abs(((d1.a*x)+(d1.b*y)+d1.c))<=2 then forma.image1.Canvas.Ellipse(X-2,Y-2,X+1,Y+1); compteur:=0;n:=length(ListeObjets[0].listepoint); for i:=0 to n-1 do begin p1.X:=ListeObjets[0].listepoint[i].X;p1.Y:=ListeObjets[0].listepoint[i].Y; p2.X:=ListeObjets[0].listepoint[(i+1) mod n].X;p2.Y:=ListeObjets[0].listepoint[(i+1) mod n].Y; //Deuxieme droite d2.a:=(p1.y-p2.y); d2.b:=-(p1.x-p2.x); d2.c:=-(d2.a*p1.x+d2.b*p1.y); forma.image1.Canvas.Pen.Color:=clred; for x:=0 to 500 do for y:=0 to 500 do if abs(((d2.a*x)+(d2.b*y)+d2.c))<=2 then forma.image1.Canvas.Ellipse(X-2,Y-2,X+1,Y+1); if (not ptsMemeCotedeD(p,pinfini,d2))and(not ptsMemeCotedeD(p1,p2,D1)) then inc(compteur); end; if compteur mod 2 <>0 then DansPolygone:=true else DansPolygone:=false; //showmessage(inttostr(compteur)); end; function homothetie(T:array of unit1.tpoint;f:real):TabPoints; var i,N:integer; TT:TabPoints; X,Y:real; begin //*************Centre de Gravité X,Y N:=length(T); For i:=0 to N-1 do begin X:=X+T[i].X; Y:=Y+T[i].Y; end; X:=X/N;Y:=Y/N; //**************Homotetie setlength(TT,N); For i:=0 to N-1 do Begin TT[i].X:=trunc(F*T[i].X+X*(1-F)); TT[i].Y:=trunc(F*T[i].Y+Y*(1-F)); End; homothetie:=TT; end; function DistPoint(P1,P2:tpoint):real; begin DistPoint:=sqrt(sqr(P2.X-P1.X)+sqr(P2.Y-P1.Y)); end; function DistSegment(P,P1,P2:tPoint;M:tmemo):Real; Var Angle:double; begin DistSegment:=abs(((P1.Y-P2.Y)*P.X+ (P2.X-P1.X)*P.Y+ (P1.X*P2.Y-P2.X*P1.Y))/ sqrt(sqr(P2.X-P1.X)+sqr(P2.Y-P1.Y))); if DistPoint(P1,P)*DistPoint(P,P2)=0 then DistSegment:=0 else begin Angle:=(((P1.X-P.X)*(P1.X-P2.X))+((P1.Y-P.Y)*(P1.Y-P2.Y)))/(DistPoint(P1,P)*DistPoint(P1,P2)); //L'angle 1 //M.Lines.Add(FloatToStr(Angle)); //M.Lines.SaveToFile('d:\bbbb'); //If ABS(angle)=1 then angle:=0.99*Angle; if angle>1 then angle:=1; if angle<-1 then angle:=-1; Angle:=radtodeg(arccos(Angle)); if Angle>90 then DistSegment:=DistPoint(P1,P); Angle:=round((((P2.X-P.X)*(P2.X-P1.X))+((P2.Y-P.Y)*(P2.Y-P1.Y)))/(DistPoint(P2,P)*DistPoint(P2,P1))); //L'angle 2 //if abs(angle)>1 then showmessage(floattostr(angle))else if angle>1 then angle:=1; if angle<-1 then angle:=-1; Angle:=radtodeg(arccos(Angle)); if Angle>90 then DistSegment:=DistPoint(P2,P); end; end; {$R *.dfm} procedure TForma.Edit1Change(Sender: TObject); var B:TColor; begin B:=Image1.Canvas.Brush.Color; Image1.Canvas.Brush.Color:=86186240; Sweep:=strtoint(Edit1.Text); Image1.Canvas.MoveTo(0,Sweep); Image1.Canvas.LineTo(Image1.Width,Sweep); end; procedure TForma.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Point.Flat then begin Point.Flat:=false; SetLength(ListeObjets,length(ListeObjets)+1); ListeObjets[length(ListeObjets)-1].Nature:='P'; SetLength(ListeObjets[length(ListeObjets)-1].ListePoint,1); ListeObjets[length(ListeObjets)-1].ListePoint[0].X:=X; ListeObjets[length(ListeObjets)-1].ListePoint[0].Y:=Y; Image1.Canvas.Ellipse(X,Y,X+4,Y+4); end; if Ligne.Flat then begin inc(clique); if clique=1 then begin SetLength(ListeObjets,length(ListeObjets)+1); ListeObjets[length(ListeObjets)-1].Nature:='L'; Image1.Canvas.MoveTo(X,Y); end; SetLength(ListeObjets[length(ListeObjets)-1].ListePoint,clique); ListeObjets[length(ListeObjets)-1].ListePoint[clique-1].X:=X; ListeObjets[length(ListeObjets)-1].ListePoint[clique-1].Y:=Y; if clique=2 then begin Ligne.Flat:=false;clique:=0;Image1.Canvas.LineTo(X,Y);end; end; if PLigne.Flat then begin inc(clique); if clique=1 then begin SetLength(ListeObjets,length(ListeObjets)+1); ListeObjets[length(ListeObjets)-1].Nature:='PL'; Image1.Canvas.MoveTo(X,Y); end; SetLength(ListeObjets[length(ListeObjets)-1].ListePoint,clique); ListeObjets[length(ListeObjets)-1].ListePoint[clique-1].X:=X; ListeObjets[length(ListeObjets)-1].ListePoint[clique-1].Y:=Y; Image1.Canvas.LineTo(X,Y); end; if Polygone.Flat then begin inc(clique); if clique=1 then begin SetLength(ListeObjets,length(ListeObjets)+1); ListeObjets[length(ListeObjets)-1].Nature:='PG'; Image1.Canvas.MoveTo(X,Y); end; SetLength(ListeObjets[length(ListeObjets)-1].ListePoint,clique); ListeObjets[length(ListeObjets)-1].ListePoint[clique-1].X:=X; ListeObjets[length(ListeObjets)-1].ListePoint[clique-1].Y:=Y; Image1.Canvas.LineTo(X,Y); end; end; procedure TForma.Image1DblClick(Sender: TObject); begin if PLigne.Flat then begin PLigne.Flat:=false; clique:=0; end; if Polygone.Flat then begin Polygone.Flat:=false; Image1.Canvas.LineTo(ListeObjets[length(ListeObjets)-1].ListePoint[0].X,ListeObjets[length(ListeObjets)-1].ListePoint[0].Y); clique:=0; end; end; procedure TForma.PointClick(Sender: TObject); begin Point.Flat:=true; end; procedure TForma.LigneClick(Sender: TObject); begin Ligne.Flat:=true; end; procedure TForma.PLigneClick(Sender: TObject); begin PLigne.Flat:=true; end; procedure TForma.PolygoneClick(Sender: TObject); begin Polygone.Flat:=true; end; procedure TForma.FormCreate(Sender: TObject); begin Image1.Canvas.Create; clique:=0; end; procedure TForma.Button1Click(Sender: TObject); var i:integer; begin for i:=0 to length(ListeObjets)-1 do Memo1.Lines.Add(ListeObjets[i].nature); end; procedure TForma.BitBtn1Click(Sender: TObject); var Taille,i,j,k,w:integer; DistSweep,Dist:real; Pix:tPoint; begin for i:= 1 to Image1.Width do //X for j:= 1 to Sweep-1 do //Y , la veritable formule est < sweep mais comme c'est des pix de ce fait discontinue c'est exactement sweep-1, de toute façon c pas comme ça pour le continu for k:= 0 to Length(ListeObjets)-1 do begin DistSweep:=ABS(Sweep-J); Pix.X:=i; Pix.Y:=j; Dist:=-1; if ListeObjets[k].Nature='P' then Dist:=Round(DistPoint(ListeObjets[k].ListePoint[0],Pix)); if ListeObjets[k].Nature='L' then Dist:=Round(DistSegment(Pix,ListeObjets[k].ListePoint[0],ListeObjets[k].ListePoint[1],memo2)); if DistSweep=Dist then Image1.Canvas.Ellipse(I,J,I+2,J+2); if ListeObjets[k].Nature='PL'then for w:=0 to length(ListeObjets[k].ListePoint)-2 do begin Dist:=round(DistSegment(Pix,ListeObjets[k].ListePoint[w],ListeObjets[k].ListePoint[w+1],memo2)); if DistSweep=Dist then Image1.Canvas.Ellipse(I,J,I+2,J+2); end; if ListeObjets[k].Nature='PG'then for w:=0 to length(ListeObjets[k].ListePoint)-1 do begin Dist:=round(DistSegment(Pix,ListeObjets[k].ListePoint[w],ListeObjets[k].ListePoint[(w+1)mod length(ListeObjets[k].ListePoint)],memo2)); if DistSweep=Dist then Image1.Canvas.Ellipse(I,J,I+2,J+2); end; end; end; procedure TForma.BitBtn2Click(Sender: TObject); var H,W:integer; begin H:=Image1.Height; W:=Image1.Width; Image1.Canvas.Brush.Color:=clWhite; Image1.Canvas.Rectangle(0,0,W,H); //setlength(ListeObjets,0); end; procedure TForma.BitBtn3Click(Sender: TObject); begin Timer1.Enabled:=not Timer1.Enabled; end; procedure TForma.Timer1Timer(Sender: TObject); var H,W,I:integer; begin inc(Sweep); Edit1.Text:=inttostr(Sweep); H:=Image1.Height; W:=Image1.Width; Image1.Canvas.Brush.Color:=clWhite; Image1.Canvas.Rectangle(0,0,W,H); Image1.Canvas.MoveTo(0,Sweep); Image1.Canvas.LineTo(Image1.Width,Sweep); for i:=0 to length(ListeObjets)-1do if ListeObjets[i].Nature='P' then Image1.Canvas.Ellipse(ListeObjets[i].ListePoint[0].X,ListeObjets[i].ListePoint[0].Y,ListeObjets[i].ListePoint[0].X+3,ListeObjets[i].ListePoint[0].Y+3) else if ListeObjets[i].Nature='L' then begin Image1.Canvas.MoveTo(ListeObjets[i].ListePoint[0].X,ListeObjets[i].ListePoint[0].Y); Image1.Canvas.LineTo(ListeObjets[i].ListePoint[1].X,ListeObjets[i].ListePoint[1].Y);end else if ListeObjets[i].Nature='PL' then for w:=0 to length(ListeObjets[i].ListePoint)-2 do begin Image1.Canvas.MoveTo(ListeObjets[i].ListePoint[w].X,ListeObjets[i].ListePoint[w].Y); Image1.Canvas.LineTo(ListeObjets[i].ListePoint[w+1].X,ListeObjets[i].ListePoint[w+1].Y); end else if ListeObjets[i].Nature='PG' then for w:=0 to length(ListeObjets[i].ListePoint)-1 do begin Image1.Canvas.MoveTo(ListeObjets[i].ListePoint[w].X,ListeObjets[i].ListePoint[w].Y); Image1.Canvas.LineTo(ListeObjets[i].ListePoint[(w+1)mod length(ListeObjets[i].ListePoint)].X,ListeObjets[i].ListePoint[(w+1)mod length(ListeObjets[i].ListePoint)].Y); end; BitBtn1.Click; end; procedure TForma.SpeedButton5Click(Sender: TObject); var i,N:integer; T,G:array of Unit1.TPoint; X,Y,F:real; begin F:=strtofloat(LabeledEdit1.Text); //*************Centre de Gravité X,Y N:=length(ListeObjets[0].ListePoint); For i:=0 to N-1 do begin X:=X+ListeObjets[0].ListePoint[i].X; Y:=Y+ListeObjets[0].ListePoint[i].Y; end; X:=X/N;Y:=Y/N; //**************Homotetie setlength(G,N); For i:=0 to N-1 do Begin G[i].X:=trunc(F*ListeObjets[0].ListePoint[i].X+X*(1-F)); G[i].Y:=trunc(F*ListeObjets[0].ListePoint[i].Y+Y*(1-F)); End; //*************Affichage For i:=1 to N do begin Image1.Canvas.MoveTo(G[i-1].X,G[i-1].Y); Image1.Canvas.LineTo(G[i mod (n)].X,G[i mod (n)].Y); end; {on a pas toujours une homotetie autour de l'objet d'origine, c'est à cause du centre de gravité, MP'=k*MP, les segments ne sont peut etre pas proportionnels} end; procedure TForma.SpeedButton2Click(Sender: TObject); var i,N:Integer; begin MaxX:=ListeObjets[0].ListePoint[0].X;MaxY:=ListeObjets[0].ListePoint[0].Y;MinX:=ListeObjets[0].ListePoint[0].X;MinY:=ListeObjets[0].ListePoint[0].Y;//Initialisation N:=length(ListeObjets[0].ListePoint); for i:=1 to N-1 do begin if MaxXListeObjets[0].ListePoint[i].X then MinX:=ListeObjets[0].ListePoint[i].X; if MinY>ListeObjets[0].ListePoint[i].Y then MinY:=ListeObjets[0].ListePoint[i].Y; end; Image1.Canvas.Brush.Style:= BsClear; Image1.Canvas.Rectangle(MaxX,MaxY,MinX,MinY); end; procedure TForma.SpeedButton3Click(Sender: TObject); var MaX,MiX,MaY,MiY,LongX,LongY,i,s1,s2,dx,dy:integer; begin LongX:=MaxX-MinX; LongY:=MaxY-MinY; S2:=LongX*LongY; //Rectangle Englobant s1:=0; for i:=0 to length(ListeObjets[0].ListePoint)-1 do begin S1:=S1+((ListeObjets[0].ListePoint[i].X*ListeObjets[0].ListePoint[(i+1) mod length(ListeObjets[0].ListePoint)].Y)); S1:=S1-((ListeObjets[0].ListePoint[i].Y*ListeObjets[0].ListePoint[(i+1) mod length(ListeObjets[0].ListePoint)].X)); end; S1:=trunc(abs(S1)/2); //Objet Dx:=trunc(((1-(S1/S2))*LongX)/2); Dy:=trunc(((1-(S1/S2))*LongY)/2); MaX:=MaxX-Dx;MiX:=MinX+Dx; MaY:=MaxY-Dy;MiY:=MinY+Dy; Image1.Canvas.Brush.Style:= BsClear; Image1.Canvas.Rectangle(MaX,MaY,MiX,MiY); end; procedure TForma.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Label2.Caption:=inttostr(X)+' '+inttostr(Y); end; procedure TForma.SpeedButton1Click(Sender: TObject); var i:integer; Amax,A:Real; P,PminY,Pred,PAmax:TPoint; begin PminY.Y:=ListeObjets[0].ListePoint[0].Y; For i :=1 to length(ListeObjets[0].ListePoint)-1 do if ListeObjets[0].ListePoint[i].YP.X)and(ListeObjets[0].ListePoint[i].Y<>P.Y) then begin A:=(((P.X-Pred.X)*(P.X-ListeObjets[0].ListePoint[i].X))+((P.Y-Pred.Y)*(P.Y-ListeObjets[0].ListePoint[i].Y)))/(DistPoint(P,Pred)*DistPoint(P,ListeObjets[0].ListePoint[i])); //Pred P i ***P P1 P2 A:=abs(radtodeg(arccos(A))); if A>Amax then begin Amax:=A; PAmax:=ListeObjets[0].ListePoint[i];end; end; end; Pred:=P; P:=PAmax; until (P.X=PMinY.X)and(P.Y=PMinY.Y); end; procedure TForma.Button2Click(Sender: TObject); var i:integer; begin For i:=1 to length(Enveloppe) do begin Image1.Canvas.MoveTo(Enveloppe[i-1].X,Enveloppe[i-1].Y); Image1.Canvas.LineTo(Enveloppe[i mod (length(Enveloppe))].X,Enveloppe[i mod (length(Enveloppe))].Y); Image1.Canvas.TextOut(Enveloppe[i-1].X,Enveloppe[i-1].Y,inttostr(i-1)); end; end; procedure TForma.Button3Click(Sender: TObject); var i:integer; begin image1.Canvas.pen.color:=clred; //image1.Canvas.brush.color:=clwhite; For i:=1 to length(ListeObjets[0].ListePoint) do begin Image1.Canvas.MoveTo(ListeObjets[0].ListePoint[i-1].X,ListeObjets[0].ListePoint[i-1].Y); Image1.Canvas.LineTo(ListeObjets[0].ListePoint[i mod (length(ListeObjets[0].ListePoint))].X,ListeObjets[0].ListePoint[i mod (length(ListeObjets[0].ListePoint))].Y); Image1.Canvas.TextOut(ListeObjets[0].ListePoint[i-1].X,ListeObjets[0].ListePoint[i-1].Y,inttostr(i-1)); end; end; procedure TForma.SpeedButton4Click(Sender: TObject); var b1,b2:real; x1,x2,x3,y1,y2,y3,ymax,ymin,i,X,Y:integer; p,pp,ppp:ppoint; ListPP: array of ppoint; T:TabPoints; begin ymax:=500-miny;ymin:=500-maxy; b1:=ymax-minx; b2:=ymax+maxx; x1:=trunc((b2-b1)/2);y1:=trunc(x1+b1); x2:=trunc(ymin-b1);y2:=ymin; x3:=trunc(-ymin+b2);y3:=ymin; Image1.Canvas.MoveTo(x1,500-y1); Image1.Canvas.LineTo(x3,500-y3); Image1.Canvas.LineTo(x2,500-y2); Image1.Canvas.LineTo(x1,500-y1); setlength(T,3);T[0].X:=x1;T[0].Y:=500-y1;T[1].X:=x2;T[1].Y:=500-y2;T[2].X:=x3;T[2].Y:=500-y3; T:=homothetie(T,2); {just pour le besoin de supptriangles}ptanglobant.x:=T[0].x;ptanglobant.Y:=T[0].Y; Image1.Canvas.MoveTo(T[0].x,T[0].y); Image1.Canvas.LineTo(T[1].x,T[1].y); Image1.Canvas.LineTo(T[2].x,T[2].y); Image1.Canvas.LineTo(T[0].x,T[0].y); //**********afficher les etiquettes des points Image1.Canvas.TextOut(x1,500-y1,'P1');Image1.Canvas.TextOut(x2,500-y2,'P2');Image1.Canvas.TextOut(x3,500-y3,'P3'); //************ setlength(Delau.ListePoint,0); setlength(Delau.Listetriangle,0); //Delau.ListePoint:=ListePoint; Delau.maxPoint:=0; Delau.maxTriangle:=0; //Delau.Listetriangle:=0; p:=Delau.AddPoint(T[0].X,T[0].Y);pp:=Delau.AddPoint(T[1].X,T[1].Y);ppp:=Delau.AddPoint(T[2].X,T[2].Y); //for i:=0 to length(Delau.ListePoint)-1 do showmessage(inttostr(listepoint[i].X)+' '+inttostr(listepoint[i].Y)); // cre les deux triangles initiaux Delau.AddTriangle(Delau.CreateTriangle(p,pp,ppp)); end; procedure TForma.SpeedButton6Click(Sender: TObject); var i:integer; p:tpoint; begin { PROBLEMME AVEC LES POINTS ALA ISTIKAMA WAHIDA , ET PROBLEMME DE SUPPERPOSITION DES TRIANGLES A L4INTERIEUR} for i:=0 to length(ListeObjets[0].ListePoint)-1 do begin p:=ListeObjets[0].ListePoint[i]; Delau.Algorythm_Delaunay(p.X,p.Y); //ShowMessage(inttostr(i)); end end; procedure TForma.SpeedButton7Click(Sender: TObject); var i,x,y:integer; points:array[0..2] of Types.tpoint; p:ppoint; begin image1.Canvas.Brush.Style:=bssolid; image1.Canvas.Brush.color:=clwhite; image1.Canvas.FillRect(image1.ClientRect); for i:=0 to Delau.maxTriangle-1 do begin p:=Delau.listetriangle[i].p1; points[0].X:=p.X; points[0].Y:=p.Y; p:=Delau.listetriangle[i].p2; points[1].X:=p.X; points[1].Y:=p.Y; p:=Delau.listetriangle[i].p3; points[2].X:=p.X; points[2].Y:=p.Y; image1.Canvas.pen.color:=clblack; image1.Canvas.brush.color:=clwhite; image1.Canvas.Polygon(points); end; end; procedure TForma.SpeedButton9Click(Sender: TObject); var d1,d2:tDroite; pt1,pt2,pt3,pcg,pinf:pPoint; p:types.tpoint; i,N:integer; begin {RAJOUTER AUSSI L4INTERSECTION} SpeedButton2.Click; SpeedButton4.Click; SpeedButton6.Click; new(pt1);new(pt2);new(pt3);new(pinf);pinf^:=ptanglobant;new(pcg); N:=length(Listetriangle); i:=0; while(i<=n-1) do begin pt1.X:=Listetriangle[i].p1.X;pt1.Y:=Listetriangle[i].p1.Y; pt2.X:=Listetriangle[i].p2.X;pt2.Y:=Listetriangle[i].p2.Y; pt3.X:=Listetriangle[i].p3.X;pt3.Y:=Listetriangle[i].p3.Y; p.x:=(pt1.x+pt2.x+pt3.x)div 3;p.y:=(pt1.y+pt2.y+pt3.y)div 3; pcg.X:=p.X; pcg.Y:=p.Y; if not(DansPolygone(pcg,pinf))then Delau.DelTriangle(Listetriangle[i]) else inc(i); N:=length(Listetriangle); end; BitBtn2.Click; SpeedButton7.Click; end; procedure TForma.SpeedButton10Click(Sender: TObject); var i,n,ncf,ncs,nv,v,v1,v2,w,ctr,x,y,it,it2:integer;//ncf nombre de chemins fermés T,pr,sv:ptriangle; M,C,pd,pf:tpoint; begin // le premier chemin, chercher le premier triangle pd.X:=ListeObjets[0].ListePoint[0].x;pd.Y:=ListeObjets[0].ListePoint[0].y; pf.X:=ListeObjets[0].ListePoint[length(ListeObjets[0].ListePoint)-1].x;pf.Y:=ListeObjets[0].ListePoint[length(ListeObjets[0].ListePoint)-1].y; setlength(chemins,1); Chemins[0].TP:=nil;Chemins[0].EstFerme:=false;Chemins[0].EstSupprime:=false; setlength(Chemins[0].LesP,1); Chemins[0].LesP[0].X:=(pd.X+pf.X)div 2;Chemins[0].LesP[0].Y:=(pd.Y+pf.Y)div 2; for i:=0 to length(listetriangle)-1 do begin t:=listetriangle[i]; ctr:=0; if ((listetriangle[i].p1.X=pd.X)and(listetriangle[i].p1.Y=pd.Y))or((listetriangle[i].p1.X=pf.X)and(listetriangle[i].p1.Y=pf.Y)) then inc(ctr); if ((listetriangle[i].p2.X=pd.X)and(listetriangle[i].p2.Y=pd.Y))or((listetriangle[i].p2.X=pf.X)and(listetriangle[i].p2.Y=pf.Y)) then inc(ctr); if ((listetriangle[i].p3.X=pd.X)and(listetriangle[i].p3.Y=pd.Y))or((listetriangle[i].p3.X=pf.X)and(listetriangle[i].p3.Y=pf.Y)) then inc(ctr); if ctr>1 then Chemins[0].TA:=t; end; Image1.Canvas.Ellipse(Chemins[0].LesP[0].X-3,Chemins[0].LesP[0].Y-3,Chemins[0].LesP[0].X+3,Chemins[0].LesP[0].Y+3); ncf:=0;ncs:=0;n:=1;it:=0; while (ncf+ncs nil then Image1.Canvas.Ellipse(t.c.X-3,t.c.Y-3,t.c.X+3,t.c.Y+3); // si t pas nil T:=Chemins[i].TA;// aficher les infor du triangle et du chemin // Compter les voisins de TA nv:=0; if t<> nil then if T.t1<>nil then inc(nv);if T.t2<>nil then inc(nv);if T.t3<>nil then inc(nv); //nv nombre de voisins if T.t1=Chemins[i].TP then pr:=T.t1;if T.t2=Chemins[i].TP then pr:=T.t2;if T.t3=Chemins[i].TP then pr:=T.t3;// TP triangle precedent // si un voisin c'est donc le precedent alors fermer le chemin, ajouter je ne sais pas quoid if (nv=1)and(it<>1) then begin Chemins[i].EstFerme:=true;inc(ncf);end; // sil a un voisin seulement ou si c'est le premier triangle et qu'il a un seul voisin // si deux voisins if (nv=2)or((nv=1) and (it=1)) then begin if (T.t1<>nil)and(T.t1<>pr) then begin M.x:=(T.p2.x+T.p3.x)div 2;M.y:=(T.p2.y+T.p3.y)div 2; sv:=T.t1; Image1.Canvas.TextOut(M.X,M.Y,'V1'); end; if (T.t2<>nil)and(T.t2<>pr) then begin M.x:=(T.p1.x+T.p3.x)div 2;M.y:=(T.p1.y+T.p3.y)div 2; sv:=T.t2;Image1.Canvas.TextOut(M.X,M.Y,'V2');end; if (T.t3<>nil)and(T.t3<>pr) then begin M.x:=(T.p2.x+T.p1.x)div 2;M.y:=(T.p2.y+T.p1.y)div 2; sv:=T.t3;Image1.Canvas.TextOut(M.X,M.Y,'V3');end; setlength(chemins[i].LesP,length(chemins[i].LesP)+1); chemins[i].LesP[length(chemins[i].LesP)-1].X:=M.X; chemins[i].LesP[length(chemins[i].LesP)-1].Y:=M.Y; chemins[i].TA:=sv;chemins[i].TP:=T; end; // si trois voisins if (nv=3) or ((nv=2)and(it=1)) then begin chemins[i].EstSupprime:=true;// supprimer le chemin qui va se bifurquer inc(ncs); c.X:=(t.p1.X+t.p2.X+t.p3.X)div 3;c.Y:=(t.p1.y+t.p2.y+t.p3.Y)div 3;// meme s'il y a t.c et quil marche quand je change le code il peut ne pas marcher setlength(chemins[i].LesP,length(chemins[i].LesP)+1); chemins[i].LesP[length(chemins[i].LesP)-1].X:=C.X; chemins[i].LesP[length(chemins[i].LesP)-1].Y:=C.Y;// ajout du centre de gravité //premier voisin if T.t1<>pr then begin M.x:=(T.p2.x+T.p3.x)div 2;M.y:=(T.p2.y+T.p3.y)div 2; setlength(chemins,length(chemins)+1); chemins[length(chemins)-1].TA:=T.t1;chemins[length(chemins)-1].TP:=T;chemins[length(chemins)-1].EstFerme:=false;chemins[length(chemins)-1].EstSupprime:=false; setlength(chemins[length(chemins)-1].LesP,length(chemins[i].LesP)+1); for w:=0 to length(chemins[i].LesP)-1 do begin chemins[length(chemins)-1].LesP[w].X:=chemins[i].LesP[w].x; chemins[length(chemins)-1].LesP[w].Y:=chemins[i].LesP[w].y; end; chemins[length(chemins)-1].LesP[w].X:=M.X;chemins[length(chemins)-1].LesP[w].Y:=M.Y; end; // deuxieme voisin if T.t2<>pr then begin M.x:=(T.p1.x+T.p3.x)div 2;M.y:=(T.p1.y+T.p3.y)div 2; setlength(chemins,length(chemins)+1); chemins[length(chemins)-1].TA:=T.t2;chemins[length(chemins)-1].TP:=T;chemins[length(chemins)-1].EstFerme:=false;chemins[length(chemins)-1].EstSupprime:=false; setlength(chemins[length(chemins)-1].LesP,length(chemins[i].LesP)+1); for w:=0 to length(chemins[i].LesP)-1 do begin chemins[length(chemins)-1].LesP[w].X:=chemins[i].LesP[w].x; chemins[length(chemins)-1].LesP[w].Y:=chemins[i].LesP[w].y; end; chemins[length(chemins)-1].LesP[w].X:=M.X;chemins[length(chemins)-1].LesP[w].Y:=M.Y; end; // troisieme voisin if T.t3<>pr then begin M.x:=(T.p2.x+T.p1.x)div 2;M.y:=(T.p2.y+T.p1.y)div 2; setlength(chemins,length(chemins)+1); chemins[length(chemins)-1].TA:=T.t3;chemins[length(chemins)-1].TP:=T;chemins[length(chemins)-1].EstFerme:=false;chemins[length(chemins)-1].EstSupprime:=false; setlength(chemins[length(chemins)-1].LesP,length(chemins[i].LesP)+1); for w:=0 to length(chemins[i].LesP)-1 do begin chemins[length(chemins)-1].LesP[w].X:=chemins[i].LesP[w].x; chemins[length(chemins)-1].LesP[w].Y:=chemins[i].LesP[w].y; end; chemins[length(chemins)-1].LesP[w].X:=M.X;chemins[length(chemins)-1].LesP[w].Y:=M.Y; end; end; end; end; end; end; procedure TForma.Button4Click(Sender: TObject); var i,p : integer ; t:ptriangle; S:string; begin for i:=0 to length(listetriangle)-1 do begin t:=listetriangle[i]; S:=inttostr(i)+' '+ 'p1 '+inttostr(t.p1.x)+' '+inttostr(t.p1.y)+' '+ 'p2 '+inttostr(t.p2.x)+' '+inttostr(t.p2.y)+' '+ 'p3 '+inttostr(t.p3.x)+' '+inttostr(t.p3.y)+' '; if t.t1=nil then s:=s+'v1p1 nil' else s:=s+'v1p1 '+inttostr(t.t1.p1.x)+' '+inttostr(t.t1.p1.y)+'v1p2 '+inttostr(t.t1.p2.x)+' '+inttostr(t.t1.p2.y)+'v1p3 '+inttostr(t.t1.p3.x)+' '+inttostr(t.t1.p3.y); if t.t2=nil then s:=s+'v2p1 nil' else s:=s+'v2p1 '+inttostr(t.t2.p1.x)+' '+inttostr(t.t2.p1.y)+'v2p2 '+inttostr(t.t2.p2.x)+' '+inttostr(t.t2.p2.y)+'v2p3 '+inttostr(t.t2.p3.x)+' '+inttostr(t.t2.p3.y); if t.t3=nil then s:=s+'v3p1 nil' else s:=s+'v3p1 '+inttostr(t.t3.p1.x)+' '+inttostr(t.t3.p1.y)+'v3p2 '+inttostr(t.t3.p2.x)+' '+inttostr(t.t3.p2.y)+'v3p3 '+inttostr(t.t3.p3.x)+' '+inttostr(t.t3.p3.y); Memo5.Lines.Add(S); end; end; procedure TForma.SpeedButton11Click(Sender: TObject); var i,k:integer; s:string; begin label3.Caption:='chemins '+inttostr(length(Chemins))+' points '+inttostr(length(Chemins[0].LesP)); for i:=0 to length(Chemins)-1 do begin s:=inttostr(length(Chemins[i].LesP));if Chemins[i].estsupprime then s:=s+' Supp';if Chemins[i].EstFerme then s:=s+' Ferm'; Memo5.Lines.Add(s); for k:=1 to length(Chemins[i].LesP)-1 do begin image1.Canvas.pen.color:=clblack; Image1.Canvas.MoveTo(Chemins[i].LesP[k-1].X,Chemins[i].LesP[k-1].Y); Image1.Canvas.LineTo(Chemins[i].LesP[k].X,Chemins[i].LesP[k].Y); end; end; end; procedure TForma.Button5Click(Sender: TObject); var i,x,y:integer; p:ptriangle; begin for i:=0 to length(Delau.listetriangle)-1 do begin p:=Delau.listetriangle[i]; x:=(p.p1.X+p.p2.X+p.p3.X)div 3;y:=(p.p1.y+p.p2.y+p.p3.y)div 3; image1.Canvas.Brush.Color:=clgreen; image1.Canvas.pen.color:=clgreen; Image1.Canvas.Ellipse(x-3,y-3,x+3,y+3); end; end; procedure TForma.SpeedButton8Click(Sender: TObject); var i,k,Sqlt:integer; LM,L:real; begin for i :=1 to length(chemins)-1 do begin LM:=-1; L:=0; for k:=1 to length(Chemins[i].LesP)-1 do begin L:=L+DistPoint(Chemins[i].LesP[i-1],Chemins[i].LesP[i]); end; if L>LM then begin LM:=L; Sqlt:=i;end; end; //Affichage du squellette for k:=1 to length(Chemins[Sqlt].LesP)-1 do begin image1.Canvas.pen.color:=clblack; Image1.Canvas.MoveTo(Chemins[Sqlt].LesP[k-1].X,Chemins[Sqlt].LesP[k-1].Y); Image1.Canvas.LineTo(Chemins[Sqlt].LesP[k].X,Chemins[Sqlt].LesP[k].Y); end; end; procedure TForma.BitBtn4Click(Sender: TObject); var i,N:Integer; tt:TabPoints; p:tpoint; d1,d2:tDroite;pt1,pt2,pt3,pcg,pinf:pPoint; ncf,ncs,nv,v,v1,v2,w,ctr,x,y,it,it2:integer;{ncf nombre de chemins fermés } T,pr,sv:ptriangle; M,C,pd,pf:tpoint; k,Sqlt:integer;LM,L:real; begin //1111111111 rectangle anglobant RectangleAnglobant(listeobjets[0],minx,miny,maxx,maxy); Image1.Canvas.Brush.Style:= BsClear; Image1.Canvas.Rectangle(MaxX,MaxY,MinX,MinY); //2222222222 Triangle anglobant tT:=TriangleAnglobant(listeobjets[0]); Image1.Canvas.MoveTo(tT[0].x,Tt[0].y); Image1.Canvas.LineTo(tT[1].x,Tt[1].y); Image1.Canvas.LineTo(tT[2].x,Tt[2].y); Image1.Canvas.LineTo(tT[0].x,Tt[0].y); //3333333333 Dalau for i:=0 to length(ListeObjets[0].ListePoint)-1 do begin p:=ListeObjets[0].ListePoint[i]; Delau.Algorythm_Delaunay(p.X,p.Y); end; //44444444 Baricentre new(pt1);new(pt2);new(pt3);new(pinf);pinf^:=ptanglobant;new(pcg); N:=length(Listetriangle); i:=0; while(i<=n-1) do begin pt1.X:=Listetriangle[i].p1.X;pt1.Y:=Listetriangle[i].p1.Y; pt2.X:=Listetriangle[i].p2.X;pt2.Y:=Listetriangle[i].p2.Y; pt3.X:=Listetriangle[i].p3.X;pt3.Y:=Listetriangle[i].p3.Y; p.x:=(pt1.x+pt2.x+pt3.x)div 3;p.y:=(pt1.y+pt2.y+pt3.y)div 3; pcg.X:=p.X; pcg.Y:=p.Y; if not(DansPolygone(pcg,pinf))then Delau.DelTriangle(Listetriangle[i]) else inc(i); N:=length(Listetriangle); end; BitBtn2.Click; SpeedButton7.Click; //555555555 Squellette // le premier chemin, chercher le premier triangle pd.X:=ListeObjets[0].ListePoint[0].x;pd.Y:=ListeObjets[0].ListePoint[0].y; pf.X:=ListeObjets[0].ListePoint[length(ListeObjets[0].ListePoint)-1].x;pf.Y:=ListeObjets[0].ListePoint[length(ListeObjets[0].ListePoint)-1].y; setlength(chemins,1); Chemins[0].TP:=nil;Chemins[0].EstFerme:=false;Chemins[0].EstSupprime:=false; setlength(Chemins[0].LesP,1); Chemins[0].LesP[0].X:=(pd.X+pf.X)div 2;Chemins[0].LesP[0].Y:=(pd.Y+pf.Y)div 2; for i:=0 to length(listetriangle)-1 do begin t:=listetriangle[i]; ctr:=0; if ((listetriangle[i].p1.X=pd.X)and(listetriangle[i].p1.Y=pd.Y))or((listetriangle[i].p1.X=pf.X)and(listetriangle[i].p1.Y=pf.Y)) then inc(ctr); if ((listetriangle[i].p2.X=pd.X)and(listetriangle[i].p2.Y=pd.Y))or((listetriangle[i].p2.X=pf.X)and(listetriangle[i].p2.Y=pf.Y)) then inc(ctr); if ((listetriangle[i].p3.X=pd.X)and(listetriangle[i].p3.Y=pd.Y))or((listetriangle[i].p3.X=pf.X)and(listetriangle[i].p3.Y=pf.Y)) then inc(ctr); if ctr>1 then Chemins[0].TA:=t; end; Image1.Canvas.Ellipse(Chemins[0].LesP[0].X-3,Chemins[0].LesP[0].Y-3,Chemins[0].LesP[0].X+3,Chemins[0].LesP[0].Y+3); ncf:=0;ncs:=0;n:=1;it:=0; while (ncf+ncs nil then Image1.Canvas.Ellipse(t.c.X-3,t.c.Y-3,t.c.X+3,t.c.Y+3); // si t pas nil T:=Chemins[i].TA;// aficher les infor du triangle et du chemin // Compter les voisins de TA nv:=0; if t<> nil then if T.t1<>nil then inc(nv);if T.t2<>nil then inc(nv);if T.t3<>nil then inc(nv); //nv nombre de voisins if T.t1=Chemins[i].TP then pr:=T.t1;if T.t2=Chemins[i].TP then pr:=T.t2;if T.t3=Chemins[i].TP then pr:=T.t3;// TP triangle precedent // si un voisin c'est donc le precedent alors fermer le chemin, ajouter je ne sais pas quoid if (nv=1)and(it<>1) then begin Chemins[i].EstFerme:=true;inc(ncf);end; // sil a un voisin seulement ou si c'est le premier triangle et qu'il a un seul voisin // si deux voisins if (nv=2)or((nv=1) and (it=1)) then begin if (T.t1<>nil)and(T.t1<>pr) then begin M.x:=(T.p2.x+T.p3.x)div 2;M.y:=(T.p2.y+T.p3.y)div 2; sv:=T.t1; Image1.Canvas.TextOut(M.X,M.Y,'V1'); end; if (T.t2<>nil)and(T.t2<>pr) then begin M.x:=(T.p1.x+T.p3.x)div 2;M.y:=(T.p1.y+T.p3.y)div 2; sv:=T.t2;Image1.Canvas.TextOut(M.X,M.Y,'V2');end; if (T.t3<>nil)and(T.t3<>pr) then begin M.x:=(T.p2.x+T.p1.x)div 2;M.y:=(T.p2.y+T.p1.y)div 2; sv:=T.t3;Image1.Canvas.TextOut(M.X,M.Y,'V3');end; setlength(chemins[i].LesP,length(chemins[i].LesP)+1); chemins[i].LesP[length(chemins[i].LesP)-1].X:=M.X; chemins[i].LesP[length(chemins[i].LesP)-1].Y:=M.Y; chemins[i].TA:=sv;chemins[i].TP:=T; end; // si trois voisins if (nv=3) or ((nv=2)and(it=1)) then begin chemins[i].EstSupprime:=true;// supprimer le chemin qui va se bifurquer inc(ncs); c.X:=(t.p1.X+t.p2.X+t.p3.X)div 3;c.Y:=(t.p1.y+t.p2.y+t.p3.Y)div 3;// meme s'il y a t.c et quil marche quand je change le code il peut ne pas marcher setlength(chemins[i].LesP,length(chemins[i].LesP)+1); chemins[i].LesP[length(chemins[i].LesP)-1].X:=C.X; chemins[i].LesP[length(chemins[i].LesP)-1].Y:=C.Y;// ajout du centre de gravité //premier voisin if T.t1<>pr then begin M.x:=(T.p2.x+T.p3.x)div 2;M.y:=(T.p2.y+T.p3.y)div 2; setlength(chemins,length(chemins)+1); chemins[length(chemins)-1].TA:=T.t1;chemins[length(chemins)-1].TP:=T;chemins[length(chemins)-1].EstFerme:=false;chemins[length(chemins)-1].EstSupprime:=false; setlength(chemins[length(chemins)-1].LesP,length(chemins[i].LesP)+1); for w:=0 to length(chemins[i].LesP)-1 do begin chemins[length(chemins)-1].LesP[w].X:=chemins[i].LesP[w].x; chemins[length(chemins)-1].LesP[w].Y:=chemins[i].LesP[w].y; end; chemins[length(chemins)-1].LesP[w].X:=M.X;chemins[length(chemins)-1].LesP[w].Y:=M.Y; end; // deuxieme voisin if T.t2<>pr then begin M.x:=(T.p1.x+T.p3.x)div 2;M.y:=(T.p1.y+T.p3.y)div 2; setlength(chemins,length(chemins)+1); chemins[length(chemins)-1].TA:=T.t2;chemins[length(chemins)-1].TP:=T;chemins[length(chemins)-1].EstFerme:=false;chemins[length(chemins)-1].EstSupprime:=false; setlength(chemins[length(chemins)-1].LesP,length(chemins[i].LesP)+1); for w:=0 to length(chemins[i].LesP)-1 do begin chemins[length(chemins)-1].LesP[w].X:=chemins[i].LesP[w].x; chemins[length(chemins)-1].LesP[w].Y:=chemins[i].LesP[w].y; end; chemins[length(chemins)-1].LesP[w].X:=M.X;chemins[length(chemins)-1].LesP[w].Y:=M.Y; end; // troisieme voisin if T.t3<>pr then begin M.x:=(T.p2.x+T.p1.x)div 2;M.y:=(T.p2.y+T.p1.y)div 2; setlength(chemins,length(chemins)+1); chemins[length(chemins)-1].TA:=T.t3;chemins[length(chemins)-1].TP:=T;chemins[length(chemins)-1].EstFerme:=false;chemins[length(chemins)-1].EstSupprime:=false; setlength(chemins[length(chemins)-1].LesP,length(chemins[i].LesP)+1); for w:=0 to length(chemins[i].LesP)-1 do begin chemins[length(chemins)-1].LesP[w].X:=chemins[i].LesP[w].x; chemins[length(chemins)-1].LesP[w].Y:=chemins[i].LesP[w].y; end; chemins[length(chemins)-1].LesP[w].X:=M.X;chemins[length(chemins)-1].LesP[w].Y:=M.Y; end; end; end; end; end; //6666666666666 Chemin le plus long for i :=1 to length(chemins)-1 do begin LM:=-1; L:=0; for k:=1 to length(Chemins[i].LesP)-1 do begin L:=L+DistPoint(Chemins[i].LesP[i-1],Chemins[i].LesP[i]); end; if L>LM then begin LM:=L; Sqlt:=i;end; end; //Affichage du squellette for k:=1 to length(Chemins[Sqlt].LesP)-1 do begin image1.Canvas.pen.color:=clblack; Image1.Canvas.MoveTo(Chemins[Sqlt].LesP[k-1].X,Chemins[Sqlt].LesP[k-1].Y); Image1.Canvas.LineTo(Chemins[Sqlt].LesP[k].X,Chemins[Sqlt].LesP[k].Y); end; end; procedure TForma.Button6Click(Sender: TObject); var k,i,j:integer; XY:char; begin //Memo6.Lines.Clear; i:=-1;XY:='X'; setlength(ListeObjetsR,0); for k:=0 to Memo6.Lines.Count-1 do begin if (Memo6.Lines[k]='PL') or (Memo6.Lines[k]='PG') then begin SetLength(ListeObjetsR,length(ListeObjetsR)+1); inc(i);ListeObjetsR[i].Nature:=Memo6.Lines[k]; end else begin if XY='X' then begin SetLength(ListeObjetsR[i].ListePoint,length(ListeObjetsR[i].ListePoint)+1); ListeObjetsR[i].ListePoint[length(ListeObjetsR[i].ListePoint)-1].X:=strtofloat(Memo6.Lines[k]); XY:='Y'; end else begin ListeObjetsR[i].ListePoint[length(ListeObjetsR[i].ListePoint)-1].Y:=strtofloat(Memo6.Lines[k]); XY:='X'; end; end; end; end; end.