Skip to content
Snippets Groups Projects
Commit e69c5a8e authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

removed obsolete, unused, misleading, duplicate Load routines from CEle and CScan

parent a9a108ea
No related branches found
No related tags found
No related merge requests found
......@@ -226,87 +226,6 @@ void CEle::Save( FILE *fd, string fmt )
};
//! OBSOLETE ??? ( obsoleted by File_io ? )
void CEle::Load( FILE *fd, string fshort )
{
throw string( " sorry, in oct07 JWu thought Ele::Load was obsolete" );
COlc C;
COld D;
CScan DS;
CCurve CS;
CCoord co;
uint iz, nj=0, j;
string lin, test;
if (mystd::freadln(fd, &lin)<=0)
throw string( "! file empty or starting with empty line" );
if (lin!=string("ASCII-01 JWu"))
throw "! unknown file format: " + lin;
if (mystd::freadln(fd, &lin)<=0)
throw string( "! unexpected empty line\n");
if (lin.substr(0,4)!=string("typ "))
throw string( "! missing \"typ\" entry\n");
if (lin.substr(4)=="D") {
Typ = DATA;
Ptr = &D;
} else if (lin.substr(4)=="C") {
Typ = CURVE;
Ptr = &C;
} else
throw "FATAL: invalid type: " + lin.substr(4);
P()->name = fshort;
while (1) {
if (mystd::freadln(fd, &lin)<0)
throw string( "! unexpected end-of-file" );
if (lin=="eof") {
NOlm::OloAdd(P())->P()->as_on_disk = true;
return; // regular exit
} else if (lin.substr(0,4)=="fil ") {
if (lin.substr(4)!=fshort) {
printf("! warning: file %s renamed from %s\n",
fshort.c_str(), lin.substr(4).c_str());
}
} else if (lin.substr(0,4)=="doc ") {
P()->lDoc.push_back(lin.substr(4));
} else if (lin.substr(0,4)=="x ") {
P()->xco.load(lin.substr(4));
} else if (lin.substr(0,4)=="y ") {
P()->yco.load(lin.substr(4));
} else if (lin[0]=='z') {
if (sscanf(lin.substr(1,3).c_str(), "%u", &iz)!=1)
throw string( "z coordinates must be numbered" );
if (iz!=P()->ZCo.size())
throw string( "z coordinates must be sorted" );
co.load(lin.substr(4));
P()->ZCo.push_back(co);
} else if (lin.substr(0,4)=="#j ") {
if (sscanf(lin.substr(4).c_str(), "%u", &nj)!=1)
throw string( "after label #j no no. of scans" );
} else if (lin.substr(0,4)=="scn ") {
if (sscanf(lin.substr(4).c_str(), "%u", &j)!=1) {
throw string( "! number of scan not given\n");
} else if (j!=nScan()) {
printf("scan %u, label %u\n", nScan(), j);
throw string( "inconsistency in input file" );
}
if (Typ == DATA) {
DS.Load( fd, P()->ZCo.size() );
D.VS.push_back(DS);
} else if (Typ == CURVE) {
CS.Load( fd, P()->ZCo.size() );
C.VC.push_back(CS);
} else
throw string( "FATAL: invalid Typ" );
} else
throw "! Unexpected label " + lin.substr(0,4);
}
}
//***************************************************************************//
//* namespace NOlm *//
//***************************************************************************//
......
......@@ -147,7 +147,6 @@ class CEle {
else if (Typ==CURVE) return &(((COlc*) Ptr)->VC[j].z);
else throw string( "FATAL ERROR in CEle:Z()" );
};
void Load( FILE *fd, string fshort );
void Save( FILE *fd, string fmt );
};
......
......@@ -18,29 +18,24 @@
//* Construct or modify *//
//**************************************************************************//
CScan::CScan(const vector<double>& X_in, const vector<double>& Y_in,
const vector<double>& Z_in)
{
if (X_in.size() != Y_in.size())
throw string( "PROGRAM ERROR: cannot make scan "
"from incompatible input vectors" );
x = X_in;
y = Y_in;
z = Z_in;
}
//! Append given data point.
void CScan::push_back(const double x_in, const double y_in)
void CScan::push_back( const double x_in, const double y_in )
{
x.push_back(x_in);
y.push_back(y_in);
}
void CScan::erase(const uint begin, const uint end)
//! Remove data points according to given indices.
void CScan::erase( const uint begin, const uint end )
{
x.erase(x.begin()+begin, x.begin()+end);
y.erase(y.begin()+begin, y.begin()+end);
x.erase( x.begin()+begin, x.begin()+end );
y.erase( y.begin()+begin, y.begin()+end );
}
//! Reset to initial state.
void CScan::Clear(void)
{
x.clear();
......@@ -52,6 +47,8 @@ void CScan::Clear(void)
//* Input, output *//
//**************************************************************************//
//! Write scan to open file.
void CScan::Save( FILE *fd, string fmt ) const
{
if( fmt=="y08" ){
......@@ -70,58 +67,6 @@ void CScan::Save( FILE *fd, string fmt ) const
}
}
int CScan::Load(FILE *fd, uint nz)
{
int err;
uint i, m;
char lab[4];
double v, w;
Clear();
if ((err=fscanf(fd, "%4c%u\n", lab, &m))!=2) {
printf("! expecting Z head line, found %d entries\n", err);
return -1;
}
if (strncmp(lab, "Z ", 4)) {
printf("! found [%s] in Z head line\n", lab);
return -1;
}
if (m!=nz) {
printf("! found %u Z entries, expecting %u\n", m, nz);
return -1;
}
for (i=0; i<nz; i++) {
if ((err=fscanf(fd, "%lg\n", &v))!=1) {
printf("! expecting z value, found %d entries\n", err);
return -1;
}
z.push_back(v);
}
// printf(".. read %u z values\n", nz);
if ((err=fscanf(fd, "%4c%u\n", lab, &m))!=2) {
printf("! expecting XY head line, found %d entries\n", err);
return -1;
}
if (strncmp(lab, "XY ", 4)) {
printf("! found [%s] in XY head line\n", lab);
return -1;
}
for (i=0; i<m; i++) {
if ((err=fscanf(fd, "%lg %lg\n", &v, &w))!=2) {
printf("! expecting xy pair, found %d entries\n", err);
return -1;
}
push_back(v, w);
}
// printf(".. read %u xy pairs\n", m);
return 0;
}
//**************************************************************************//
//* Extract data *//
//**************************************************************************//
......
......@@ -5,16 +5,13 @@ class CScan {
// construct, modify:
inline CScan() {};
CScan(const vector<double>& X_in, const vector<double>& Y_in,
const vector<double>& Z_in);
void push_back(const double x_in, const double y_in);
void push_back( const double x_in, const double y_in );
void Clear(void);
void erase(const uint begin, const uint end);
void erase( const uint begin, const uint end );
// input, output:
void Save( FILE *fd, string fmt ) const;
int Load( FILE *fd, uint nz );
// extract data:
size_t size() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment