MBDyn classes for reading
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
#include "SymbolicParser.h"
|
||||
#include "BasicUserFunction.h"
|
||||
#include "EulerAngles.h"
|
||||
#include "Constant.h"
|
||||
#include "MBDynReferences.h"
|
||||
#include "MBDynReference.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
@@ -39,153 +42,12 @@ void MbD::MBDynStructural::parseMBDyn(std::string line)
|
||||
iss >> type;
|
||||
arguments->erase(arguments->begin());
|
||||
|
||||
readPosition(arguments);
|
||||
readOrientation(arguments);
|
||||
rOfO = readPosition(arguments);
|
||||
aAOf = readOrientation(arguments);
|
||||
readVelocity(arguments);
|
||||
readOmega(arguments);
|
||||
}
|
||||
|
||||
void MbD::MBDynStructural::readPosition(std::istringstream& iss)
|
||||
{
|
||||
auto parser = CREATE<SymbolicParser>::With();
|
||||
parser->variables = mbdynVariables()->variables;
|
||||
rOfO = std::make_shared<FullColumn<double>>(3);
|
||||
std::string str;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
iss >> str;
|
||||
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
|
||||
parser->parseUserFunction(userFunc);
|
||||
auto sym = parser->stack->top();
|
||||
rOfO->at(i) = sym->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
void MbD::MBDynStructural::readOrientation(std::istringstream& iss)
|
||||
{
|
||||
std::string str;
|
||||
iss >> str;
|
||||
auto parser = CREATE<SymbolicParser>::With();
|
||||
parser->variables = mbdynVariables()->variables;
|
||||
auto euler = std::make_shared<EulerAngles<Symsptr>>();
|
||||
if (str.find("eye") != std::string::npos) {
|
||||
aAOf = std::make_shared<FullMatrix<double>>(3, 3);
|
||||
aAOf->identity();
|
||||
return;
|
||||
}
|
||||
else if (str.find("euler") != std::string::npos) {
|
||||
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
iss >> str;
|
||||
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
|
||||
parser->parseUserFunction(userFunc);
|
||||
auto sym = parser->stack->top();
|
||||
euler->at(i) = sym;
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
euler->calc();
|
||||
aAOf = euler->aA;
|
||||
}
|
||||
|
||||
void MbD::MBDynStructural::readVelocity(std::istringstream& iss)
|
||||
{
|
||||
auto parser = CREATE<SymbolicParser>::With();
|
||||
parser->variables = mbdynVariables()->variables;
|
||||
vOfO = std::make_shared<FullColumn<double>>(3);
|
||||
std::string str;
|
||||
auto p = iss.tellg();
|
||||
iss >> str;
|
||||
if (str.find("null") != std::string::npos) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
iss.seekg(p);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
iss >> str;
|
||||
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
|
||||
parser->parseUserFunction(userFunc);
|
||||
auto sym = parser->stack->top();
|
||||
vOfO->at(i) = sym->getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MbD::MBDynStructural::readOmega(std::istringstream& iss)
|
||||
{
|
||||
auto parser = CREATE<SymbolicParser>::With();
|
||||
parser->variables = mbdynVariables()->variables;
|
||||
omeOfO = std::make_shared<FullColumn<double>>(3);
|
||||
std::string str;
|
||||
auto p = iss.tellg();
|
||||
iss >> str;
|
||||
if (str.find("null") != std::string::npos) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
iss.seekg(p);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
iss >> str;
|
||||
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
|
||||
parser->parseUserFunction(userFunc);
|
||||
auto sym = parser->stack->top();
|
||||
omeOfO->at(i) = sym->getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MbD::MBDynStructural::readPosition(std::shared_ptr<std::vector<std::string>>& args)
|
||||
{
|
||||
auto parser = CREATE<SymbolicParser>::With();
|
||||
parser->variables = mbdynVariables()->variables;
|
||||
rOfO = std::make_shared<FullColumn<double>>(3);
|
||||
std::string str;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
str = args->at(0);
|
||||
args->erase(args->begin());
|
||||
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
|
||||
parser->parseUserFunction(userFunc);
|
||||
auto sym = parser->stack->top();
|
||||
rOfO->at(i) = sym->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
void MbD::MBDynStructural::readOrientation(std::shared_ptr<std::vector<std::string>>& args)
|
||||
{
|
||||
auto str = args->at(0);
|
||||
auto parser = CREATE<SymbolicParser>::With();
|
||||
parser->variables = mbdynVariables()->variables;
|
||||
auto euler = std::make_shared<EulerAngles<Symsptr>>();
|
||||
if (str.find("euler") != std::string::npos) {
|
||||
args->erase(args->begin());
|
||||
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
str = args->at(0);
|
||||
args->erase(args->begin());
|
||||
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
|
||||
parser->parseUserFunction(userFunc);
|
||||
auto sym = parser->stack->top();
|
||||
euler->at(i) = sym;
|
||||
}
|
||||
}
|
||||
else if (str.find("eye") != std::string::npos) {
|
||||
args->erase(args->begin());
|
||||
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
euler->calc();
|
||||
aAOf = euler->aA;
|
||||
}
|
||||
|
||||
void MbD::MBDynStructural::readVelocity(std::shared_ptr<std::vector<std::string>>& args)
|
||||
{
|
||||
auto parser = CREATE<SymbolicParser>::With();
|
||||
|
||||
Reference in New Issue
Block a user