| 1531 | } |
| 1532 | |
| 1533 | int OPS_nodeCoord() |
| 1534 | { |
| 1535 | // make sure at least one other argument to contain type of system |
| 1536 | if (OPS_GetNumRemainingInputArgs() < 1) { |
| 1537 | opserr << "WARNING want - nodeCoord nodeTag? <dim?>\n"; |
| 1538 | return -1; |
| 1539 | } |
| 1540 | |
| 1541 | int tag; |
| 1542 | int numdata = 1; |
| 1543 | |
| 1544 | if (OPS_GetIntInput(&numdata, &tag) < 0) { |
| 1545 | opserr << "WARNING nodeCoord nodeTag? dim? - could not read nodeTag? \n"; |
| 1546 | return -1; |
| 1547 | } |
| 1548 | |
| 1549 | int dim = -1; |
| 1550 | |
| 1551 | if (OPS_GetNumRemainingInputArgs() > 0) { |
| 1552 | const char* flag = OPS_GetString(); |
| 1553 | if (strcmp(flag,"X") == 0 || strcmp(flag,"x") == 0) { |
| 1554 | dim = 0; |
| 1555 | } else if (strcmp(flag,"Y") == 0 || strcmp(flag,"y") == 0) { |
| 1556 | dim = 1; |
| 1557 | } else if (strcmp(flag,"Z") == 0 || strcmp(flag,"z") == 0) { |
| 1558 | dim = 2; |
| 1559 | } else { |
| 1560 | OPS_ResetCurrentInputArg(-1); |
| 1561 | if (OPS_GetIntInput(&numdata, &dim) < 0) { |
| 1562 | opserr << "WARNING nodeCoord nodeTag? dim? - could not read dim? \n"; |
| 1563 | return -1; |
| 1564 | } |
| 1565 | dim--; |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | Domain* theDomain = OPS_GetDomain(); |
| 1570 | if (theDomain == 0) return -1; |
| 1571 | Node *theNode = theDomain->getNode(tag); |
| 1572 | |
| 1573 | if (theNode == 0) { |
| 1574 | opserr << "WARNING node "<<tag<<" does not exist\n"; |
| 1575 | return -1; |
| 1576 | } |
| 1577 | |
| 1578 | const Vector &coords = theNode->getCrds(); |
| 1579 | |
| 1580 | int size = coords.Size(); |
| 1581 | if (dim == -1) { |
| 1582 | |
| 1583 | double* data = new double[size]; |
| 1584 | for (int i=0; i<size; i++) { |
| 1585 | data[i] = coords(i); |
| 1586 | } |
| 1587 | if (OPS_SetDoubleOutput(&size, data, false) < 0) { |
| 1588 | opserr << "WARNING failed to set output\n"; |
| 1589 | delete [] data; |
| 1590 | return -1; |
no test coverage detected