300分救命!EinvalidOperation在数据表table.post出现!(300分)

  • 主题发起人 主题发起人 felong11
  • 开始时间 开始时间
F

felong11

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟在做一个项目。
使用一个窗体进行计算,计算的结果放到了数据库里面去。第一次使用这个窗体的时候
没事,当重新用这个窗体计算的时候在执行到table.post的时候抛出了
raised exception class EInvalidOperation with message"Cannot focus a disabled or
invisible window"
非常的奇怪。我并没有对其他的窗体进行操作。
我是使用了DataMoudle的,难道引用里面的table就会出现这样的情况?那我第一次使用
的时候为什么不抛出异常?是不是我的资源释放有问题?
但是我好像没有怎么样释放错误啊!

请各位大虾救命!项目要交了。

要贴出源码吗?较长的说。

 
这就是小弟的调用过程。
较长,在红色的句子出错。真的比较长,请各位原谅!我也不敢省略。
[?][?][?][?][?][?][?][?][?][?][?][?][?][?][?][?][?][?][?][?][?]



{只作点到点的计算}
procedure TFeCore.Calculate(Tx,Rx:TSpacePoint;TablePlane:TTable;var TableRayTube:TTable;var TableTrace:TTable;
var Eout:TField_of_Electric;ProgressBar:TProgressBar);
var
{循环变量}
k,i,j,n,m:integer;

{接收点和发射点之间是否有阻碍物
HaveOb=true表示存在阻碍物}
HaveOb,HaveOb1,HaveOb2,HaveOb3:boolean;

{平面数,射线管数}
NumberOfPlane,NumberOfRayTube:integer;

{填补参数,仅仅起填补参数的作用,实际并不对它进行处理。}
FillVector:TSpaceVector;
FillPoint:TSpacePoint;
FillDistance:real;

{临时变量}
radiusTemp,ThitaTemp,FiTemp:real;
JudgeWhichPlaneTemp:TJudge_Which_Plane;
TempVector:TSpaceVector;
Phase:TComplexNum;

{直射、反射波,总的场强大小}
DirectEField,BounceEField,E:TField_of_Electric;

{第一根射线的方向,和反射线的方向}
FirstDirection,Direction_Bounce:TSpaceVector;

{入射点,第一个发射点,第一个入射点}
Insert_Point,FirstPoint,FirstInsertPoint:TSpacePoint;

{路径长度}
PathL:real;

{点是否在射线管内}
If_Point_In_Triangle:boolean;

{反射顺序}
Bounce_Order:array of integer;

{入射波的平行分量}
Direction_Incidence_Parallel:TSpaceVector;

{入射波的垂直分量}
Direction_Incidence_Vertical:TSpaceVector;

{反射线的方向}
Direction_Of_Bounce:TSpaceVector;

{反射线的平行分量}
Direction_Bounce_Parallel:TSpaceVector;

{反射线的垂直分量}
Direction_Bounce_Vertical:TSpaceVector;

{判断是否达到接收点}
HasReach:Boolean;

{直射方向}
Direct_Direction:TSpaceVector;

{临时射线管}
TempRayTube:TRayTube;

{一根射线管三根射线最后与接收点垂面的交点}
p1,p2,p3:TSpacePoint;

{一根射线管三根射线最后与接收点垂面的交点与接收点的距离}
l1,l2,l3:real;

{临时场强值}
E1,E2,E3:TField_of_Electric;

f,f2,f3:textfile;//调试专用
{2222222222222222222222222222222222222222222222222222222222222222222222}
{临时变量}
PlaneTemp:TPlane;
VectorTemp,vn:TSpaceVector;
PointTemp,pt1,pt2:TSpacePoint;

begin

AssignFile(f,extractfilepath(application.ExeName)+'log/CheckCrossCore.rec');
assignfile(f2,extractfilepath(application.ExeName)+'log/EF.rec');
assignfile(f3,extractfilepath(application.ExeName)+'log/BounceLoss.rec');
rewrite(f);
rewrite(f2);
try
rewrite(f3);
closefile(f3);
{初始化时设没有阻碍物}
Haveob:=false;

tabletrace.Close;
tabletrace.EmptyTable;
tabletrace.Open;


{清零操作}
Eout.x.r:=0;
EOut.x.i:=0;
Eout.y.r:=0;
EOut.y.i:=0;
Eout.z.r:=0;
EOut.z.i:=0;

{进度条初始化}
ProgressBar.Min:=0;
ProgressBar.Max:=tableRaytube.FieldCount;
ProgressBar.Step:=1;
ProgressBar.Position:=0;

{初始化,清零处理}
BounceEField.x.r:=0;
BounceEField.x.i:=0;
BounceEField.y.r:=0;
BounceEField.y.i:=0;
BounceEField.z.r:=0;
BounceEField.z.i:=0;

{求直射波,首先计算是否存在直射波。}
{直射波的方向}
Direct_Direction.x:=rx.x-tx.x;
Direct_Direction.y:=rx.y-tx.y;
Direct_Direction.z:=rx.z-tx.z;

DirectEField.x.r:=0;
DirectEField.x.i:=0;
DirectEField.y.r:=0;
DirectEField.y.i:=0;
DirectEField.z.r:=0;
DirectEField.z.i:=0;
writeln(f,'直射波的射线与平面的相交情况');

if TablePlane.Active then
TablePlane.First else TablePlane.Open;

while not TablePlane.Eof do
begin
{检测是否与任意平面相交}
PlaneTemp.Point_In_Plane.x:=
tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=
tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=
tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=
tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=
tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=
tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;

VectorTemp.x:=rx.x-tx.x;
VectorTemp.y:=rx.y-tx.y;
VectorTemp.z:=rx.z-tx.z;

HaveOb:=CrossTest(tx,VectorTemp,PlaneTemp,FillDistance,FillPoint,FillVector);
if HaveOb then
begin {是否在发射点与接收点之间}
if ((FillPoint.x<=max(Tx.x,Rx.x))
and (FillPoint.x>=min(Tx.x,Rx.x))
and (FillPoint.y<=max(Tx.y,Rx.y))
and (FillPoint.y>=min(Tx.y,Rx.y))
and (FillPoint.z<=max(Tx.z,Rx.z))
and (FillPoint.z>=min(Tx.z,Rx.z)))
then {if (FillPoint.x<=max(Tx.x,Rx.x))}
begin
writeln(f,'射线的相交情况:与第'+inttostr(tableplane.fieldbyname('no').AsInteger)+'平面相交。');
haveob:=true;
writeln(f,'下面的射线就不再计算(如果有的话)');
{一旦检测到有一个阻碍物就不再检测其他的平面,跳出循环}
break;
end {if (FillPoint.x<=max(Tx.x,Rx.x))}
else
begin
writeln(f,'射线的相交情况:与第'+inttostr(tableplane.fieldbyname('no').AsInteger)+'平面不相交。');
haveob:=false;
end
end
else {if HaveOb then}
begin
writeln(f,'射线的相交情况:与第'+inttostr(tableplane.fieldbyname('no').AsInteger)+'平面不相交。');
haveob:=false;
end;

tablePlane.Next;
end;

{如果没有阻碍物的话,就计算直射波。}
if not HaveOb then
begin
radiustemp:=sqrt(sqr(Tx.x-Rx.x)
+sqr(Tx.y-Rx.y)
+sqr(Tx.z-Rx.z));

thitatemp:=arccos((Tx.z-Rx.z)/ radiustemp);
fitemp:=arctan((Tx.y-Rx.y )/(Tx.x-Rx.x));

DirectEField.x.r:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*cos(fitemp)*sin(Constk*radiustemp);
DirectEField.x.i:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*cos(fitemp)*(-cos(Constk*radiustemp));
DirectEField.y.r:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*sin(fitemp)*sin(Constk*radiustemp);
DirectEField.y.i:= (60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*sin(fitemp)*(-cos(Constk*radiustemp));
DirectEField.z.r:=-(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*sin(thitatemp)*sin(Constk*radiustemp);
DirectEField.z.i:=-(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*sin(thitatemp)*(-cos(Constk*radiustemp));

end; {if not HaveOb}
writeln(f,'直射波大小 x='+floattostr(DirectEField.x.r)+'+'+
floattostr(DirectEField.x.i)+'i'+#13+'y='+floattostr(DirectEField.y.r)+'+'+
floattostr(DirectEField.y.i)+'i'+#13+'z='+floattostr(DirectEField.z.r)+'+'+
floattostr(DirectEField.z.i)+'i' );
closefile(f);
{求直射波结束}


{初始化踪迹表}
tableTrace.Open;

{初始化反弹顺序}
setLength(Bounce_Order,BounceNumber+1);

{对射线管球中每一根射线管的方向追踪}

if tableraytube.Active then tableraytube.First
else tableraytube.Open;



while not tableRaytube.Eof do
begin
{判断是否达到接收点}
HasReach:=false;
////////////////////////////////////////////////////////////////////////////////
//////////////// 跟踪射线踪迹 (反射) //////////////////////
////////////////////////////////////////////////////////////////////////////////

{记录第一根射线一开始的方向,以及所在起点}

FirstDirection.x:=tableraytube.fieldbyname('r1_vx').AsFloat;
FirstDirection.y:=tableraytube.fieldbyname('r1_vy').AsFloat;
FirstDirection.z:=tableraytube.fieldbyname('r1_vz').AsFloat;

FirstPoint.x:=tableraytube.fieldbyname('r1_spx').AsFloat;
FirstPoint.y:=tableraytube.fieldbyname('r1_spy').AsFloat;
FirstPoint.z:=tableraytube.fieldbyname('r1_spz').AsFloat;

tabletrace.Append;

tableTrace.FieldByName('rtno').AsInteger:=tableraytube.fieldbyname('rtno').AsInteger;

tabletrace.FieldByName('RT0R1_SPX').AsFloat:=tableraytube.fieldbyname('r1_spx').AsFloat;
tabletrace.FieldByName('RT0R1_SPy').AsFloat:=tableraytube.fieldbyname('r1_spy').AsFloat;
tabletrace.FieldByName('RT0R1_SPz').AsFloat:=tableraytube.fieldbyname('r1_spz').AsFloat;

tabletrace.FieldByName('RT0R2_SPX').AsFloat:=tableraytube.fieldbyname('r2_spx').AsFloat;
tabletrace.FieldByName('RT0R2_SPy').AsFloat:=tableraytube.fieldbyname('r2_spy').AsFloat;
tabletrace.FieldByName('RT0R2_SPz').AsFloat:=tableraytube.fieldbyname('r2_spz').AsFloat;

tabletrace.FieldByName('RT0R3_SPX').AsFloat:=tableraytube.fieldbyname('r3_spx').AsFloat;
tabletrace.FieldByName('RT0R3_SPy').AsFloat:=tableraytube.fieldbyname('r3_spy').AsFloat;
tabletrace.FieldByName('RT0R3_SPz').AsFloat:=tableraytube.fieldbyname('r3_spz').AsFloat;

tabletrace.FieldByName('rt0r1_vx').AsFloat:=tableraytube.fieldbyname('r1_vx').AsFloat;
tabletrace.FieldByName('rt0r1_vy').AsFloat:=tableraytube.fieldbyname('r1_vy').AsFloat;
tabletrace.FieldByName('rt0r1_vz').AsFloat:=tableraytube.fieldbyname('r1_vz').AsFloat;

tabletrace.FieldByName('rt0r2_vx').AsFloat:=tableraytube.fieldbyname('r2_vx').AsFloat;
tabletrace.FieldByName('rt0r2_vy').AsFloat:=tableraytube.fieldbyname('r2_vy').AsFloat;
tabletrace.FieldByName('rt0r2_vz').AsFloat:=tableraytube.fieldbyname('r2_vz').AsFloat;

tabletrace.FieldByName('rt0r3_vx').AsFloat:=tableraytube.fieldbyname('r3_vx').AsFloat;
tabletrace.FieldByName('rt0r3_vy').AsFloat:=tableraytube.fieldbyname('r3_vy').AsFloat;
tabletrace.FieldByName('rt0r3_vz').AsFloat:=tableraytube.fieldbyname('r3_vz').AsFloat;

tabletrace.Post;

{k为反射次数}
for k:=1 to BounceNumber do
begin
{判断是否达到接收点,如果已经到达了接收点就不再
继续尝试在规定次数中是否可以再度到达接收点。}
if HasReach then break;

{借用FillVector作临时变量}
{初始化}
TempVector:=FirstDirection;
JudgeWhichPlaneTemp.Which_Plane:=-1;
JudgeWhichPlaneTemp.Length:=99999999;
HaveOb:=false;

{找出这根射线的真正的相交平面,去除伪交点}
if tableplane.Active then tableplane.First else tableplane.Open;

while not tableplane.Eof do
begin
{数据库向自定义数据结构转换开始}
PointTemp.x:=tableraytube.fieldbyname('R1_spx').AsFloat;
PointTemp.y:=tableraytube.fieldbyname('R1_spy').AsFloat;
PointTemp.z:=tableraytube.fieldbyname('R1_spz').AsFloat;

VectorTemp.x:=tableraytube.fieldbyname('r1_vx').AsFloat;
VectorTemp.y:=tableraytube.fieldbyname('r1_vy').AsFloat;
VectorTemp.z:=tableraytube.fieldbyname('r1_vz').AsFloat;

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;

{数据库向自定义数据结构转换结束}

HaveOb:=CrossTest(PointTemp,VectorTemp,Planetemp,
pathL,insert_point,Direction_Of_Bounce);

if HaveOb then
begin
if PathL<JudgeWhichPlaneTemp.Length then
begin
JudgeWhichPlaneTemp.Which_Plane:=tableplane.fieldbyname('no').AsInteger;
JudgeWhichPlaneTemp.Length:=PathL;
JudgeWhichPlaneTemp.Insert_Point:=Insert_Point;
JudgeWhichPlaneTemp.Direction_of_Bounce:=Direction_Of_Bounce;
end;{if PathL<JudgeWhichPlaneTemp.Length then}
end;{if HaveOb then}
tableplane.Next;
end;{for j:=1 to NumberOfPlane do}
{找出真正的相交平面结束}

tempraytube.R1.StartPoint.x:=tableraytube.fieldbyname('r1_spx').AsFloat;
tempraytube.R1.StartPoint.y:=tableraytube.fieldbyname('r1_spy').AsFloat;
tempraytube.R1.StartPoint.z:=tableraytube.fieldbyname('r1_spz').AsFloat;

tempraytube.R1.EndPoint.x:=tableraytube.fieldbyname('r1_epx').AsFloat;
tempraytube.R1.EndPoint.y:=tableraytube.fieldbyname('r1_epy').AsFloat;
tempraytube.R1.EndPoint.z:=tableraytube.fieldbyname('r1_epz').AsFloat;

tempraytube.R1.V.x:=tableraytube.fieldbyname('r1_vx').asfloat;
tempraytube.R1.V.y:=tableraytube.fieldbyname('r1_vy').asfloat;
tempraytube.R1.V.z:=tableraytube.fieldbyname('r1_vz').asfloat;

tempraytube.R2.StartPoint.x:=tableraytube.fieldbyname('r2_spx').AsFloat;
tempraytube.R2.StartPoint.y:=tableraytube.fieldbyname('r2_spy').AsFloat;
tempraytube.R2.StartPoint.z:=tableraytube.fieldbyname('r2_spz').AsFloat;

tempraytube.R2.EndPoint.x:=tableraytube.fieldbyname('r2_epx').AsFloat;
tempraytube.R2.EndPoint.y:=tableraytube.fieldbyname('r2_epy').AsFloat;
tempraytube.R2.EndPoint.z:=tableraytube.fieldbyname('r2_epz').AsFloat;

tempraytube.R2.V.x:=tableraytube.fieldbyname('r2_vx').asfloat;
tempraytube.R2.V.y:=tableraytube.fieldbyname('r2_vy').asfloat;
tempraytube.R2.V.z:=tableraytube.fieldbyname('r2_vz').asfloat;

tempraytube.R3.StartPoint.x:=tableraytube.fieldbyname('r3_spx').AsFloat;
tempraytube.R3.StartPoint.y:=tableraytube.fieldbyname('r3_spy').AsFloat;
tempraytube.R3.StartPoint.z:=tableraytube.fieldbyname('r3_spz').AsFloat;

tempraytube.R3.EndPoint.x:=tableraytube.fieldbyname('r3_epx').AsFloat;
tempraytube.R3.EndPoint.y:=tableraytube.fieldbyname('r3_epy').AsFloat;
tempraytube.R3.EndPoint.z:=tableraytube.fieldbyname('r3_epz').AsFloat;

tempraytube.R3.V.x:=tableraytube.fieldbyname('r3_vx').asfloat;
tempraytube.R3.V.y:=tableraytube.fieldbyname('r3_vy').asfloat;
tempraytube.R3.V.z:=tableraytube.fieldbyname('r3_vz').asfloat;

{将真正的相交平面记录下来}

{数据库向自定义数据结构转换开始}
{找出真正相交的平面并再进行一次相交测试}
tableplane.SetKey;
tableplane.FieldByName('no').AsInteger:=JudgeWhichPlaneTemp.Which_Plane;
tableplane.GotoKey;

PointTemp.x:=tableraytube.fieldbyname('R1_spx').AsFloat;
PointTemp.y:=tableraytube.fieldbyname('R1_spy').AsFloat;
PointTemp.z:=tableraytube.fieldbyname('R1_spz').AsFloat;

VectorTemp.x:=tableraytube.fieldbyname('r1_vx').AsFloat;
VectorTemp.y:=tableraytube.fieldbyname('r1_vy').AsFloat;
VectorTemp.z:=tableraytube.fieldbyname('r1_vz').AsFloat;

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;
{数据库向自定义数据结构转换结束}

HaveOb1:=CrossTest(PointTemp,VectorTemp,Planetemp,
pathL,insert_point,Direction_Of_Bounce);

{记录射线管与平面的第一个交点}
if k=1 then FirstInsertPoint:=JudgeWhichPlaneTemp.Insert_Point;

tableTrace.Edit;
//tableTrace.FieldByName('rtno').AsInteger:=tableraytube.fieldbyname('rtno').AsInteger;

tableTrace.FieldByName('rt'+inttostr(k)+'r1_spx').AsFloat:=insert_point.x;
tableTrace.FieldByName('rt'+inttostr(k)+'r1_spy').AsFloat:=Insert_Point.y;
tableTrace.FieldByName('rt'+inttostr(k)+'r1_spz').AsFloat:=Insert_Point.z;

tabletrace.FieldByName('rt'+inttostr(k-1)+'r1_epx').AsFloat:=Insert_Point.x;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r1_epy').AsFloat:=Insert_Point.y;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r1_epz').AsFloat:=Insert_Point.z;

tabletrace.FieldByName('rt'+inttostr(k)+'r1_vx').AsFloat:=tableraytube.fieldbyname('r1_vx').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k)+'r1_vy').AsFloat:=tableraytube.fieldbyname('r1_vy').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k)+'r1_vz').AsFloat:=tableraytube.fieldbyname('r1_vz').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r1_Pno').AsInteger:=JudgeWhichPlaneTemp.Which_Plane;
{更改tableraytube以进行下一次反射}
tableraytube.Edit;
tableraytube.FieldByName('r1_spx').AsFloat:=Insert_Point.x;
tableraytube.FieldByName('r1_spy').AsFloat:=Insert_Point.y;
tableraytube.FieldByName('r1_spz').AsFloat:=Insert_Point.z;

tableraytube.FieldByName('r1_vx').AsFloat:=Direction_of_bounce.x;
tableraytube.FieldByName('r1_vy').AsFloat:=Direction_of_bounce.y;
tableraytube.FieldByName('r1_vz').AsFloat:=Direction_of_bounce.z;
tableraytube.Post;

{第二根射线,第一根射线看作测试射线,
遇到的平面,就认为这根射线管的三根射线都遇到。
这显然有一定的误差了。}

PointTemp.x:=tableraytube.fieldbyname('R2_spx').AsFloat;
PointTemp.y:=tableraytube.fieldbyname('R2_spy').AsFloat;
PointTemp.z:=tableraytube.fieldbyname('R2_spz').AsFloat;

VectorTemp.x:=tableraytube.fieldbyname('r2_vx').AsFloat;
VectorTemp.y:=tableraytube.fieldbyname('r2_vy').AsFloat;
VectorTemp.z:=tableraytube.fieldbyname('r2_vz').AsFloat;

haveob2:=CrossTest(PointTemp,VectorTemp,Planetemp,
pathL,insert_point,Direction_Of_Bounce);



tabletrace.Edit;
tableTrace.FieldByName('rt'+inttostr(k)+'r2_spx').AsFloat:=Insert_Point.x;
tableTrace.FieldByName('rt'+inttostr(k)+'r2_spy').AsFloat:=Insert_Point.y;
tableTrace.FieldByName('rt'+inttostr(k)+'r2_spz').AsFloat:=Insert_Point.z;

tabletrace.FieldByName('rt'+inttostr(k-1)+'r2_epx').AsFloat:=Insert_Point.x;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r2_epy').AsFloat:=Insert_Point.y;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r2_epz').AsFloat:=Insert_Point.z;

tabletrace.FieldByName('rt'+inttostr(k)+'r2_vx').AsFloat:=tableraytube.fieldbyname('r2_vx').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k)+'r2_vy').AsFloat:=tableraytube.fieldbyname('r2_vy').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k)+'r2_vz').AsFloat:=tableraytube.fieldbyname('r2_vz').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r2_Pno').AsInteger:=JudgeWhichPlaneTemp.Which_Plane;

tableraytube.Edit;
tableraytube.FieldByName('r2_spx').AsFloat:=Insert_Point.x;
tableraytube.FieldByName('r2_spy').AsFloat:=Insert_Point.y;
tableraytube.FieldByName('r2_spz').AsFloat:=Insert_Point.z;

tableraytube.FieldByName('r2_vx').AsFloat:=Direction_of_bounce.x;
tableraytube.FieldByName('r2_vy').AsFloat:=Direction_of_bounce.y;
tableraytube.FieldByName('r2_vz').AsFloat:=Direction_of_bounce.z;
tableraytube.Post;


{第三根射线,第一根射线看作测试射线,
遇到的平面,就认为这根射线管的三根射线都遇到。
这显然有一定的误差了。}


PointTemp.x:=tableraytube.fieldbyname('R3_spx').AsFloat;
PointTemp.y:=tableraytube.fieldbyname('R3_spy').AsFloat;
PointTemp.z:=tableraytube.fieldbyname('R3_spz').AsFloat;

VectorTemp.x:=tableraytube.fieldbyname('r3_vx').AsFloat;
VectorTemp.y:=tableraytube.fieldbyname('r3_vy').AsFloat;
VectorTemp.z:=tableraytube.fieldbyname('r3_vz').AsFloat;

haveob3:= CrossTest(PointTemp,VectorTemp,Planetemp,
pathL,insert_point,Direction_Of_Bounce);


tabletrace.Edit;
tableTrace.FieldByName('rt'+inttostr(k)+'r3_spx').AsFloat:=Insert_Point.x;
tableTrace.FieldByName('rt'+inttostr(k)+'r3_spy').AsFloat:=Insert_Point.y;
tableTrace.FieldByName('rt'+inttostr(k)+'r3_spz').AsFloat:=Insert_Point.z;

tabletrace.FieldByName('rt'+inttostr(k-1)+'r3_epx').AsFloat:=Insert_Point.x;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r3_epy').AsFloat:=Insert_Point.y;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r3_epz').AsFloat:=Insert_Point.z;

tabletrace.FieldByName('rt'+inttostr(k)+'r3_vx').AsFloat:=tableraytube.fieldbyname('r3_vx').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k)+'r3_vy').AsFloat:=tableraytube.fieldbyname('r3_vy').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k)+'r3_vz').AsFloat:=tableraytube.fieldbyname('r3_vz').AsFloat;
tabletrace.FieldByName('rt'+inttostr(k-1)+'r3_Pno').AsInteger:=JudgeWhichPlaneTemp.Which_Plane;
tabletrace.FieldByName('StopNo').AsInteger:=BounceNumber;
tabletrace.FieldByName('Reach').AsBoolean:=false;
[red]tabletrace.Post;[/red]

tableraytube.Edit;
tableraytube.FieldByName('r3_spx').AsFloat:=Insert_Point.x;
tableraytube.FieldByName('r3_spy').AsFloat:=Insert_Point.y;
tableraytube.FieldByName('r3_spz').AsFloat:=Insert_Point.z;

tableraytube.FieldByName('r3_vx').AsFloat:=Direction_of_bounce.x;
tableraytube.FieldByName('r3_vy').AsFloat:=Direction_of_bounce.y;
tableraytube.FieldByName('r3_vz').AsFloat:=Direction_of_bounce.z;
tableraytube.Post;


if not (haveob1 and haveob2 and haveob3) then
begin
tabletrace.Edit;
tabletrace.FieldByName('stopno').AsInteger:=k-1;
tabletrace.Post;
//continue;
end;

////////////////////////////////////////////////////////////////////////////////
//////////////// 跟踪射线踪迹结束 (反射) ////////////////
////////////////////////////////////////////////////////////////////////////////

{判断接收点是否在射线管内,然后在判断中间是否有障碍物}



If_Point_In_Triangle:=Decide_If_Point_In_Triangle(Rx,TempRayTube,p1,p2,p3);

{如果在的话,就看看他们(第一根射线和接收点)之间有没有阻挡物}
if If_Point_In_Triangle then
begin
if tableplane.Active then tableplane.First else tableplane.Open;

while not tableplane.Eof do
begin

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;


HaveOb:=CrossTest(TempRayTube.R1.StartPoint,TempRayTube.R1.V,PlaneTemp,
PathL,FillPoint,FillVector);

if HaveOb then {就是如果有物体交射线的交点的坐标在起点与
接收点的范围内的话,才是真正的存在障碍物}
begin {是否在这根射线管的起点(相当于发射点)与接收点之间}
{仅限房间内的物体,墙壁不算}
if (FillPoint.x<=max(TempRayTube.R1.StartPoint.x,Rx.x))
and (FillPoint.x>=min(TempRayTube.R1.StartPoint.x,Rx.x))
and (FillPoint.y<=max(TempRayTube.R1.StartPoint.y,Rx.y))
and (FillPoint.y>=min(TempRayTube.R1.StartPoint.y,Rx.y))
and (FillPoint.z<=max(TempRayTube.R1.StartPoint.z,Rx.z))
and (FillPoint.z>=min(TempRayTube.R1.StartPoint.z,Rx.z))
then
begin
if tableplane.FieldByName('No').AsInteger>6 then
begin
haveOb:=true;
break;
end{if tableplane.RecNo>6 then}
else
haveob:=false;
end{第三个 if 一层}
else HaveOb:=false;{第二个if}
end;

tableplane.Next;
end;{while not tableplane.Eof do}
writeln(f2,'Once Again');
end;{if If_Point_In_Triangle then}

{如果出现一次阻挡,就不行。如果无阻挡则算反射了k次后的场强}
if ( not Haveob ) and If_Point_In_Triangle then
begin
{如果无阻挡而且到达接收点的话就置TableTrace的字段值 Reach 为true
并记录是在第几次反射停下的StopNo}
TableTrace.Edit;
TableTrace.FieldByName('StopNo').AsInteger:=k;
TableTrace.FieldByName('Reach').AsBoolean:=true;

{记录最后的射线管三根射线与接收点的垂面的交点}
TableTrace.FieldByName('R1_Px').AsFloat:=p1.x;
TableTrace.FieldByName('R1_Py').AsFloat:=p1.y;
TableTrace.FieldByName('R1_Pz').AsFloat:=p1.z;

TableTrace.FieldByName('R2_Px').AsFloat:=p2.x;
TableTrace.FieldByName('R2_Py').AsFloat:=p2.y;
TableTrace.FieldByName('R2_Pz').AsFloat:=p2.z;

TableTrace.FieldByName('R3_Px').AsFloat:=p3.x;
TableTrace.FieldByName('R3_Py').AsFloat:=p3.y;
TableTrace.FieldByName('R3_Pz').AsFloat:=p3.z;

TableTrace.Post;
HasReach:=true;

end;{if Haveob and If_Point_In_Triangle then}
end;{for k:=1 to BounceNumber do}

{每一次判断在射线管内且中间没有障碍物的时候才
开始计算接收电的场强,这就是说,k次中只有某一次(1<=t<=k)
中成功到达接收点。一旦成功的话,对于t次后的k-t次反射就不必考虑了
应该跳过后面的循环计算。这个场强就是这根射线管
(RayTube_Tree)完成规定反射次数(BounceNumber)
后对接收点的贡献。最后应叠加所有射线管的贡献}



application.ProcessMessages;
tableraytube.next;

ProgressBar.StepIt;
end;{ while not tableRaytube.Eof do}

{ 处理踪迹表TableTrace,把没有写上去的终点补上 }

{将到达接收点的射线管过滤出来}
TableTrace.Filter:='Reach=True';
TableTrace.Filtered:=true;
TableTrace.First;

{循环处理踪迹表TableTrace,把没有写上去的终点补上}
while not TableTrace.Eof do
begin
i:=tabletrace.fieldbyname('StopNo').AsInteger;

{射线1}
if tableplane.Active then tableplane.First else tableplane.Open;
{初始化}
JudgeWhichPlaneTemp.Which_Plane:=-1;
JudgeWhichPlaneTemp.Length:=99999999;
HaveOb:=false;
while not tableplane.Eof do
begin
PointTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spx').AsFloat;
PointTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spy').AsFloat;
PointTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spz').AsFloat;

VectorTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'r1_vx').AsFloat;
VectorTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'r1_vy').AsFloat;
VectorTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'r1_vz').AsFloat;

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;
{数据库向自定义数据结构转换结束}

HaveOb:=CrossTest(PointTemp,VectorTemp,Planetemp,
pathL,insert_point,Direction_Of_Bounce);

if HaveOb then
begin
if PathL<JudgeWhichPlaneTemp.Length then
begin
JudgeWhichPlaneTemp.Which_Plane:=tableplane.fieldbyname('no').AsInteger;
JudgeWhichPlaneTemp.Length:=PathL;
JudgeWhichPlaneTemp.Insert_Point:=Insert_Point;
JudgeWhichPlaneTemp.Direction_of_Bounce:=Direction_Of_Bounce;
end;{if PathL<JudgeWhichPlaneTemp.Length then}
end;{if HaveOb then}
tableplane.Next;
end;{for j:=1 to NumberOfPlane do}
{找出真正的相交平面结束}

tableplane.SetKey;
tableplane.FieldByName('no').AsInteger:=JudgeWhichPlaneTemp.Which_Plane;
{找出交点和相交平面}
if tableplane.GotoKey then
begin
if CrossTest(PointTemp,VectorTemp,Planetemp,
PathL,Insert_Point,Direction_Of_Bounce)
then
begin
tabletrace.Edit;
tabletrace.fieldbyname('rt'+inttostr(i)+'R1_epx').AsFloat:=Insert_Point.x;
tabletrace.fieldbyname('rt'+inttostr(i)+'R1_epy').AsFloat:=Insert_Point.y;
tabletrace.fieldbyname('rt'+inttostr(i)+'R1_epz').AsFloat:=Insert_Point.z;
tabletrace.Post;
end;{if CrossTest}
end;{if tableplane.GotoKey then}

{射线2}
if tableplane.Active then tableplane.First else tableplane.Open;
{初始化}
JudgeWhichPlaneTemp.Which_Plane:=-1;
JudgeWhichPlaneTemp.Length:=99999999;
HaveOb:=false;
while not tableplane.Eof do
begin
PointTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spx').AsFloat;
PointTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spy').AsFloat;
PointTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spz').AsFloat;

VectorTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'r2_vx').AsFloat;
VectorTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'r2_vy').AsFloat;
VectorTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'r2_vz').AsFloat;

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;
{数据库向自定义数据结构转换结束}

HaveOb:=CrossTest(PointTemp,VectorTemp,Planetemp,
pathL,insert_point,Direction_Of_Bounce);

if HaveOb then
begin
if PathL<JudgeWhichPlaneTemp.Length then
begin
JudgeWhichPlaneTemp.Which_Plane:=tableplane.fieldbyname('no').AsInteger;
JudgeWhichPlaneTemp.Length:=PathL;
JudgeWhichPlaneTemp.Insert_Point:=Insert_Point;
JudgeWhichPlaneTemp.Direction_of_Bounce:=Direction_Of_Bounce;
end;{if PathL<JudgeWhichPlaneTemp.Length then}
end;{if HaveOb then}
tableplane.Next;
end;{for j:=1 to NumberOfPlane do}
{找出真正的相交平面结束}

tableplane.SetKey;
tableplane.FieldByName('no').AsInteger:=JudgeWhichPlaneTemp.Which_Plane;
{找出交点和相交平面}
if tableplane.GotoKey then
begin
if CrossTest(PointTemp,VectorTemp,Planetemp,
PathL,Insert_Point,Direction_Of_Bounce)
then
begin
tabletrace.Edit;
tabletrace.fieldbyname('rt'+inttostr(i)+'R2_epx').AsFloat:=Insert_Point.x;
tabletrace.fieldbyname('rt'+inttostr(i)+'R2_epy').AsFloat:=Insert_Point.y;
tabletrace.fieldbyname('rt'+inttostr(i)+'R2_epz').AsFloat:=Insert_Point.z;
tabletrace.Post;
end;{if CrossTest}
end;{if tableplane.GotoKey then}
{射线3}
if tableplane.Active then tableplane.First else tableplane.Open;
{初始化}
JudgeWhichPlaneTemp.Which_Plane:=-1;
JudgeWhichPlaneTemp.Length:=99999999;
HaveOb:=false;
while not tableplane.Eof do
begin
PointTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spx').AsFloat;
PointTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spy').AsFloat;
PointTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spz').AsFloat;

VectorTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'r3_vx').AsFloat;
VectorTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'r3_vy').AsFloat;
VectorTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'r3_vz').AsFloat;

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;
{数据库向自定义数据结构转换结束}

HaveOb:=CrossTest(PointTemp,VectorTemp,Planetemp,
pathL,insert_point,Direction_Of_Bounce);

if HaveOb then
begin
if PathL<JudgeWhichPlaneTemp.Length then
begin
JudgeWhichPlaneTemp.Which_Plane:=tableplane.fieldbyname('no').AsInteger;
JudgeWhichPlaneTemp.Length:=PathL;
JudgeWhichPlaneTemp.Insert_Point:=Insert_Point;
JudgeWhichPlaneTemp.Direction_of_Bounce:=Direction_Of_Bounce;
end;{if PathL<JudgeWhichPlaneTemp.Length then}
end;{if HaveOb then}
tableplane.Next;
end;{for j:=1 to NumberOfPlane do}
{找出真正的相交平面结束}

tableplane.SetKey;
tableplane.FieldByName('no').AsInteger:=JudgeWhichPlaneTemp.Which_Plane;
{找出交点和相交平面}
if tableplane.GotoKey then
begin
if CrossTest(PointTemp,VectorTemp,Planetemp,
PathL,Insert_Point,Direction_Of_Bounce)
then
begin
tabletrace.Edit;
tabletrace.fieldbyname('rt'+inttostr(i)+'R3_epx').AsFloat:=Insert_Point.x;
tabletrace.fieldbyname('rt'+inttostr(i)+'R3_epy').AsFloat:=Insert_Point.y;
tabletrace.fieldbyname('rt'+inttostr(i)+'R3_epz').AsFloat:=Insert_Point.z;
tabletrace.Post;
end;{if CrossTest}
end;{if tableplane.GotoKey then}
tabletrace.Next;
application.ProcessMessages;
end;{while not TableTrace.Eof do}
{ 终点计算完毕 }

{计算场强部分}
tableTrace.First;
while not tabletrace.Eof do
begin
{计算初始场强}
{射线1}
FirstPoint.x:=tabletrace.fieldbyname('rt0r1_spx').AsFloat;
FirstPoint.y:=tabletrace.fieldbyname('rt0r1_spy').AsFloat;
FirstPoint.z:=tabletrace.fieldbyname('rt0r1_spz').AsFloat;

FirstInsertPoint.x:=tabletrace.fieldbyname('rt0r1_epx').AsFloat;
FirstInsertPoint.y:=tabletrace.fieldbyname('rt0r1_epy').AsFloat;
FirstInsertPoint.z:=tabletrace.fieldbyname('rt0r1_epz').AsFloat;

radiustemp:=Ptp_Distance(FirstPoint,FirstInsertPoint);
thitatemp:=arccos((FirstPoint.x-FirstInsertPoint.x)/radiustemp);
fitemp:=arctan((FirstPoint.y-FirstInsertPoint.y)/(FirstPoint.x-FirstInsertPoint.x));

E1.x.r:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*cos(fitemp)*sin(Constk*radiustemp);
E1.x.i:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*cos(fitemp)*(-cos(Constk*radiustemp));
E1.y.r:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*sin(fitemp)*sin(Constk*radiustemp);
E1.y.i:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*sin(fitemp)*(-cos(Constk*radiustemp));
E1.z.r:=-(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*sin(thitatemp)*sin(Constk*radiustemp);
E1.z.i:=-(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*sin(thitatemp)*(-cos(Constk*radiustemp));
{射线2}
FirstPoint.x:=tabletrace.fieldbyname('rt0r2_spx').AsFloat;
FirstPoint.y:=tabletrace.fieldbyname('rt0r2_spy').AsFloat;
FirstPoint.z:=tabletrace.fieldbyname('rt0r2_spz').AsFloat;

FirstInsertPoint.x:=tabletrace.fieldbyname('rt0r2_epx').AsFloat;
FirstInsertPoint.y:=tabletrace.fieldbyname('rt0r2_epy').AsFloat;
FirstInsertPoint.z:=tabletrace.fieldbyname('rt0r2_epz').AsFloat;

radiustemp:=Ptp_Distance(FirstPoint,FirstInsertPoint);
thitatemp:=arccos((FirstPoint.x-FirstInsertPoint.x)/radiustemp);
fitemp:=arctan((FirstPoint.y-FirstInsertPoint.y)/(FirstPoint.x-FirstInsertPoint.x));

E2.x.r:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*cos(fitemp)*sin(Constk*radiustemp);
E2.x.i:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*cos(fitemp)*(-cos(Constk*radiustemp));
E2.y.r:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*sin(fitemp)*sin(Constk*radiustemp);
E2.y.i:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*sin(fitemp)*(-cos(Constk*radiustemp));
E2.z.r:=-(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*sin(thitatemp)*sin(Constk*radiustemp);
E2.z.i:=-(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*sin(thitatemp)*(-cos(Constk*radiustemp));
{射线3}
FirstPoint.x:=tabletrace.fieldbyname('rt0r3_spx').AsFloat;
FirstPoint.y:=tabletrace.fieldbyname('rt0r3_spy').AsFloat;
FirstPoint.z:=tabletrace.fieldbyname('rt0r3_spz').AsFloat;

FirstInsertPoint.x:=tabletrace.fieldbyname('rt0r3_epx').AsFloat;
FirstInsertPoint.y:=tabletrace.fieldbyname('rt0r3_epy').AsFloat;
FirstInsertPoint.z:=tabletrace.fieldbyname('rt0r3_epz').AsFloat;

radiustemp:=Ptp_Distance(FirstPoint,FirstInsertPoint);
thitatemp:=arccos((FirstPoint.x-FirstInsertPoint.x)/radiustemp);
fitemp:=arctan((FirstPoint.y-FirstInsertPoint.y)/(FirstPoint.x-FirstInsertPoint.x));

E3.x.r:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*cos(fitemp)*sin(Constk*radiustemp);
E3.x.i:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*cos(fitemp)*(-cos(Constk*radiustemp));
E3.y.r:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*sin(fitemp)*sin(Constk*radiustemp);
E3.y.i:=(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*cos(thitatemp)*sin(fitemp)*(-cos(Constk*radiustemp));
E3.z.r:=-(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*sin(thitatemp)*sin(Constk*radiustemp);
E3.z.i:=-(60*Im*cos(pi*cos(thitatemp)*0.5)/(sin(thitatemp)*radiustemp))*sin(thitatemp)*(-cos(Constk*radiustemp));



{初始场强计算完毕}

{开始计算反射损耗}

p1.x:=tabletrace.fieldbyname('R1_Px').AsFloat;
p1.y:=tabletrace.fieldbyname('R1_Py').AsFloat;
p1.z:=tabletrace.fieldbyname('R1_Pz').AsFloat;

p2.x:=tabletrace.fieldbyname('R2_Px').AsFloat;
p2.y:=tabletrace.fieldbyname('R2_Py').AsFloat;
p2.z:=tabletrace.fieldbyname('R2_Pz').AsFloat;

p3.x:=tabletrace.fieldbyname('R3_Px').AsFloat;
p3.y:=tabletrace.fieldbyname('R3_Py').AsFloat;
p3.z:=tabletrace.fieldbyname('R3_Pz').AsFloat;

l1:=Ptp_distance(p1,rx);
l2:=Ptp_distance(p2,rx);
l3:=Ptp_distance(p3,rx);

{射线一}
for i:=0 to tabletrace.fieldbyname('StopNo').AsInteger-1 do
begin
tableplane.SetKey;
tableplane.FieldByName('no').AsInteger:=tabletrace.fieldbyname('rt'+inttostr(i)+'r1_PNo').AsInteger;
{找出交点和相交平面}
if tableplane.GotoKey then
begin
PointTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spx').AsFloat;
PointTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spy').AsFloat;
PointTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spz').AsFloat;

VectorTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'r1_vx').AsFloat;
VectorTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'r1_vy').AsFloat;
VectorTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'r1_vz').AsFloat;

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;

if CrossTest(PointTemp,VectorTemp,Planetemp,
PathL,Insert_Point,Direction_Of_Bounce)
then
begin
{求入射波、反射波的平行垂直分量}
Relation_of_Incidence_And_Bounce(VectorTemp,Planetemp,
Direction_Incidence_Parallel,Direction_Incidence_Vertical,
Direction_Bounce_Parallel,Direction_Bounce_Vertical );

BounceLoss(VectorTemp,Planetemp.Normal_Direction_of_Plane,
Direction_Incidence_Parallel,Direction_Incidence_Vertical,
Direction_Bounce_Parallel,Direction_Bounce_Vertical,
Planetemp.Material,Freq,E1);
end;
end;
end;{for i:=0 to tabletrace.fieldbyname('StopNo').AsInteger-1 do}

{累加射线传播路径}
PathL:=0;

for i:=1 to tabletrace.fieldbyname('StopNo').AsInteger-1 do
begin
Pt1.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spx').AsFloat;
Pt1.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spy').AsFloat;
Pt1.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spz').AsFloat;

Pt2.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_epx').AsFloat;
Pt2.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_epy').AsFloat;
Pt2.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_epz').AsFloat;

PathL:=PathL+Ptp_Distance(pt1,pt2);
end;
i:=tabletrace.fieldbyname('StopNo').AsInteger;
Pt1.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spx').AsFloat;
Pt1.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spy').AsFloat;
Pt1.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R1_spz').AsFloat;

Pt2.x:=tabletrace.fieldbyname('r1_px').AsFloat;
Pt2.y:=tabletrace.fieldbyname('r1_py').AsFloat;
Pt2.z:=tabletrace.fieldbyname('r1_pz').AsFloat;

PathL:=PathL+Ptp_Distance(pt1,pt2);

E1.x.r:=e1.x.r/PathL;
E1.x.i:=e1.x.i/PathL;
E1.y.r:=e1.y.r/PathL;
E1.y.i:=e1.y.i/PathL;
E1.z.r:=e1.z.r/PathL;
E1.z.i:=e1.z.i/PathL;

{将相位放到复数里面去,以便用复数的乘法计算场强的复数形式}
Phase.r:=cos(constk*PathL);
Phase.i:=-sin(constk*PathL);

E1.x:=ComplexMultiply(E1.x,Phase);
E1.y:=ComplexMultiply(E1.y,Phase);
E1.z:=ComplexMultiply(E1.z,Phase);




{射线一结束}

{射线二}
for i:=0 to tabletrace.fieldbyname('StopNo').AsInteger-1 do
begin
tableplane.SetKey;
tableplane.FieldByName('no').AsInteger:=tabletrace.fieldbyname('rt'+inttostr(i)+'r2_PNo').AsInteger;
{找出交点和相交平面}
if tableplane.GotoKey then
begin
PointTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spx').AsFloat;
PointTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spy').AsFloat;
PointTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spz').AsFloat;

VectorTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'r2_vx').AsFloat;
VectorTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'r2_vy').AsFloat;
VectorTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'r2_vz').AsFloat;

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;

if CrossTest(PointTemp,VectorTemp,Planetemp,
PathL,Insert_Point,Direction_Of_Bounce)
then
begin
{求入射波、反射波的平行垂直分量}
Relation_of_Incidence_And_Bounce(VectorTemp,Planetemp,
Direction_Incidence_Parallel,Direction_Incidence_Vertical,
Direction_Bounce_Parallel,Direction_Bounce_Vertical );

BounceLoss(VectorTemp,Planetemp.Normal_Direction_of_Plane,
Direction_Incidence_Parallel,Direction_Incidence_Vertical,
Direction_Bounce_Parallel,Direction_Bounce_Vertical,
Planetemp.Material,Freq,E2);
end;
end;
end;{for i:=0 to tabletrace.fieldbyname('StopNo').AsInteger-1 do}

{累加射线传播路径}
PathL:=0;

for i:=1 to tabletrace.fieldbyname('StopNo').AsInteger-1 do
begin
Pt1.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spx').AsFloat;
Pt1.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spy').AsFloat;
Pt1.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spz').AsFloat;

Pt2.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_epx').AsFloat;
Pt2.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_epy').AsFloat;
Pt2.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_epz').AsFloat;

PathL:=PathL+Ptp_Distance(pt1,pt2);
end;
i:=tabletrace.fieldbyname('StopNo').AsInteger;
Pt1.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spx').AsFloat;
Pt1.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spy').AsFloat;
Pt1.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R2_spz').AsFloat;

Pt2.x:=tabletrace.fieldbyname('r2_px').AsFloat;
Pt2.y:=tabletrace.fieldbyname('r2_py').AsFloat;
Pt2.z:=tabletrace.fieldbyname('r2_pz').AsFloat;

PathL:=PathL+Ptp_Distance(pt1,pt2);

E2.x.r:=e2.x.r/PathL;
E2.x.i:=e2.x.i/PathL;
E2.y.r:=e2.y.r/PathL;
E2.y.i:=e2.y.i/PathL;
E2.z.r:=e2.z.r/PathL;
E2.z.i:=e2.z.i/PathL;

{将相位放到复数里面去,以便用复数的乘法计算场强的复数形式}
Phase.r:=cos(constk*PathL);
Phase.i:=-sin(constk*PathL);

E2.x:=ComplexMultiply(E2.x,Phase);
E2.y:=ComplexMultiply(E2.y,Phase);
E2.z:=ComplexMultiply(E2.z,Phase);



{射线二结束}

{射线三}
for i:=0 to tabletrace.fieldbyname('StopNo').AsInteger-1 do
begin
tableplane.SetKey;
tableplane.FieldByName('no').AsInteger:=tabletrace.fieldbyname('rt'+inttostr(i)+'r3_PNo').AsInteger;
{找出交点和相交平面}
if tableplane.GotoKey then
begin
PointTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spx').AsFloat;
PointTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spy').AsFloat;
PointTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spz').AsFloat;

VectorTemp.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'r3_vx').AsFloat;
VectorTemp.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'r3_vy').AsFloat;
VectorTemp.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'r3_vz').AsFloat;

PlaneTemp.Point_In_Plane.x:=tableplane.fieldbyname('px').AsFloat;
PlaneTemp.Point_In_Plane.y:=tableplane.fieldbyname('py').AsFloat;
PlaneTemp.Point_In_Plane.z:=tableplane.fieldbyname('pz').AsFloat;

PlaneTemp.Normal_Direction_of_Plane.x:=tablePlane.fieldbyname('nvx').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.y:=tablePlane.fieldbyname('nvy').AsFloat;
PlaneTemp.Normal_Direction_of_Plane.z:=tablePlane.fieldbyname('nvz').AsFloat;

PlaneTemp.Range_Min.x:=tablePlane.fieldbyname('x_min').AsFloat;
PlaneTemp.Range_Min.y:=tablePlane.fieldbyname('y_min').AsFloat;
PlaneTemp.Range_Min.z:=tablePlane.fieldbyname('z_min').AsFloat;

PlaneTemp.Range_Max.x:=tablePlane.fieldbyname('x_max').AsFloat;
PlaneTemp.Range_Max.y:=tablePlane.fieldbyname('y_max').AsFloat;
PlaneTemp.Range_Max.z:=tablePlane.fieldbyname('z_max').AsFloat;

planetemp.Material.E.r:=tableplane.fieldbyname('e_r').AsFloat;
planetemp.Material.E.i:=tableplane.fieldbyname('e_i').AsFloat;
planetemp.Material.u.r:=tableplane.fieldbyname('u').AsFloat;
planetemp.Material.sigma:=tableplane.fieldbyname('sigma').AsFloat;

if CrossTest(PointTemp,VectorTemp,Planetemp,
PathL,Insert_Point,Direction_Of_Bounce)
then
begin
{求入射波、反射波的平行垂直分量}
Relation_of_Incidence_And_Bounce(VectorTemp,Planetemp,
Direction_Incidence_Parallel,Direction_Incidence_Vertical,
Direction_Bounce_Parallel,Direction_Bounce_Vertical );

BounceLoss(VectorTemp,Planetemp.Normal_Direction_of_Plane,
Direction_Incidence_Parallel,Direction_Incidence_Vertical,
Direction_Bounce_Parallel,Direction_Bounce_Vertical,
Planetemp.Material,Freq,E3);
end;
end;
end;{for i:=0 to tabletrace.fieldbyname('StopNo').AsInteger-1 do}

{累加射线传播路径}
PathL:=0;

for i:=1 to tabletrace.fieldbyname('StopNo').AsInteger-1 do
begin
Pt1.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spx').AsFloat;
Pt1.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spy').AsFloat;
Pt1.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spz').AsFloat;

Pt2.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_epx').AsFloat;
Pt2.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_epy').AsFloat;
Pt2.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_epz').AsFloat;

PathL:=PathL+Ptp_Distance(pt1,pt2);
end;
i:=tabletrace.fieldbyname('StopNo').AsInteger;
Pt1.x:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spx').AsFloat;
Pt1.y:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spy').AsFloat;
Pt1.z:=tabletrace.fieldbyname('rt'+inttostr(i)+'R3_spz').AsFloat;

Pt2.x:=tabletrace.fieldbyname('r3_px').AsFloat;
Pt2.y:=tabletrace.fieldbyname('r3_py').AsFloat;
Pt2.z:=tabletrace.fieldbyname('r3_pz').AsFloat;

PathL:=PathL+Ptp_Distance(pt1,pt2);

E3.x.r:=e3.x.r/PathL;
E3.x.i:=e3.x.i/PathL;
E3.y.r:=e3.y.r/PathL;
E3.y.i:=e3.y.i/PathL;
E3.z.r:=e3.z.r/PathL;
E3.z.i:=e3.z.i/PathL;


{将相位放到复数里面去,以便用复数的乘法计算场强的复数形式}
Phase.r:=cos(constk*PathL);
Phase.i:=-sin(constk*PathL);

E3.x:=ComplexMultiply(E3.x,Phase);
E3.y:=ComplexMultiply(E3.y,Phase);
E3.z:=ComplexMultiply(E3.z,Phase);



{射线三结束}

{按比例相加三个射线的贡献}
E.x.r:=(E1.x.r*(l2+l3)/(l1+l2+l3)+
E2.x.r*(l1+l3)/(l1+l2+l3)+
E3.x.r*(l1+l2)/(l1+l2+l3))/2;
E.x.i:=(E1.x.i*(l2+l3)/(l1+l2+l3)+
E2.x.i*(l1+l3)/(l1+l2+l3)+
E3.x.i*(l1+l2)/(l1+l2+l3))/2;
E.y.r:=(E1.y.r*(l2+l3)/(l1+l2+l3)+
E2.y.r*(l1+l3)/(l1+l2+l3)+
E3.y.r*(l1+l2)/(l1+l2+l3))/2;
E.y.i:=(E1.y.i*(l2+l3)/(l1+l2+l3)+
E2.y.i*(l1+l3)/(l1+l2+l3)+
E3.y.i*(l1+l2)/(l1+l2+l3))/2;
E.z.r:=(E1.z.r*(l2+l3)/(l1+l2+l3)+
E2.z.r*(l1+l3)/(l1+l2+l3)+
E3.z.r*(l1+l2)/(l1+l2+l3))/2;
E.z.i:=(E1.z.i*(l2+l3)/(l1+l2+l3)+
E2.z.i*(l1+l3)/(l1+l2+l3)+
E3.z.i*(l1+l2)/(l1+l2+l3))/2;

{叠加所有的贡献}
Eout.x:=ComplexAdd(E.x,Eout.x);
Eout.y:=ComplexAdd(E.y,Eout.y);
Eout.z:=ComplexAdd(E.z,Eout.z);


tabletrace.Next;
end;{while not tabletrace.Eof do}

Eout.x.r:=Eout.x.r+DirectEField.x.r;
Eout.x.i:=Eout.x.i+DirectEField.x.i;
Eout.y.r:=Eout.y.r+DirectEField.y.r;
Eout.y.i:=Eout.y.i+DirectEField.y.i;
Eout.z.r:=Eout.z.r+DirectEField.z.r;
Eout.z.i:=Eout.z.i+DirectEField.z.i;

ProgressBar.Position:=ProgressBar.Max;
finally
closefile(f2);
end;
end;{Procedure end;}
 
你的程序中可否有aaaa.setfoucs
 
没有,我在程序中不需要用户输入什么,只是使用了进度条。
进度条如源码所示。没有问题吧?
 
太长了,看得头昏。高手啊!
 
在你的程序中有对数据表的频繁操作,这时记住在你
Table1.open;
插入,编辑,删除之后,
别忘了马上Table1.Close;
下次用的时候再Open。这样就不会出错了。
你的错误和数据模块没有关系,调用数据模块里的Table.post决对可以。
 
接受答案了.
 
后退
顶部