Changeset 3874 in Sophya for trunk/SophyaLib/NTools/slininterp.cc
- Timestamp:
- Sep 7, 2010, 7:48:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/slininterp.cc
r3869 r3874 175 175 176 176 177 /* --Methode-- */ 178 size_t SLinInterp1D::ReadYFromFile(string const& filename, double xmin, double xmax) 177 /*! 178 \brief Read Y values from the file \b filename 179 180 Read Y values ( one/line) for regularly spaced X's from file \b filename and call 181 DefinePoints(xmin, xmax, yreg). Return the number of Y values read. 182 \param filename : input file name 183 \param xmin,xamx : X range limits 184 \param clm : comment character, lines starting with \b clm are ignored 185 */ 186 size_t SLinInterp1D::ReadYFromFile(string const& filename, double xmin, double xmax, char clm) 179 187 { 180 188 ifstream inputFile; … … 192 200 size_t cnt=0; 193 201 double cola; 202 string eline; 194 203 while(!inputFile.eof()) { 195 204 inputFile.clear(); 205 if (inputFile.peek() == (int)clm) { // skip comment lines 206 getline(inputFile, eline); 207 continue; 208 } 196 209 inputFile >> cola; 197 210 if ( (!inputFile.good()) || inputFile.eof()) break; 211 inputFile.ignore(1024,'\n'); // make sure we go to the next line 198 212 //cout << cola<< " "<<colb<<endl; 199 213 ysv.push_back(cola); … … 206 220 } 207 221 208 /* --Methode-- */ 209 size_t SLinInterp1D::ReadXYFromFile(string const& filename, double xmin, double xmax, size_t npt) 222 /*! 223 \brief Read pairs of ( X Y ) values from file \b filename 224 225 Read pairs of (X Y) values, one pair / line from the specified file and call DefinePoints(xs, ys ...). 226 One pair of space or tab separated numbers on each line. Return the number of Y values read. 227 \param filename : input file name 228 \param xmin,xamx : X range limits. use the X limits from the file if xmax<xmin 229 \param npt : number of points for regularly spaced interpolation points 230 \param clm : comment character, lines starting with \b clm are ignored 231 */ 232 size_t SLinInterp1D::ReadXYFromFile(string const& filename, double xmin, double xmax, size_t npt, char clm) 210 233 { 211 234 ifstream inputFile; … … 223 246 size_t cnt=0; 224 247 double cola, colb; 248 string eline; 225 249 while(!inputFile.eof()) { 226 250 inputFile.clear(); 251 if (inputFile.peek() == (int)clm) { // skip comment lines 252 getline(inputFile, eline); 253 continue; 254 } 227 255 inputFile >> cola >> colb; 228 256 if ( (!inputFile.good()) || inputFile.eof()) break; 229 // cout << " DEBUG - cnt=" << cnt << " x=" << cola << " y= "<<colb<<endl; 257 inputFile.ignore(1024,'\n'); // make sure we go to the next line 258 // cout << " DEBUG-GCount " << inputFile.gcount() << endl; 259 // cout << " DEBUG - cnt=" << cnt << " x=" << cola << " y= "<<colb<<endl; 230 260 xsv.push_back(cola); 231 261 ysv.push_back(colb);
Note:
See TracChangeset
for help on using the changeset viewer.