| 458 | /////////////////////////////////////////////////////////////////////////////// |
| 459 | |
| 460 | int PIOAdaptor::parsePIOFile(const char* PIOFileName) |
| 461 | { |
| 462 | this->descFileName = PIOFileName; |
| 463 | vtksys::ifstream pioStr(this->descFileName.c_str()); |
| 464 | if (!pioStr) |
| 465 | { |
| 466 | vtkGenericWarningMacro("Could not open the global description .pio file: " << PIOFileName); |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | // Get the directory name from the full path of the .pio file in GUI |
| 471 | // or simple name from python script |
| 472 | std::string::size_type dirPos = this->descFileName.find_last_of(Slash); |
| 473 | std::string dirName; |
| 474 | if (dirPos == std::string::npos) |
| 475 | { |
| 476 | // No directory name included |
| 477 | std::ostringstream tempStr; |
| 478 | tempStr << "." << Slash; |
| 479 | dirName = tempStr.str(); |
| 480 | } |
| 481 | else |
| 482 | { |
| 483 | // Directory name before final slash |
| 484 | dirName = this->descFileName.substr(0, dirPos); |
| 485 | } |
| 486 | |
| 487 | // Either .pio file or an actual basename-dmp000000 to guide open file |
| 488 | // Opening actual dump file requires asking for All files and picking PIOReader |
| 489 | // Opening a pio suffix file defaults to the correct action |
| 490 | std::string::size_type pos = this->descFileName.rfind('.'); |
| 491 | std::string suffix = this->descFileName.substr(pos + 1); |
| 492 | if (suffix == "pio") |
| 493 | { |
| 494 | // Parse the pio input file |
| 495 | char inBuf[256]; |
| 496 | std::string rest; |
| 497 | std::string keyword; |
| 498 | this->useHTG = false; |
| 499 | this->useTracer = false; |
| 500 | this->useFloat64 = false; |
| 501 | this->hasTracers = false; |
| 502 | |
| 503 | while (pioStr.getline(inBuf, 256)) |
| 504 | { |
| 505 | std::string localline(inBuf); |
| 506 | localline = trimString(localline); |
| 507 | if (!localline.empty()) |
| 508 | { |
| 509 | if (localline[0] != '#' && localline[0] != '!') |
| 510 | { |
| 511 | // Remove quotes from input |
| 512 | localline.erase(std::remove(localline.begin(), localline.end(), '\"'), localline.end()); |
| 513 | localline.erase(std::remove(localline.begin(), localline.end(), '\''), localline.end()); |
| 514 | |
| 515 | // check for comments in the middle of the line |
| 516 | std::string::size_type poundPos = localline.find('#'); |
| 517 | if (poundPos != std::string::npos) |