00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #include "../include/IPSA/ipsaclasses.h"
00029 #include "../include/IPSA/IpsaSimulator.h"
00030 #include "../include/IPSA/viewer/instructions/ListAllBodies.h"
00031
00032 #include <sstream>
00033 #include <map>
00034
00035
00036 Instruction::tExecResultType ListAllBodies::vExecute(std::vector<std::string>& Instr, std::ostringstream& answer, unsigned int& numberOfReturnValues)
00037 {
00038 #ifdef WIN32
00039 Instr;
00040 #endif // WIN32
00041
00042 std::map<std::string, std::string> bodyMap = Instruction::GetAllNodesOfTypeFromViewer<SoPhysics>(ipsaSimulator);
00043 numberOfReturnValues = bodyMap.size() + 1;
00044
00045 if (bodyMap.empty())
00046 {
00047 if (ipsaSimulator->getVerbosity())
00048 answer << "No bodies found!";
00049 answer << "\r" << std::endl;
00050 }
00051 else
00052 {
00053 if (true == ipsaSimulator->getVerbosity())
00054 answer << "Found bodies\r" << std::endl;
00055 for (std::map<std::string, std::string>::iterator it = bodyMap.begin(); it != bodyMap.end(); it++)
00056 {
00057 if (true == ipsaSimulator->getVerbosity())
00058 answer << " Type <" << it->second << "> ";
00059 answer << it->first << "\r" << std::endl;
00060 }
00061 }
00062
00063 return eOK;
00064 }