initial upload
This commit is contained in:
103
archive/TetraGM/res_reg.h
Normal file
103
archive/TetraGM/res_reg.h
Normal file
@@ -0,0 +1,103 @@
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#ifndef _RES_REG_H
|
||||
#define _RES_REG_H
|
||||
#include "Data_Func.h"
|
||||
|
||||
class res_reg
|
||||
{
|
||||
public:
|
||||
res_reg(int);
|
||||
~res_reg();
|
||||
int res_add(double *,int);
|
||||
int savedat(string,int,sphere_point *);
|
||||
int savedat(string,int,point3d *);
|
||||
int check(int);
|
||||
private:
|
||||
double *tempresult;
|
||||
};
|
||||
|
||||
res_reg::res_reg(int M)
|
||||
{
|
||||
tempresult = new double [M];
|
||||
for(int i=0;i<M;i++)
|
||||
{
|
||||
tempresult[i]=0;
|
||||
}
|
||||
}
|
||||
|
||||
res_reg::~res_reg()
|
||||
{
|
||||
if(tempresult) delete []tempresult;
|
||||
}
|
||||
|
||||
int res_reg::res_add(double *result,int M)
|
||||
{
|
||||
for(int i=0;i<M;i++)
|
||||
{
|
||||
tempresult[i]+=*(result+i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int res_reg::savedat(string filename,int sum,sphere_point *fie)
|
||||
{
|
||||
ofstream fout;
|
||||
string tempname = filename + ".dat";
|
||||
const char* savename = tempname.c_str();
|
||||
fout.open(savename);
|
||||
if(!fout)
|
||||
{
|
||||
cout<<"can't create "<<savename<<endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<<"saving "<<savename<<"..."<<endl;
|
||||
fout<<"Longitude(degree) Latitude(degree) Radius(m) Value"<<endl;
|
||||
for(int i=0;i<sum;i++)
|
||||
{
|
||||
fout<<setprecision(16)<<fie[i].phi<<" "<<fie[i].thet<<" "<<fie[i].radius<<" "<<tempresult[i]<<endl;
|
||||
}
|
||||
fout.close();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int res_reg::savedat(string filename,int sum,point3d *fie)
|
||||
{
|
||||
ofstream fout;
|
||||
string tempname = filename + ".dat";
|
||||
const char* savename = tempname.c_str();
|
||||
fout.open(savename);
|
||||
if(!fout)
|
||||
{
|
||||
cout<<"can't create "<<filename<<endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<<"saving "<<filename<<"..."<<endl;
|
||||
//fout<<"X(m) Y(m) Z(m) Value"<<endl;
|
||||
for(int i=0;i<sum;i++)
|
||||
{
|
||||
//fout<<setprecision(16)<<fie[i].x<<" "<<fie[i].y<<" "<<fie[i].z<<" "<<tempresult[i]<<endl;
|
||||
fout<<setprecision(16)<<fie[i].x<<" "<<fie[i].y<<" "<<fie[i].z<<" "<<tempresult[i]<<endl;
|
||||
}
|
||||
fout.close();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int res_reg::check(int sum)
|
||||
{
|
||||
for(int i=0;i<sum;i++)
|
||||
{
|
||||
if(tempresult[i]!=tempresult[i])
|
||||
{
|
||||
cout<<"A non-numeric data is detected."<<endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user