-
Notifications
You must be signed in to change notification settings - Fork 0
/
Equation.cpp
402 lines (352 loc) · 13.3 KB
/
Equation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// NAME : class EQUATION.CPP
// PARAMETERS:
// 2.The number of the Left-Top V-Block is 0.
// 3. X Direction : direction perpendicular to the recieve line.
// Y Direction : direction parrall to the recieve line.
// 4. ShotPointNumber and RecievePoint Number:
// are both definited as:
// They increase on X direction firstly,
// and increase to the second Y line.
// 4. Ph of Shot Points:
// MUST be 6 caractars. the first 3 is for Shot Line
// and the second 3 is for shot point line.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "3dfstbrk.h"
#include "stdio.h"
#include "struct.h"
#include "svsys.h"
#include "swathpar.h"
#include "spp.h"
#include "equation.h"
#include "progdlg.h"
#include "fh.h"
#include "SPPDoc.h"
#include "MidFbkFile.h"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction Code EQUATION() BEGIN
Equation::Equation()
{
Reset();
}
void Equation::Reset()
{
ss.Reset();
sp.Reset();
}
// Construction Code EQUATION() END
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction Code EQUATION() BEGIN
bool Equation::Set(int Swath)
{
SetFileName(Swath);
if(!ss.Set())return false; ;
if(!sp.Set(Swath))return false;
// 设置 1.总炮点数目,2.总检波点数目,3. 炮,检点数目之和.
CSPPDoc spp;
spp.Set(Swath);
if(!spp.Read())return false;
m_TotalSNumber=spp.m_TotalSNumber;
m_TotalRNumber=sp.TotalRecievePointNumber;
m_TotalRSNumber=m_TotalSNumber+m_TotalRNumber;
// the Above two kind of parameters are good.
return TRUE;
}
// Construction Code EQUATION() END
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 函数名: Equation::ReadInputStaticData
// 功 能: 读取由其它方法获得的静校正量.
// 更 改:
// PXYV *S,存储炮点静校正量的内存起始地址,
// PXYV *R,存储检波点静校正量的内存起始地址,
// 结构为: 桩号,X坐标,Y坐标,静校正量.
// long *SN , 炮点数目的地址.
// long *RN , 检波点数目的地址.
//
// 返 回: BOOL, 成功 TRUE.
// 日 期: 1997.9.24
BOOL Equation::ReadInputStaticData(PXYV *S,PXYV *R,long *SN,long *RN)
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// read shot point pxyv.
FILE *fp=fopen(m_FileInputShot,"r");
if(!fp){
AfxMessageBox("初始静校正量文件: "+m_FileInputShot+" 不存在!");
return FALSE;
}
fseek(fp,0,SEEK_END);
float TotalLen=(float)ftell(fp);
long CurrPos;
fseek(fp,0,SEEK_SET);
CProgressDlg dlg;
dlg.Create();
dlg.SetWindowText("正在读取数据");
dlg.SetStatus("读取由其它方法得到的炮点静校正文件:");
long n=0;
int nRead=0;
while(!feof(fp)){
nRead=fscanf(fp,"%d %lf %lf %f\n",&S[n].Ph,&S[n].east,&S[n].north,&S[n].Value);
if(nRead<4){
AfxMessageBox("其他方法得到的炮点静校正量文件比预期要短!");
return false;
}
n++;
if(n%10==0){
CurrPos=ftell(fp);
dlg.SetPos(CurrPos/TotalLen*100.0);
}
}
*SN=n;
fclose(fp);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// read recieve point pxyv.
fp=fopen(m_FileInputRecieve,"r");
if(!fp){
AfxMessageBox("初始静校正量文件: "+m_FileInputRecieve+" 不存在!");
return FALSE;
}
fseek(fp,0,SEEK_END);
TotalLen=(float)ftell(fp);
fseek(fp,0,SEEK_SET);
dlg.SetWindowText("正在读取数据");
dlg.SetStatus("读取由其它方法得到的检波点静校正文件:");
n=0;
while(!feof(fp)){
nRead=fscanf(fp,"%ld %lf %lf %f\n",&R[n].Ph,&R[n].east,&R[n].north,&R[n].Value);
if(nRead<4){
AfxMessageBox("其他方法得到的检波点静校正量文件比预期要短!");
return false;
}
n++;
if(n%10==0){
CurrPos=ftell(fp);
dlg.SetPos(CurrPos/TotalLen*100.0);
}
}
*RN=n;
fclose(fp);
dlg.DestroyWindow();
return TRUE;
}
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 函数名: Equation::SaveInputStaticData
// 功 能: 存由其它方法获得的静校正量,用于文件转换.
// 输 入:
// PXYV *S,存储炮点静校正量的内存起始地址,
// PXYV *R,存储检波点静校正量的内存起始地址,
// 结构为: 桩号,X坐标,Y坐标,静校正量.
// long SN , 炮点数目.
// long RN , 检波点数目.
// 返 回: BOOL, 成功 TRUE.
// 日 期: 1997.9.24
BOOL Equation::SaveInputStaticData(PXYV *S,PXYV *R,long SN,long RN)
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 读取炮点数据
FILE *fp=fopen(m_FileInputShot,"w");
if(!fp){
AfxMessageBox("无法建立初始静校正量文件: "+m_FileInputShot+" !");
return FALSE;
}
for(int i=0;i<SN;i++){
fprintf(fp,"%d %lf %lf %f\n",S[i].Ph,S[i].east,S[i].north,S[i].Value);
}
fclose(fp);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 读取检波点数据
fp=fopen(m_FileInputRecieve,"w");
if(!fp){
AfxMessageBox("无法建立初始静校正量文件: "+m_FileInputRecieve+" !");
return FALSE;
}
for(i=0;i<RN;i++){
fprintf(fp,"%d %lf %lf %f\n",R[i].Ph,R[i].east,R[i].north,R[i].Value);
}
fclose(fp);
// 返回.
return TRUE;
}
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 函数名: Equation::ReadMidStaticData
// 功 能: 读取本软件计算获得的静校正量成果文件.
// 改 变: double *RSRoom,用于接收静校正量的内存起始地址.
// 日 期: 1997.9.24
BOOL Equation::ReadMidStaticData(long *Ph,double *RSRoom)
{
// 打开文件.
FILE *fps=fopen(m_FileMidShot,"r");
if(!fps){
AfxMessageBox("炮点中间成果文件 :"+m_FileMidShot+" 不存在!");
return FALSE;
}
FILE *fpr=fopen(m_FileMidRecieve,"r");
if(!fpr){
AfxMessageBox("检波点中间成果文件 :"+m_FileMidRecieve+" 不存在!");
return FALSE;
}
// 读取炮点数据.
for(int i=0;i<m_TotalSNumber;i++){
if(feof(fps))return FALSE;
fscanf(fps,"%ld %lf\n",&Ph[i],&RSRoom[i]);
}
// 读取检波点数据.
for(i=0;i<m_TotalRNumber;i++){
if(feof(fpr))return FALSE;
fscanf(fpr,"%ld %lf",&Ph[m_TotalSNumber+i],&RSRoom[m_TotalSNumber+i]);
}
fclose(fps);
fclose(fpr);
// 返回主程序.
return TRUE;
}
// 函数名: Equation::ReadMidStaticData 结束
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 函数名: Equation::SaveMidStaticData
// 功 能: 对本软件计算获得的静校正量成果文件 存盘.
// 输 入: double *RSRoom,存储静校正量的内存起始地址.
// 日 期: 1997.9.24
BOOL Equation::SaveMidStaticData(double * RSRoom)
{
CMidFbkFile file;
// Save the shot parameter:
CSPPDoc sppd;
sppd.Set(m_SwathNumber);
if(!sppd.Read())return FALSE;
file.SetShotNumber (m_TotalSNumber );
for(long i=0;i<m_TotalSNumber ;i++){
file.m_pShotData [i].Ph =sppd.m_pSPP [i].m_Ph ;
file.m_pShotData [i].Value =-RSRoom[i];
}
if(!file.WriteShot ())return false;
// Save the rcv data:
file.SetRcvNumber (m_TotalRNumber );
long j,n,Ph;
for(i=0;i<m_TotalRNumber/ss.RecieveLineNumber;i++){
for(j=0;j<ss.RecieveLineNumber;j++){
long PhL=sp.RecieveLineName[j]*1000;
long PhR=sp.FirstRecievePointNumber+i;
Ph=PhL+PhR;
//Ph=sp.RecieveLineName[j]*1000+sp.FirstRecievePointNumber+i;
n=i*ss.RecieveLineNumber+j;
file.m_pRcvData [n].Ph =Ph;
file.m_pRcvData [n].Value =-RSRoom[n+m_TotalSNumber];
}
}
if(!file.WriteRcv ())return false;
//
return TRUE;
}
// 函数名: Equation::SaveMidStaticData 结束
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 函数名: Equation::ReadOutputStaticData
// 功 能: 读取本软件计算的, 经过长波长校正的静校正量, 用于文件格式转换
// 更 改:
// PXYV *S,存储炮点静校正量的内存起始地址,
// PXYV *R,存储检波点静校正量的内存起始地址,
// 结构为: 桩号,X坐标,Y坐标,静校正量.
// 日 期: 1997.9.24
BOOL Equation::ReadOutputStaticData(PXYV *S,PXYV *R)
{
// 读取炮点数据.
FILE *fp=fopen(m_FileOutputShot,"r");
if(!fp){
AfxMessageBox("成果文件:"+m_FileOutputShot+" 不存在!");
return FALSE;
}
for(int i=0;i<m_TotalSNumber;i++){
if(feof(fp))return FALSE;
fscanf(fp,"%ld %lf %lf %f\n",&S[i].Ph,&S[i].east,&S[i].north,&S[i].Value);
}
fclose(fp);
// 读取检波点数据.
fp=fopen(m_FileOutputRecieve,"r");
if(!fp){
AfxMessageBox("无法建立成果文件:"+m_FileOutputRecieve);
return FALSE;
}
for(i=0;i<m_TotalRNumber;i++){
if(feof(fp))return FALSE;
fscanf(fp,"%ld %lf %lf %f\n", &R[i].Ph,&R[i].east,&R[i].north,&R[i].Value);
}
fclose(fp);
// 返回主程序.
return TRUE;
}
// 函数名: Equation::ReadOutputStaticData 结束
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 函数名: Equation::SaveOutputStaticData
// 功 能: 对本软件计算的, 经过长波长校正的静校正量, 存盘.
// 输 入:
// PXYV *S,存储炮点静校正量的内存起始地址,
// PXYV *R,存储检波点静校正量的内存起始地址,
// 结构为: 桩号,X坐标,Y坐标,静校正量.
//
// 日 期: 1997.9.24
BOOL Equation::SaveOutputStaticData(PXYV *S,PXYV *R)
{
// 存炮点数据.
FILE *fp=fopen(m_FileOutputShot,"w");
if(!fp){
AfxMessageBox("无法建立成果文件:"+m_FileOutputShot);
return FALSE;
}
CProgressDlg dlg;
dlg.Create();
dlg.SetWindowText("存储数据");
dlg.SetStatus("正在存储炮点最终成果静校正量:");
for(int i=0;i<m_TotalSNumber;i++){
fprintf(fp,"%ld %9.1f %10.1f %5.2f\n",S[i].Ph,S[i].east,S[i].north,S[i].Value);
if(i%10==0){
dlg.SetPos((float)i/m_TotalSNumber*100);
}
}
fclose(fp);
// 存检波点数据.
fp=fopen(m_FileOutputRecieve,"w");
if(!fp){
AfxMessageBox("无法建立成果文件:"+m_FileOutputRecieve);
return FALSE;
}
dlg.SetStatus("正在存储检波点最终成果静校正量:");
for(i=0;i<m_TotalRNumber;i++){
fprintf(fp,"%ld %9.1f %10.1f %5.2f\n", R[i].Ph,R[i].east,R[i].north,R[i].Value);
dlg.SetPos((float)i/m_TotalRNumber*100);
}
fclose(fp);
dlg.DestroyWindow();
// 返回主程序.
return TRUE;
}
// 函数名: Equation::SaveOutputStaticData 结束
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool Equation::SetFileName(int Swath)
{
// Make a common file name, which will be used by derived class.
m_SwathNumber=Swath;
m_FileName=IntToName(Swath);
// 初至文件的名称.
m_FileSwathFirstBreak="swath"+m_FileName+".FBD";
// Make file names that will be used in derived classes.
m_FileRS="RS"+m_FileName+".DAT"; // Binary file recording which shot and recieve plused.
m_Fileb="b"+m_FileName+".DAT"; // Binary file recording S & R value plused.
m_FileNumInColOfRS="NCRS"+m_FileName+".DAT";
m_FileRSTurned="RST"+m_FileName+".DAT";
m_FileInputShot="swath"+m_FileName+".ST"; // Binary File including Ph,X,Y,V, calculated by Sand Wave Method.
m_FileInputRecieve="swath"+m_FileName+".RT"; // Binary File including Ph,X,Y,V, calculated by Sand Wave Method.
m_FileMidShot="SMID"+m_FileName+".DAT"; // Binary File including Static Value ,Calculated by this Program , Not Controlled.
m_FileMidRecieve="RMID"+m_FileName+".DAT"; // Binary File including Static Value ,Calculated by this Program , Not Controlled.
m_FileOutputShot="SOUT"+m_FileName+".DAT"; // Binary File that has been controlled.
m_FileOutputRecieve="ROUT"+m_FileName+".DAT"; // Binary File that has been controlled.
m_FileEquationNumber="EN"+m_FileName+".TXT"; // Give value to m_EquationNumber .
return true;
}