| 399 | |
| 400 | |
| 401 | int |
| 402 | FilePlotter::plotFiles(void) |
| 403 | { |
| 404 | /* |
| 405 | * first pass: 1) open files |
| 406 | * 2) determine number of entries on first line ASSSSSUME same through file |
| 407 | * 3) determine number of lines and bounds [xmin, xmax, ymin, ymax] |
| 408 | * 4) close the file |
| 409 | */ |
| 410 | |
| 411 | // open file |
| 412 | ifstream theXfile; |
| 413 | theXfile.open(fileName1, ios::in); |
| 414 | |
| 415 | ifstream theYfile; |
| 416 | theYfile.open(fileName2, ios::in); |
| 417 | |
| 418 | if (theXfile.bad() || theYfile.bad()) { |
| 419 | opserr << "WARNING - FilePlotter::FilePlotter()"; |
| 420 | opserr << " - could not open files " << fileName1 << " " << fileName2 << endln; |
| 421 | return -1; |
| 422 | } |
| 423 | |
| 424 | double xMin, xMax, yMin, yMax; |
| 425 | xMin = 0; xMax = 0; yMin =0; yMax =0; |
| 426 | double xValue, yValue; |
| 427 | |
| 428 | // determine number of elements in each line |
| 429 | // NOTE ASSUMES ALL LINES HAVE THE SAME NUMBER OF ELEMENTS |
| 430 | char c; |
| 431 | int numLineEntriesX = 0; |
| 432 | int numLineEntriesY = 0; |
| 433 | int numLinesX = 0; |
| 434 | int numLinesY = 0; |
| 435 | |
| 436 | while (theXfile.get(c) && (c!= EOF) && c != '\n') { |
| 437 | if (!isspace(c)) { |
| 438 | theXfile.putback(c); |
| 439 | |
| 440 | theXfile >> xValue; |
| 441 | for (int i=0; i<cols->Size(); i++) { |
| 442 | if (i%2 == 0) { // an xValue if numLineEntries == colX |
| 443 | if (numLineEntriesX == (*cols)(i)) { |
| 444 | if (xValue < xMin) xMin = xValue; |
| 445 | if (xValue > xMax) xMax = xValue; |
| 446 | } |
| 447 | } |
| 448 | } |
| 449 | numLineEntriesX ++; |
| 450 | } |
| 451 | numLinesX =1; |
| 452 | } |
| 453 | |
| 454 | while (theYfile.get(c) && (c!= EOF) && c != '\n') { |
| 455 | if (!isspace(c)) { |
| 456 | theYfile.putback(c); |
| 457 | |
| 458 | theYfile >> yValue; |
no test coverage detected