| 6246 | } |
| 6247 | |
| 6248 | int |
| 6249 | nodeDisp(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) |
| 6250 | { |
| 6251 | // make sure at least one other argument to contain type of system |
| 6252 | if (argc < 2) { |
| 6253 | opserr << "WARNING want - nodeDisp nodeTag? <dof?>\n"; |
| 6254 | return TCL_ERROR; |
| 6255 | } |
| 6256 | |
| 6257 | int tag; |
| 6258 | int dof = -1; |
| 6259 | |
| 6260 | if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) { |
| 6261 | opserr << "WARNING nodeDisp nodeTag? dof? - could not read nodeTag? \n"; |
| 6262 | return TCL_ERROR; |
| 6263 | } |
| 6264 | |
| 6265 | if (argc > 2) { |
| 6266 | if (Tcl_GetInt(interp, argv[2], &dof) != TCL_OK) { |
| 6267 | opserr << "WARNING nodeDisp nodeTag? dof? - could not read dof? \n"; |
| 6268 | return TCL_ERROR; |
| 6269 | } |
| 6270 | } |
| 6271 | |
| 6272 | dof--; |
| 6273 | |
| 6274 | const Vector *nodalResponse = theDomain.getNodeResponse(tag, Disp); |
| 6275 | |
| 6276 | if (nodalResponse == 0) |
| 6277 | return TCL_ERROR; |
| 6278 | |
| 6279 | int size = nodalResponse->Size(); |
| 6280 | |
| 6281 | if (dof >= 0) { |
| 6282 | |
| 6283 | if (dof >= size) { |
| 6284 | opserr << "WARNING nodeDisp nodeTag? dof? - dofTag? too large\n"; |
| 6285 | return TCL_ERROR; |
| 6286 | } |
| 6287 | |
| 6288 | double value = (*nodalResponse)(dof); |
| 6289 | |
| 6290 | // now we copy the value to the tcl string that is returned |
| 6291 | |
| 6292 | char buffer [40]; |
| 6293 | sprintf(buffer,"%35.20f", value); |
| 6294 | Tcl_SetResult(interp, buffer, TCL_VOLATILE); |
| 6295 | // sprintf(interp->result,"%35.20f ",value); |
| 6296 | } else { |
| 6297 | char buffer [40]; |
| 6298 | for (int i=0; i<size; i++) { |
| 6299 | sprintf(buffer,"%35.20f",(*nodalResponse)(i)); |
| 6300 | Tcl_AppendResult(interp, buffer, NULL); |
| 6301 | } |
| 6302 | } |
| 6303 | |
| 6304 | return TCL_OK; |
| 6305 | } |