printNode(): function to print out the nodal information contained in line print node input: nodeArg: integer equal to arg count to node plus 1 output: output stream to which the results are sent
| 568 | // output: output stream to which the results are sent |
| 569 | // |
| 570 | int printNode(OPS_Stream &output) |
| 571 | { |
| 572 | int flag = 0; // default flag sent to a nodes Print() method |
| 573 | int nodeArg = 0; |
| 574 | int argc = OPS_GetNumRemainingInputArgs(); |
| 575 | |
| 576 | Domain* theDomain = OPS_GetDomain(); |
| 577 | if (theDomain == 0) return -1; |
| 578 | |
| 579 | // if just 'print <filename> node' print all the nodes - no flag |
| 580 | if (argc == 0) { |
| 581 | NodeIter &theNodes = theDomain->getNodes(); |
| 582 | Node *theNode; |
| 583 | while ((theNode = theNodes()) != 0) { |
| 584 | theNode->Print(output); |
| 585 | } |
| 586 | return 0; |
| 587 | } |
| 588 | |
| 589 | // if 'print <filename> node flag int <int int ..>' get the flag |
| 590 | const char* flagArg = OPS_GetString(); |
| 591 | if ((strcmp(flagArg, "flag") == 0) || (strcmp(flagArg, "-flag") == 0)) { |
| 592 | // get the specified flag |
| 593 | if (argc < 2) { |
| 594 | opserr << "WARNING print <filename> node <flag int> no int specified \n"; |
| 595 | return -1; |
| 596 | } |
| 597 | int numdata = 1; |
| 598 | if (OPS_GetIntInput(&numdata, &flag) < 0) { |
| 599 | opserr << "WARNING print node failed to get integer flag: \n"; |
| 600 | return -1; |
| 601 | } |
| 602 | nodeArg += 2; |
| 603 | } |
| 604 | else { |
| 605 | OPS_ResetCurrentInputArg(2); |
| 606 | } |
| 607 | |
| 608 | // now print the nodes with the specified flag, 0 by default |
| 609 | |
| 610 | // if 'print <filename> node flag' |
| 611 | // print out all the nodes in the domain with flag |
| 612 | if (argc == nodeArg) { |
| 613 | NodeIter &theNodes = theDomain->getNodes(); |
| 614 | Node *theNode; |
| 615 | while ((theNode = theNodes()) != 0) { |
| 616 | theNode->Print(output, flag); |
| 617 | } |
| 618 | return 0; |
| 619 | } |
| 620 | else { |
| 621 | // otherwise print out the specified nodes i j k .. with flag |
| 622 | int numNodes = argc - nodeArg; |
| 623 | ID *theNodes = new ID(numNodes); |
| 624 | for (int i = 0; i < numNodes; i++) { |
| 625 | int nodeTag; |
| 626 | int numdata = 1; |
| 627 | if (OPS_GetIntInput(&numdata, &nodeTag) < 0) { |
no test coverage detected