| 640 | } |
| 641 | |
| 642 | int printElement(OPS_Stream &output) |
| 643 | { |
| 644 | int flag = 0; // default flag sent to a nodes Print() method |
| 645 | int eleArg = 0; |
| 646 | int argc = OPS_GetNumRemainingInputArgs(); |
| 647 | |
| 648 | Domain* theDomain = OPS_GetDomain(); |
| 649 | if (theDomain == 0) return -1; |
| 650 | |
| 651 | // if just 'print <filename> node' print all the nodes - no flag |
| 652 | if (argc == 0) { |
| 653 | ElementIter &theElements = theDomain->getElements(); |
| 654 | Element *theElement; |
| 655 | while ((theElement = theElements()) != 0) { |
| 656 | theElement->Print(output); |
| 657 | } |
| 658 | return 0; |
| 659 | } |
| 660 | |
| 661 | // if 'print <filename> Element flag int <int int ..>' get the flag |
| 662 | const char* eleflag = OPS_GetString(); |
| 663 | if ((strcmp(eleflag, "flag") == 0) || (strcmp(eleflag, "-flag")) == 0) { |
| 664 | // get the specified flag |
| 665 | if (argc < 2) { |
| 666 | opserr << "WARNING print <filename> ele <flag int> no int specified \n"; |
| 667 | return -1; |
| 668 | } |
| 669 | int numdata = 1; |
| 670 | if (OPS_GetIntInput(&numdata, &flag) < 0) { |
| 671 | opserr << "WARNING print ele failed to get integer flag: \n"; |
| 672 | return -1; |
| 673 | } |
| 674 | eleArg += 2; |
| 675 | } |
| 676 | else { |
| 677 | OPS_ResetCurrentInputArg(2); |
| 678 | } |
| 679 | |
| 680 | // now print the Elements with the specified flag, 0 by default |
| 681 | if (argc == eleArg) { |
| 682 | ElementIter &theElements = theDomain->getElements(); |
| 683 | Element *theElement; |
| 684 | while ((theElement = theElements()) != 0) { |
| 685 | theElement->Print(output, flag); |
| 686 | } |
| 687 | return 0; |
| 688 | } |
| 689 | else { |
| 690 | // otherwise print out the specified nodes i j k .. with flag |
| 691 | int numEle = argc - eleArg; |
| 692 | ID *theEle = new ID(numEle); |
| 693 | for (int i = 0; i < numEle; i++) { |
| 694 | int eleTag; |
| 695 | int numdata = 1; |
| 696 | if (OPS_GetIntInput(&numdata, &eleTag) < 0) { |
| 697 | opserr << "WARNING print ele failed to get integer: " << endln; |
| 698 | delete theEle; |
| 699 | return -1; |
no test coverage detected