Для повышения точности расчётов и снижения трудоёмкости процесса расчёта земляных работ при проектировании лесовозных автомобильных дорог разработана программа «Объём земляных работ», позволяющая при заданных исходных данных получить объём работ на выемках и насыпях (рис. 1-3). Алгоритм прописан на языке высокого уровня Object Pascal среды Delphi 6.0. Фрагмент представлен ниже.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Grids, Math;
type
TForm1 = class(TForm)
Label1: TLabel; Label2: TLabel; Edit1: TEdit;
Label3: TLabel; Edit2: TEdit; Edit3: TEdit;
Edit4: TEdit; Label6: TLabel; Edit5: TEdit;
Label7: TLabel; Edit6: TEdit; Label8: TLabel;
Edit7: TEdit; RadioGroup1: TRadioGroup;
Label9: TLabel; Edit8: TEdit; Label10: TLabel;
Label11: TLabel; SG1: TStringGrid; Label12: TLabel;
Label4: TLabel; SG2: TStringGrid; Button1: TButton;
Button2: TButton; Label5: TLabel; Label13: TLabel;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Iroup1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Edit4KeyPress(Sender: TObject; var Key: Char);
procedure Edit5KeyPress(Sender: TObject; var Key: Char);
procedure Edit6KeyPress(Sender: TObject; var Key: Char);
procedure Edit7KeyPress(Sender: TObject; var Key: Char);
procedure Edit8KeyPress(Sender: TObject; var Key: Char);
private { Private declarations }
public { Public declarations }
end;
var Form1: TForm1;
i,n,code,flag,k:integer;
s:string;
A,B,B1,B2,M,M1,N3,W,H2,B3,F,s1,s2,s3,Hi,Hi1,Li,A1,A2:real;
V,L2,Lv,Ln,V7,V8,H9,C,L1,H7,H8,i1,V1,V2,nac,kon,V3,per:real;
mas:array[1..3,1..80] of real;
implementation uses Unit2, Unit3; {$R *.dfm}
procedure proc;
begin s1:=s1+V; str(Hi:10:3,s);Form2.SG1.Cells[1,i+1]:=s;
str(Hi1:10:3,s);Form2.SG1.Cells[2,i+1]:=s;
Form2.SG1.Cells[3,i+1]:=Form1.SG1.Cells[1,i+1];
str(V:10:3,s);Form2.SG1.Cells[4,i+1]:=s;
str(V7:10:3,s);Form2.SG1.Cells[5,i+1]:=s;
str(L2:10:3,s);Form2.SG1.Cells[6,i+1]:=s;
str(V8:10:3,s);Form2.SG1.Cells[7,i+1]:=s;
str(L1:10:3,s);Form2.SG1.Cells[8,i+1]:=s;
V:=0;V8:=0;V7:=0;L1:=0;L2:=0;A1:=0;A2:=0;
flag:=0; end;
procedure TForm1.Button2Click(Sender: TObject);
begin close; end;
procedure TForm1.Button1Click(Sender: TObject);
begin Form1.Hide; Form2.Show; n:=1;
val(SG2.Cells[2,1],M,code);val(SG2.Cells[3,1],M1,code);
val(SG2.Cells[1,1],kon,code);while SG1.Cells[2,n]<>´´ do n:=n+1;k:=1;
for i:=1 to n-1 do begin if kon=i then begin val(SG2.Cells[2,k],M,code);
val(SG2.Cells[3,k],M1,code); k:=k+1;val(SG2.Cells[1,k],kon,code); end;
val(SG1.Cells[2,i],Hi,code); val(SG1.Cells[2,i+1],Hi1,code);
if (Hi>=0)and(Hi1>=0) then flag:=1
else if (Hi>=0)and(Hi1<=0) then flag:=2
else if (Hi<=0)and(Hi1>=0) then flag:=3
else if (Hi<=0)and(Hi1<=0) then flag:=4;
val(SG1.Cells[1,i],Li,code);
case flag of
1:begin H9:=(Hi+Hi1)/2;C:=abs(Hi-Hi1);end;
2:begin A1:=Hi;A2:=abs(Hi1);L2:=A1*Li/(A1+A2);L1:=Li-L2;
C:=abs(Hi-Hi1);H7:=A1/2;H8:=abs(A2/2);end;
3:begin A1:=abs(Hi);A2:=Hi1; L1:=abs(A1*Li/(A1+A2));L2:=Li-L1;
C:=abs(Hi-Hi1);H7:=A2/2;H8:=abs(A1/2);end;
4:begin H9:=abs((Hi+Hi1)/2);C:=abs(Hi-abs(Hi1));end;end;
case flag of
1:begin if (N3=0)and(C>1) then begin
V:=(A+B*H9+M*H9*H9+M*(Hi-Hi1)*(Hi-Hi1)/12)*Li;S2:=S2+V; proc;end;
if (N3<>0)and(C>1) then begin
V1:=A+((B*H9+M*H9*H9+(0.25*M*B*B)/(N3*N3))/(1-M*M/(N3*N3)));
V2:=M*(Hi-Hi1)*(Hi-Hi1)/12;
V:=(V1+V2)*Li;S2:=S2+V; proc;end;
if (N3<>0)and(C<=1) then begin V:=(A+(B*H9+M*H9*H9+(0.25*M*B*B)/(N3*N3))/(1-M*M/(N3*N3)))*Li;
S2:=S2+V;proc;end;
if (N3=0)and(C<=1) then begin V:=(A+B*H9+M*H9*H9)*Li;S2:=S2+V;proc;end;
end;
2:begin if (N3=0)and(C>1) then begin
V7:=(A+B*H7+M*H7*H7+(M*A1*A1/12))*L2;S2:=S2+V7;
V1:=2*W-A+(B+2*B1)*H8+M1*H8*H8;
V2:=M1*A2*A2/12;V8:=(V1+V2)*L1;
V:=V7+V8;S3:=S3+V8;proc;end;
if (N3<>0)and(C>1) then begin V1:=A+(B*H7+M*H7*H7+0.25*M*B*B/(N3*N3))/(1-M*M/(N3*N3)); V2:=M*A1*A1/12;
V7:=(V1+V2)*L2;S2:=S2+V7;
V1:=(B+2*B1)*H8+M1*H8*H8+(0.25*M1*(B+2*B1)*(B+2*B1))/(N3*N3);
V2:=(1-M1*M1)/(N3*N3);V3:=M1*A2*A2/12;
V8:=(2*W-A+V1/V2+V3)*L1;
V:=V7+V8;S3:=S3+V8;proc;end;
if (N3<>0)and(C<=1) then begin
V7:=(A+(B*H7+M*H7*H7+0.25*M*B*B/(N3*N3))/(1-M*M/(N3*N3)))*L2;
S2:=S2+V7;
V1:=(B+2*B1)*H8+M1*H8*H8+(0.25*M1*(B+2*B1)*(B+2*B1))/(N3*N3);
V2:=1-M1*M1/(N3*N3);
V8:=(2*W-A+V1/V2)*L1;V:=V7+V8;S3:=S3+V8;proc;end;
if (N3=0)and(C<=1) then begin V7:=(A+B*H7+M*H7*H7)*L2;
S2:=S2+V;V8:=(2*W-A+(B+2*B1)*H8+M1*H8*H8)*L1;
V:=V7+V8;S3:=S3+V8;proc;end;end;
3:begin if (N3=0)and(C>1) then begin
V8:=(2*W-A+(B+2*B1)*H8+M1*H8*H8+M1*(Hi-Hi1)*(Hi-Hi1)/12)*L1;
S3:=S3+V8;V7:=(A+B*H7+M*H7*H7+M*A2*A2/12)*L2;
V:=V7+V8;S2:=S2+V7;proc;end;
if (N3<>0)and(C>1) then begin
V1:=(B+2*B1)*H8+M1+H8*H8+0.25*M1*(B+2*B1)*(B+2*B1)/(N3*N3);
V2:=1-M1*M1/(N3*N3); V3:=M1*A1*A1/12; V8:=(2*W-A+V1/V2+V3)*L1;
S3:=S3+V8; V1:=A+(B*H7+M*H7+0.25*M*B*B/(N3*N3))/(1-M*M/(N3*N3));
V2:=M*A2*A2/12;V7:=(V1+V2)*L2;V:=V7+V8;S2:=S2+V7;proc; end;
if (N3<>0)and(C<=1) then begin
V1:=((B+2*B1)*H8+M1*H8*H8+0.25*M1*(B+2*B1)*(B+2*B1)/(N3*N3))/(1-M*M/(N3*N3)); V8:=(2*W-A+V1)*L1; S3:=S3+V8;
V7:=(A+(B*H7+M*H7+M*B*B/(N3*N3*4)/(1-M*M/(N3*N3))))*L2;
V:=V7+V8; S2:=S2+V7;proc;end;
if (N3=0)and(C<=1) then begin
V:=(2*W-A+(B+2*B1)*H8+M1*H8*H8)*L1;
V8:=V1*L1; S3:=S3+V8; V7:=(A+B*H7+M*H7*H7)*L2;
V:=V7+V8;S2:=S2+V7;proc;end;end;
4:begin if (N3=0)and(C>1) then begin
V:=(2*W-A+(B+2*B1)*H9-M1+H9*H9+M1*(Hi-Hi1)*(Hi-Hi1)/12)*Li;
S3:=S3+V;proc;end;
if (N3=0)and(C<=1) then begin V:=(2*W-A+(B+2*B1)*H9+M1*H9*H9)*Li;
S3:=S3+V;proc;end; if (N3<>0)and(C>0) then begin
V1:=(B+2*B1)*H9+M1*H9*H9+0.25*M1+(B+2*B1)*(B+2*B1)/(N3*N3);
V2:=1-M1*M1/(N3*N3); V3:=M1*(Hi-Hi1)*(Hi-Hi1)/12;
V:=(2*W-A+V1/V2+V3)*Li;S3:=S3+V;proc;end;
if (N3<>0)and(C<=0) then begin
V1:=((B+2*B1)*H9+M1*H9*H9+0.25*M1*(B+2*B1)*(B+2*B1)/(N3*N3))/(1-M1*M1/(N3*N3)); V:=(2*W-A+V1)*Li;proc;end;
end;end;end;end;k:=1;nd;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then begin
val(Edit2.Text,B,code);
if B>0 then Edit3.SetFocus else Edit2.SelectAll; end;end;end