| 143 |
|
prevPos = currPos; |
| 144 |
|
bool foundOpenSnapshotTag = false; |
| 145 |
|
bool foundClosedSnapshotTag = false; |
| 146 |
+ |
bool foundOpenSiteDataTag = false; |
| 147 |
|
while(inFile_->getline(buffer, bufferSize)) { |
| 148 |
|
++lineNo; |
| 149 |
|
|
| 326 |
|
|
| 327 |
|
inputStream.getline(buffer, bufferSize); |
| 328 |
|
line = buffer; |
| 329 |
< |
if (line.find("</Snapshot>") == std::string::npos) { |
| 330 |
< |
sprintf(painCave.errMsg, |
| 331 |
< |
"DumpReader Error: can not find </Snapshot>\n"); |
| 332 |
< |
painCave.isFatal = 1; |
| 333 |
< |
simError(); |
| 334 |
< |
} |
| 335 |
< |
|
| 329 |
> |
|
| 330 |
> |
if (line.find("<SiteData>") != std::string::npos) { |
| 331 |
> |
//read SiteData |
| 332 |
> |
readSiteData(inputStream); |
| 333 |
> |
} else { |
| 334 |
> |
if (line.find("</Snapshot>") == std::string::npos) { |
| 335 |
> |
sprintf(painCave.errMsg, |
| 336 |
> |
"DumpReader Error: can not find </Snapshot>\n"); |
| 337 |
> |
painCave.isFatal = 1; |
| 338 |
> |
simError(); |
| 339 |
> |
} |
| 340 |
> |
} |
| 341 |
|
} |
| 342 |
|
|
| 343 |
|
void DumpReader::parseDumpLine(const std::string& line) { |
| 524 |
|
} |
| 525 |
|
|
| 526 |
|
|
| 527 |
< |
void DumpReader::readStuntDoubles(std::istream& inputStream) { |
| 527 |
> |
void DumpReader::parseSiteLine(const std::string& line) { |
| 528 |
|
|
| 529 |
+ |
StringTokenizer tokenizer(line); |
| 530 |
+ |
int nTokens; |
| 531 |
+ |
|
| 532 |
+ |
nTokens = tokenizer.countTokens(); |
| 533 |
+ |
|
| 534 |
+ |
if (nTokens < 2) { |
| 535 |
+ |
sprintf(painCave.errMsg, |
| 536 |
+ |
"DumpReader Error: Not enough Tokens.\n%s\n", line.c_str()); |
| 537 |
+ |
painCave.isFatal = 1; |
| 538 |
+ |
simError(); |
| 539 |
+ |
} |
| 540 |
+ |
|
| 541 |
+ |
/** |
| 542 |
+ |
* The first token is the global integrable object index. |
| 543 |
+ |
*/ |
| 544 |
+ |
|
| 545 |
+ |
int index = tokenizer.nextTokenAsInt(); |
| 546 |
+ |
StuntDouble* integrableObject = info_->getIOIndexToIntegrableObject(index); |
| 547 |
+ |
if (integrableObject == NULL) { |
| 548 |
+ |
return; |
| 549 |
+ |
} |
| 550 |
+ |
StuntDouble* sd = integrableObject; |
| 551 |
+ |
|
| 552 |
+ |
/** |
| 553 |
+ |
* Test to see if the next token is an integer or not. If not, |
| 554 |
+ |
* we've got data on the integrable object itself. If there is an |
| 555 |
+ |
* integer, we're parsing data for a site on a rigid body. |
| 556 |
+ |
*/ |
| 557 |
+ |
|
| 558 |
+ |
std::string indexTest = tokenizer.peekNextToken(); |
| 559 |
+ |
std::istringstream i(indexTest); |
| 560 |
+ |
int siteIndex; |
| 561 |
+ |
if (i >> siteIndex) { |
| 562 |
+ |
// chew up this token and parse as an int: |
| 563 |
+ |
siteIndex = tokenizer.nextTokenAsInt(); |
| 564 |
+ |
RigidBody* rb = static_cast<RigidBody*>(integrableObject); |
| 565 |
+ |
sd = rb->getAtoms()[siteIndex]; |
| 566 |
+ |
} |
| 567 |
+ |
|
| 568 |
+ |
/** |
| 569 |
+ |
* The next token contains information on what follows. |
| 570 |
+ |
*/ |
| 571 |
+ |
std::string type = tokenizer.nextToken(); |
| 572 |
+ |
int size = type.size(); |
| 573 |
+ |
|
| 574 |
+ |
for(int i = 0; i < size; ++i) { |
| 575 |
+ |
switch(type[i]) { |
| 576 |
+ |
|
| 577 |
+ |
case 'u' : { |
| 578 |
+ |
|
| 579 |
+ |
RealType particlePot; |
| 580 |
+ |
particlePot = tokenizer.nextTokenAsDouble(); |
| 581 |
+ |
sd->setParticlePot(particlePot); |
| 582 |
+ |
break; |
| 583 |
+ |
} |
| 584 |
+ |
case 'c' : { |
| 585 |
+ |
|
| 586 |
+ |
RealType flucQPos; |
| 587 |
+ |
flucQPos = tokenizer.nextTokenAsDouble(); |
| 588 |
+ |
sd->setFlucQPos(flucQPos); |
| 589 |
+ |
break; |
| 590 |
+ |
} |
| 591 |
+ |
case 'w' : { |
| 592 |
+ |
|
| 593 |
+ |
RealType flucQVel; |
| 594 |
+ |
flucQVel = tokenizer.nextTokenAsDouble(); |
| 595 |
+ |
sd->setFlucQVel(flucQVel); |
| 596 |
+ |
break; |
| 597 |
+ |
} |
| 598 |
+ |
case 'g' : { |
| 599 |
+ |
|
| 600 |
+ |
RealType flucQFrc; |
| 601 |
+ |
flucQFrc = tokenizer.nextTokenAsDouble(); |
| 602 |
+ |
sd->setFlucQFrc(flucQFrc); |
| 603 |
+ |
break; |
| 604 |
+ |
} |
| 605 |
+ |
case 'e' : { |
| 606 |
+ |
|
| 607 |
+ |
Vector3d eField; |
| 608 |
+ |
eField[0] = tokenizer.nextTokenAsDouble(); |
| 609 |
+ |
eField[1] = tokenizer.nextTokenAsDouble(); |
| 610 |
+ |
eField[2] = tokenizer.nextTokenAsDouble(); |
| 611 |
+ |
sd->setElectricField(eField); |
| 612 |
+ |
break; |
| 613 |
+ |
} |
| 614 |
+ |
default: { |
| 615 |
+ |
sprintf(painCave.errMsg, |
| 616 |
+ |
"DumpReader Error: %s is an unrecognized type\n", type.c_str()); |
| 617 |
+ |
painCave.isFatal = 1; |
| 618 |
+ |
simError(); |
| 619 |
+ |
break; |
| 620 |
+ |
} |
| 621 |
+ |
} |
| 622 |
+ |
} |
| 623 |
+ |
} |
| 624 |
+ |
|
| 625 |
+ |
|
| 626 |
+ |
void DumpReader::readStuntDoubles(std::istream& inputStream) { |
| 627 |
+ |
|
| 628 |
|
inputStream.getline(buffer, bufferSize); |
| 629 |
|
std::string line(buffer); |
| 630 |
|
|
| 647 |
|
|
| 648 |
|
} |
| 649 |
|
|
| 650 |
+ |
void DumpReader::readSiteData(std::istream& inputStream) { |
| 651 |
+ |
|
| 652 |
+ |
inputStream.getline(buffer, bufferSize); |
| 653 |
+ |
std::string line(buffer); |
| 654 |
+ |
|
| 655 |
+ |
if (line.find("<SiteData>") == std::string::npos) { |
| 656 |
+ |
// site data isn't required for a simulation, so skip |
| 657 |
+ |
return; |
| 658 |
+ |
} |
| 659 |
+ |
|
| 660 |
+ |
while(inputStream.getline(buffer, bufferSize)) { |
| 661 |
+ |
line = buffer; |
| 662 |
+ |
|
| 663 |
+ |
if(line.find("</SiteData>") != std::string::npos) { |
| 664 |
+ |
break; |
| 665 |
+ |
} |
| 666 |
+ |
|
| 667 |
+ |
parseSiteLine(line); |
| 668 |
+ |
} |
| 669 |
+ |
|
| 670 |
+ |
} |
| 671 |
+ |
|
| 672 |
|
void DumpReader::readFrameProperties(std::istream& inputStream) { |
| 673 |
|
|
| 674 |
|
Snapshot* s = info_->getSnapshotManager()->getCurrentSnapshot(); |