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

more info when points out of range

parent 2a3cf8fd
No related branches found
No related tags found
No related merge requests found
......@@ -437,20 +437,18 @@ void NPlot::Box()
ps_accu.push_back( "\n%% modeDD\nplotbefore\n" );
}
void NPlot::Line(const int lstyle,
const vector<double> x, const vector<double> y,
const vector<double>* z,
const string xco, const string yco)
void NPlot::Line( const int lstyle,
const vector<double> x, const vector<double> y,
const vector<double>* z,
const string xco, const string yco,
const string info )
{
double *xp, *yp;
uint np=0, nxl=0, nxh=0, nyl=0, nyh=0;
uint n=x.size();
if (n!=y.size()) {
printf("PROG ERR NPLot::Line x.size<>y.size\n");
return;
}
xp = (double *) malloc(sizeof(double)*n);
yp = (double *) malloc(sizeof(double)*n);
if (n!=y.size())
throw string( "PROG ERR NPLot::Line x.size<>y.size" );
vector<double> xp, yp;
for (uint i=0; i<n; i++) {
if(!X.force && !X.R.contained(x[i])) {
if (x[i]<=X.R.inf) nxl++;
......@@ -462,19 +460,26 @@ void NPlot::Line(const int lstyle,
if (y[i]>=Y.R.sup) nyh++;
continue;
}
if(np==maxpoints && np<n) {
if( np==maxpoints && np<n) {
printf("reached maxpoints at %g\n", x[i]);
}
xp[np] = x[i];
yp[np] = y[i];
np++;
if(np>maxpoints) i += maxpoints;
xp.push_back( x[i] );
yp.push_back( y[i] );
np = xp.size();
if( np > maxpoints ) // continue in large steps
i += maxpoints;
}
if (np==0) {
printf("no points in data range:\n"
"of %d points are\n %d left and %d right of the x range,"
"\n %d below and %d above of the y range\n",
n, nxl, nxh, nyl, nyh);
if ( np==0 ) {
printf( "%s : all %d points outside plot range:\n",
info.c_str(), n );
if( nxl )
printf( " %d points < xmin\n", nxl );
if( nxh )
printf( " %d points > xmax\n", nxh );
if( nyl )
printf( " %d points < ymin\n", nyl );
if( nyh )
printf( " %d points > ymax\n", nyh );
return;
}
......@@ -489,10 +494,8 @@ void NPlot::Line(const int lstyle,
if (lstyle<0)
gp_fnames += " with lines";
FILE *gp_fd;
if (!(gp_fd = fopen(gp_fnam, "w"))) {
printf( "cannot save gnuplot data to %s", gp_fnam );
return;
}
if (!(gp_fd = fopen(gp_fnam, "w")))
throw string("cannot save gnuplot data to ") + gp_fnam;
for (uint i=0; i<np; i++)
fprintf(gp_fd, "%20.12g %20.12g\n", xp[i], yp[i]);
fclose(gp_fd);
......@@ -527,9 +530,6 @@ void NPlot::Line(const int lstyle,
i==0 ? 'i' : i==np-1 ? 'f' : ' ', xp[i], yp[i] );
ps_accu.push_back( outlin );
}
free(xp);
free(yp);
}
void NPlot::Doc (vector<string> lDoc)
......
......@@ -66,7 +66,8 @@ namespace NPlot { // additional declarations in dualplot.cpp
void Line( const int lstyle,
const vector<double> x, const vector<double> y,
const vector<double>* z,
const string xco, const string yco );
const string xco, const string yco,
const string info );
void Doc (vector<string> lDoc);
void Save( bool full_outfile );
void Dialog(void);
......
......@@ -1008,7 +1008,8 @@ void NEdif::Plot( bool add )
} else
throw string( "PROGRAM ERROR plot invalid *e" );
NPlot::Line( lstyle, s->x, s->y, e->Z(j),
e->P()->xco.str(), e->P()->yco.str() );
e->P()->xco.str(), e->P()->yco.str(),
"file "+strg(k)+" scan "+strg(j) );
}
NPlot::Doc( e->P()->lDoc );
if( fc )
......
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