ASMT output, MBDyn input and output done.
This commit is contained in:
@@ -32,6 +32,55 @@ void MbD::MBDynItem::parseMBDyn(std::vector<std::string>& lines)
|
||||
assert(false);
|
||||
}
|
||||
|
||||
std::vector<std::string> MbD::MBDynItem::collectArgumentsFor(std::string title, std::string& statement)
|
||||
{
|
||||
size_t previousPos = 0;
|
||||
auto pos = statement.find(":");
|
||||
auto front = statement.substr(previousPos, pos - previousPos);
|
||||
assert(front.find(title) != std::string::npos);
|
||||
auto arguments = std::vector<std::string>();
|
||||
std::string argument;
|
||||
while (true) {
|
||||
previousPos = pos;
|
||||
pos = statement.find(",", pos + 1);
|
||||
if (pos != std::string::npos) {
|
||||
argument = statement.substr(previousPos + 1, pos - previousPos - 1);
|
||||
arguments.push_back(argument);
|
||||
}
|
||||
else {
|
||||
argument = statement.substr(previousPos + 1);
|
||||
arguments.push_back(argument);
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto arguments2 = std::vector<std::string>();
|
||||
while (!arguments.empty()) {
|
||||
argument = arguments[0];
|
||||
auto n = std::count(argument.begin(), argument.end(), '"');
|
||||
if ((n % 2) == 0) {
|
||||
arguments2.push_back(argument);
|
||||
arguments.erase(arguments.begin());
|
||||
}
|
||||
else {
|
||||
//Need to find matching '"'
|
||||
auto it = std::find_if(arguments.begin() + 1, arguments.end(), [](const std::string& s) {
|
||||
auto nn = std::count(s.begin(), s.end(), '"');
|
||||
if ((nn % 2) == 1) return true;
|
||||
});
|
||||
std::vector<std::string> needToCombineArgs(arguments.begin(), it + 1);
|
||||
arguments.erase(arguments.begin(), it + 1);
|
||||
std::stringstream ss;
|
||||
ss << needToCombineArgs[0];
|
||||
needToCombineArgs.erase(needToCombineArgs.begin());
|
||||
for (auto& arg : needToCombineArgs) {
|
||||
ss << ',' << arg;
|
||||
}
|
||||
arguments2.push_back(ss.str());
|
||||
}
|
||||
}
|
||||
return arguments2;
|
||||
}
|
||||
|
||||
std::vector<std::string>::iterator MbD::MBDynItem::findLineWith(std::vector<std::string>& lines, std::vector<std::string>& tokens)
|
||||
{
|
||||
auto it = std::find_if(lines.begin(), lines.end(), [&](const std::string& line) {
|
||||
@@ -56,6 +105,21 @@ std::shared_ptr<std::vector<std::shared_ptr<MBDynNode>>> MbD::MBDynItem::mbdynNo
|
||||
return owner->mbdynNodes();
|
||||
}
|
||||
|
||||
std::shared_ptr<std::vector<std::shared_ptr<MBDynBody>>> MbD::MBDynItem::mbdynBodies()
|
||||
{
|
||||
return owner->mbdynBodies();
|
||||
}
|
||||
|
||||
std::shared_ptr<std::vector<std::shared_ptr<MBDynJoint>>> MbD::MBDynItem::mbdynJoints()
|
||||
{
|
||||
return owner->mbdynJoints();
|
||||
}
|
||||
|
||||
std::shared_ptr<std::vector<std::shared_ptr<MBDynDrive>>> MbD::MBDynItem::mbdynDrives()
|
||||
{
|
||||
return owner->mbdynDrives();
|
||||
}
|
||||
|
||||
std::vector<std::string> MbD::MBDynItem::nodeNames()
|
||||
{
|
||||
return owner->nodeNames();
|
||||
@@ -96,6 +160,18 @@ std::shared_ptr<ASMTAssembly> MbD::MBDynItem::asmtAssembly()
|
||||
return owner->asmtAssembly();
|
||||
}
|
||||
|
||||
std::string MbD::MBDynItem::formulaFromDrive(std::string driveName, std::string varName)
|
||||
{
|
||||
std::vector<std::string> tokens{ "drive:", driveName };
|
||||
auto drives = mbdynDrives();
|
||||
auto it = std::find_if(drives->begin(), drives->end(), [&](auto& drive) {
|
||||
return lineHasTokens(drive->driveName, tokens);
|
||||
});
|
||||
auto formula = (*it)->formula;
|
||||
assert(varName == "Time");
|
||||
return formula;
|
||||
}
|
||||
|
||||
FColDsptr MbD::MBDynItem::readVector3(std::vector<std::string>& args)
|
||||
{
|
||||
auto parser = std::make_shared<SymbolicParser>();
|
||||
@@ -336,3 +412,11 @@ std::string MbD::MBDynItem::readStringOffTop(std::vector<std::string>& args)
|
||||
iss >> str;
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string MbD::MBDynItem::readToken(std::string& line)
|
||||
{
|
||||
auto iss = std::istringstream(line);
|
||||
std::string str;
|
||||
iss >> str;
|
||||
return str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user