ExternalSystem class
This commit is contained in:
@@ -33,259 +33,334 @@ void MbD::ASMTAssembly::runFile(const char* chars)
|
||||
|
||||
void MbD::ASMTAssembly::parseASMT(std::vector<std::string>& lines)
|
||||
{
|
||||
size_t pos = lines[0].find_first_not_of("\t");
|
||||
auto leadingTabs = lines[0].substr(0, pos);
|
||||
while (!lines.empty()) {
|
||||
if (lines[0] == (leadingTabs + "Notes")) {
|
||||
lines.erase(lines.begin());
|
||||
notes = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
readNotes(lines);
|
||||
readName(lines);
|
||||
readPosition3D(lines);
|
||||
readRotationMatrix(lines);
|
||||
readVelocity3D(lines);
|
||||
readOmega3D(lines);
|
||||
readRefPoints(lines);
|
||||
readRefCurves(lines);
|
||||
readRefSurfaces(lines);
|
||||
readParts(lines);
|
||||
readKinematicIJs(lines);
|
||||
readConstraintSets(lines);
|
||||
readForceTorques(lines);
|
||||
readConstantGravity(lines);
|
||||
readSimulationParameters(lines);
|
||||
readAnimationParameters(lines);
|
||||
readTimeSeries(lines);
|
||||
readAssemblySeries(lines);
|
||||
readPartSeriesMany(lines);
|
||||
readJointSeriesMany(lines);
|
||||
readMotionSeriesMany(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readNotes(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\tNotes");
|
||||
lines.erase(lines.begin());
|
||||
notes = readString(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readParts(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\tParts");
|
||||
lines.erase(lines.begin());
|
||||
parts = std::make_shared<std::vector<std::shared_ptr<ASMTPart>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), "\tKinematicIJs");
|
||||
std::vector<std::string> partsLines(lines.begin(), it);
|
||||
while (!partsLines.empty()) {
|
||||
readPart(partsLines);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readPart(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\t\tPart");
|
||||
lines.erase(lines.begin());
|
||||
auto part = CREATE<ASMTPart>::With();
|
||||
part->parseASMT(lines);
|
||||
parts->push_back(part);
|
||||
part->owner = this;
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readKinematicIJs(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\tKinematicIJs");
|
||||
lines.erase(lines.begin());
|
||||
kinematicIJs = std::make_shared<std::vector<std::shared_ptr<ASMTKinematicIJ>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), "\tConstraintSets");
|
||||
std::vector<std::string> kinematicIJsLines(lines.begin(), it);
|
||||
while (!kinematicIJsLines.empty()) {
|
||||
readKinematicIJ(kinematicIJsLines);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readKinematicIJ(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readConstraintSets(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\tConstraintSets");
|
||||
lines.erase(lines.begin());
|
||||
readJoints(lines);
|
||||
readMotions(lines);
|
||||
readGeneralConstraintSets(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readJoints(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\t\tJoints");
|
||||
lines.erase(lines.begin());
|
||||
joints = std::make_shared<std::vector<std::shared_ptr<ASMTJoint>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), "\t\tMotions");
|
||||
std::vector<std::string> jointsLines(lines.begin(), it);
|
||||
std::shared_ptr<ASMTJoint> joint;
|
||||
while (!jointsLines.empty()) {
|
||||
if (jointsLines[0] == "\t\t\tRevoluteJoint") {
|
||||
joint = CREATE<ASMTRevoluteJoint>::With();
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Name")) {
|
||||
lines.erase(lines.begin());
|
||||
name = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
else if (jointsLines[0] == "\t\t\tCylindricalJoint") {
|
||||
joint = CREATE<ASMTCylindricalJoint>::With();
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Position3D")) {
|
||||
lines.erase(lines.begin());
|
||||
std::istringstream iss(lines[0]);
|
||||
position3D = std::make_shared<FullColumn<double>>();
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
position3D->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RotationMatrix")) {
|
||||
lines.erase(lines.begin());
|
||||
rotationMatrix = std::make_shared<FullMatrix<double>>(3, 0);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto& row = rotationMatrix->at(i);
|
||||
std::istringstream iss(lines[0]);
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
row->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
jointsLines.erase(jointsLines.begin());
|
||||
joint->parseASMT(jointsLines);
|
||||
joints->push_back(joint);
|
||||
joint->owner = this;
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readMotions(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\t\tMotions");
|
||||
lines.erase(lines.begin());
|
||||
motions = std::make_shared<std::vector<std::shared_ptr<ASMTMotion>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), "\t\tGeneralConstraintSets");
|
||||
std::vector<std::string> motionsLines(lines.begin(), it);
|
||||
std::shared_ptr<ASMTMotion> motion;
|
||||
while (!motionsLines.empty()) {
|
||||
if (motionsLines[0] == "\t\t\tRotationalMotion") {
|
||||
motion = CREATE<ASMTRotationalMotion>::With();
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Velocity3D")) {
|
||||
lines.erase(lines.begin());
|
||||
std::istringstream iss(lines[0]);
|
||||
velocity3D = std::make_shared<FullColumn<double>>();
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
velocity3D->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
else if (motionsLines[0] == "\t\t\tTranslationalMotion") {
|
||||
motion = CREATE<ASMTTranslationalMotion>::With();
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Omega3D")) {
|
||||
lines.erase(lines.begin());
|
||||
std::istringstream iss(lines[0]);
|
||||
omega3D = std::make_shared<FullColumn<double>>();
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
omega3D->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RefPoints")) {
|
||||
lines.erase(lines.begin());
|
||||
refPoints = std::make_shared<std::vector<std::shared_ptr<ASMTRefPoint>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "RefCurves"));
|
||||
std::vector<std::string> refPointsLines(lines.begin(), it);
|
||||
while (!refPointsLines.empty()) {
|
||||
if (refPointsLines[0] == (leadingTabs + "\tRefPoint")) {
|
||||
refPointsLines.erase(refPointsLines.begin());
|
||||
auto refPoint = CREATE<ASMTRefPoint>::With();
|
||||
refPoint->parseASMT(refPointsLines);
|
||||
refPoints->push_back(refPoint);
|
||||
refPoint->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RefCurves")) {
|
||||
lines.erase(lines.begin());
|
||||
refCurves = std::make_shared<std::vector<std::shared_ptr<ASMTRefCurve>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "RefSurfaces"));
|
||||
std::vector<std::string> refCurvesLines(lines.begin(), it);
|
||||
while (!refCurvesLines.empty()) {
|
||||
if (refCurvesLines[0] == (leadingTabs + "\tRefCurve")) {
|
||||
refCurvesLines.erase(refCurvesLines.begin());
|
||||
auto refCurve = CREATE<ASMTRefCurve>::With();
|
||||
refCurve->parseASMT(refCurvesLines);
|
||||
refCurves->push_back(refCurve);
|
||||
refCurve->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RefSurfaces")) {
|
||||
lines.erase(lines.begin());
|
||||
refSurfaces = std::make_shared<std::vector<std::shared_ptr<ASMTRefSurface>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "Parts"));
|
||||
std::vector<std::string> refSurfacesLines(lines.begin(), it);
|
||||
while (!refSurfacesLines.empty()) {
|
||||
if (refSurfacesLines[0] == (leadingTabs + "\tRefSurface")) {
|
||||
refSurfacesLines.erase(refSurfacesLines.begin());
|
||||
auto refSurface = CREATE<ASMTRefSurface>::With();
|
||||
refSurface->parseASMT(refSurfacesLines);
|
||||
refSurfaces->push_back(refSurface);
|
||||
refSurface->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Parts")) {
|
||||
lines.erase(lines.begin());
|
||||
parts = std::make_shared<std::vector<std::shared_ptr<ASMTPart>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "KinematicIJs"));
|
||||
std::vector<std::string> partsLines(lines.begin(), it);
|
||||
while (!partsLines.empty()) {
|
||||
if (partsLines[0] == (leadingTabs + "\tPart")) {
|
||||
partsLines.erase(partsLines.begin());
|
||||
auto part = CREATE<ASMTPart>::With();
|
||||
part->parseASMT(partsLines);
|
||||
parts->push_back(part);
|
||||
part->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "KinematicIJs")) {
|
||||
lines.erase(lines.begin());
|
||||
kinematicIJs = std::make_shared<std::vector<std::shared_ptr<ASMTKinematicIJ>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "ConstraintSets"));
|
||||
std::vector<std::string> kinematicIJsLines(lines.begin(), it);
|
||||
while (!kinematicIJsLines.empty()) {
|
||||
if (kinematicIJsLines[0] == (leadingTabs + "\tKinematicIJ")) {
|
||||
kinematicIJsLines.erase(kinematicIJsLines.begin());
|
||||
auto kinematicIJ = CREATE<ASMTKinematicIJ>::With();
|
||||
kinematicIJ->parseASMT(kinematicIJsLines);
|
||||
kinematicIJs->push_back(kinematicIJ);
|
||||
kinematicIJ->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "ConstraintSets")) {
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "\tJoints"));
|
||||
lines.erase(lines.begin());
|
||||
joints = std::make_shared<std::vector<std::shared_ptr<ASMTJoint>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "\tMotions"));
|
||||
std::vector<std::string> jointsLines(lines.begin(), it);
|
||||
while (!jointsLines.empty()) {
|
||||
if (jointsLines[0] == (leadingTabs + "\t\tRevoluteJoint")) {
|
||||
jointsLines.erase(jointsLines.begin());
|
||||
auto joint = CREATE<ASMTRevoluteJoint>::With();
|
||||
joint->parseASMT(jointsLines);
|
||||
joints->push_back(joint);
|
||||
joint->owner = this;
|
||||
}
|
||||
else if (jointsLines[0] == (leadingTabs + "\t\tCylindricalJoint")) {
|
||||
jointsLines.erase(jointsLines.begin());
|
||||
auto joint = CREATE<ASMTCylindricalJoint>::With();
|
||||
joint->parseASMT(jointsLines);
|
||||
joints->push_back(joint);
|
||||
joint->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
assert(lines[0] == (leadingTabs + "\tMotions"));
|
||||
lines.erase(lines.begin());
|
||||
motions = std::make_shared<std::vector<std::shared_ptr<ASMTMotion>>>();
|
||||
it = std::find(lines.begin(), lines.end(), (leadingTabs + "\tGeneralConstraintSets"));
|
||||
std::vector<std::string> motionsLines(lines.begin(), it);
|
||||
while (!motionsLines.empty()) {
|
||||
if (motionsLines[0] == (leadingTabs + "\t\tRotationalMotion")) {
|
||||
motionsLines.erase(motionsLines.begin());
|
||||
auto motion = CREATE<ASMTRotationalMotion>::With();
|
||||
motion->parseASMT(motionsLines);
|
||||
motions->push_back(motion);
|
||||
motion->owner = this;
|
||||
}
|
||||
else if (motionsLines[0] == (leadingTabs + "\t\tTranslationalMotion")) {
|
||||
motionsLines.erase(motionsLines.begin());
|
||||
auto motion = CREATE<ASMTTranslationalMotion>::With();
|
||||
motion->parseASMT(motionsLines);
|
||||
motions->push_back(motion);
|
||||
motion->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
assert(lines[0] == (leadingTabs + "\tGeneralConstraintSets"));
|
||||
lines.erase(lines.begin());
|
||||
constraintSets = std::make_shared<std::vector<std::shared_ptr<ASMTConstraintSet>>>();
|
||||
it = std::find(lines.begin(), lines.end(), (leadingTabs + "ForceTorques"));
|
||||
std::vector<std::string> generalConstraintSetsLines(lines.begin(), it);
|
||||
while (!generalConstraintSetsLines.empty()) {
|
||||
assert(false);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "ForceTorques")) {
|
||||
lines.erase(lines.begin());
|
||||
forceTorques = std::make_shared<std::vector<std::shared_ptr<ASMTForceTorque>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "ConstantGravity"));
|
||||
std::vector<std::string> forceTorquesLines(lines.begin(), it);
|
||||
while (!forceTorquesLines.empty()) {
|
||||
if (forceTorquesLines[0] == (leadingTabs + "\tForceTorque")) {
|
||||
forceTorquesLines.erase(forceTorquesLines.begin());
|
||||
auto forceTorque = CREATE<ASMTForceTorque>::With();
|
||||
forceTorque->parseASMT(forceTorquesLines);
|
||||
forceTorques->push_back(forceTorque);
|
||||
forceTorque->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "ConstantGravity")) {
|
||||
lines.erase(lines.begin());
|
||||
constantGravity = CREATE<ASMTConstantGravity>::With();
|
||||
constantGravity->parseASMT(lines);
|
||||
constantGravity->owner = this;
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "SimulationParameters")) {
|
||||
lines.erase(lines.begin());
|
||||
simulationParameters = CREATE<ASMTSimulationParameters>::With();
|
||||
simulationParameters->parseASMT(lines);
|
||||
simulationParameters->owner = this;
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "AnimationParameters")) {
|
||||
lines.erase(lines.begin());
|
||||
animationParameters = CREATE<ASMTAnimationParameters>::With();
|
||||
animationParameters->parseASMT(lines);
|
||||
animationParameters->owner = this;
|
||||
motionsLines.erase(motionsLines.begin());
|
||||
motion->parseASMT(motionsLines);
|
||||
motions->push_back(motion);
|
||||
motion->owner = this;
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readGeneralConstraintSets(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\t\tGeneralConstraintSets");
|
||||
lines.erase(lines.begin());
|
||||
constraintSets = std::make_shared<std::vector<std::shared_ptr<ASMTConstraintSet>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), "\tForceTorques");
|
||||
std::vector<std::string> generalConstraintSetsLines(lines.begin(), it);
|
||||
while (!generalConstraintSetsLines.empty()) {
|
||||
assert(false);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readForceTorques(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\tForceTorques");
|
||||
lines.erase(lines.begin());
|
||||
forceTorques = std::make_shared<std::vector<std::shared_ptr<ASMTForceTorque>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), "\tConstantGravity");
|
||||
std::vector<std::string> forceTorquesLines(lines.begin(), it);
|
||||
while (!forceTorquesLines.empty()) {
|
||||
if (forceTorquesLines[0] == "\t\tForceTorque") {
|
||||
forceTorquesLines.erase(forceTorquesLines.begin());
|
||||
auto forceTorque = CREATE<ASMTForceTorque>::With();
|
||||
forceTorque->parseASMT(forceTorquesLines);
|
||||
forceTorques->push_back(forceTorque);
|
||||
forceTorque->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readConstantGravity(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\tConstantGravity");
|
||||
lines.erase(lines.begin());
|
||||
constantGravity = CREATE<ASMTConstantGravity>::With();
|
||||
constantGravity->parseASMT(lines);
|
||||
constantGravity->owner = this;
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readSimulationParameters(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\tSimulationParameters");
|
||||
lines.erase(lines.begin());
|
||||
simulationParameters = CREATE<ASMTSimulationParameters>::With();
|
||||
simulationParameters->parseASMT(lines);
|
||||
simulationParameters->owner = this;
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readAnimationParameters(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "\tAnimationParameters");
|
||||
lines.erase(lines.begin());
|
||||
animationParameters = CREATE<ASMTAnimationParameters>::With();
|
||||
animationParameters->parseASMT(lines);
|
||||
animationParameters->owner = this;
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readTimeSeries(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0] == "TimeSeries");
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0].find("Number\tInput") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
readTimes(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readTimes(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
std::string substr = "Time\tInput";
|
||||
auto pos = str.find(substr);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + substr.length());
|
||||
times = readRowOfDoubles(str);
|
||||
times->insert(times->begin(), times->at(0)); //The first element is the input state.
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readPartSeriesMany(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("PartSeries") != std::string::npos);
|
||||
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
|
||||
return s.find("JointSeries") != std::string::npos;
|
||||
});
|
||||
std::vector<std::string> partSeriesLines(lines.begin(), it);
|
||||
while (!partSeriesLines.empty()) {
|
||||
readPartSeries(partSeriesLines);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readJointSeriesMany(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("JointSeries") != std::string::npos);
|
||||
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
|
||||
return s.find("MotionSeries") != std::string::npos;
|
||||
});
|
||||
std::vector<std::string> jointSeriesLines(lines.begin(), it);
|
||||
while (!jointSeriesLines.empty()) {
|
||||
readJointSeries(jointSeriesLines);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readAssemblySeries(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
std::string substr = "AssemblySeries";
|
||||
auto pos = str.find(substr);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + substr.length());
|
||||
auto seriesName = readString(str);
|
||||
assert(fullName("") == seriesName);
|
||||
lines.erase(lines.begin());
|
||||
//xs, ys, zs, bryxs, bryys, bryzs
|
||||
readXs(lines);
|
||||
readYs(lines);
|
||||
readZs(lines);
|
||||
readBryantxs(lines);
|
||||
readBryantys(lines);
|
||||
readBryantzs(lines);
|
||||
readVXs(lines);
|
||||
readVYs(lines);
|
||||
readVZs(lines);
|
||||
readOmegaXs(lines);
|
||||
readOmegaYs(lines);
|
||||
readOmegaZs(lines);
|
||||
readAXs(lines);
|
||||
readAYs(lines);
|
||||
readAZs(lines);
|
||||
readAlphaXs(lines);
|
||||
readAlphaYs(lines);
|
||||
readAlphaZs(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readPartSeries(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
std::string substr = "PartSeries";
|
||||
auto pos = str.find(substr);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + substr.length());
|
||||
auto seriesName = readString(str);
|
||||
auto it = std::find_if(parts->begin(), parts->end(), [&](const std::shared_ptr<ASMTPart>& prt) {
|
||||
return prt->fullName("") == seriesName;
|
||||
});
|
||||
auto part = *it;
|
||||
part->readPartSeries(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readJointSeries(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
std::string substr = "JointSeries";
|
||||
auto pos = str.find(substr);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + substr.length());
|
||||
auto seriesName = readString(str);
|
||||
auto it = std::find_if(joints->begin(), joints->end(), [&](const std::shared_ptr<ASMTJoint>& jt) {
|
||||
return jt->fullName("") == seriesName;
|
||||
});
|
||||
auto joint = *it;
|
||||
joint->readJointSeries(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readMotionSeriesMany(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("MotionSeries") != std::string::npos);
|
||||
while (!lines.empty()) {
|
||||
readMotionSeries(lines);
|
||||
}
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readMotionSeries(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
std::string substr = "MotionSeries";
|
||||
auto pos = str.find(substr);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + substr.length());
|
||||
auto seriesName = readString(str);
|
||||
auto it = std::find_if(motions->begin(), motions->end(), [&](const std::shared_ptr<ASMTMotion>& jt) {
|
||||
return jt->fullName("") == seriesName;
|
||||
});
|
||||
auto motion = *it;
|
||||
motion->readMotionSeries(lines);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <fstream>
|
||||
|
||||
#include "ASMTItem.h"
|
||||
#include "ASMTSpatialContainer.h"
|
||||
#include "ASMTRefPoint.h"
|
||||
#include "ASMTRefCurve.h"
|
||||
#include "ASMTRefSurface.h"
|
||||
@@ -18,19 +18,36 @@
|
||||
#include "ASMTMotion.h"
|
||||
|
||||
namespace MbD {
|
||||
class ASMTAssembly : public ASMTItem
|
||||
class ASMTAssembly : public ASMTSpatialContainer
|
||||
{
|
||||
//
|
||||
public:
|
||||
static void runFile(const char* chars);
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
void readNotes(std::vector<std::string>& lines);
|
||||
void readParts(std::vector<std::string>& lines);
|
||||
void readPart(std::vector<std::string>& lines);
|
||||
void readKinematicIJs(std::vector<std::string>& lines);
|
||||
void readKinematicIJ(std::vector<std::string>& lines);
|
||||
void readConstraintSets(std::vector<std::string>& lines);
|
||||
void readJoints(std::vector<std::string>& lines);
|
||||
void readMotions(std::vector<std::string>& lines);
|
||||
void readGeneralConstraintSets(std::vector<std::string>& lines);
|
||||
void readForceTorques(std::vector<std::string>& lines);
|
||||
void readConstantGravity(std::vector<std::string>& lines);
|
||||
void readSimulationParameters(std::vector<std::string>& lines);
|
||||
void readAnimationParameters(std::vector<std::string>& lines);
|
||||
void readTimeSeries(std::vector<std::string>& lines);
|
||||
void readTimes(std::vector<std::string>& lines);
|
||||
void readAssemblySeries(std::vector<std::string>& lines);
|
||||
void readPartSeriesMany(std::vector<std::string>& lines);
|
||||
void readPartSeries(std::vector<std::string>& lines);
|
||||
void readJointSeriesMany(std::vector<std::string>& lines);
|
||||
void readJointSeries(std::vector<std::string>& lines);
|
||||
void readMotionSeriesMany(std::vector<std::string>& lines);
|
||||
void readMotionSeries(std::vector<std::string>& lines);
|
||||
|
||||
std::string notes, name;
|
||||
FColDsptr position3D, velocity3D, omega3D;
|
||||
FMatDsptr rotationMatrix;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefPoint>>> refPoints;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefCurve>>> refCurves;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefSurface>>> refSurfaces;
|
||||
std::string notes;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTPart>>> parts;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTKinematicIJ>>> kinematicIJs;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTConstraintSet>>> constraintSets;
|
||||
@@ -40,6 +57,7 @@ namespace MbD {
|
||||
std::shared_ptr<ASMTConstantGravity> constantGravity;
|
||||
std::shared_ptr<ASMTSimulationParameters> simulationParameters;
|
||||
std::shared_ptr<ASMTAnimationParameters> animationParameters;
|
||||
std::shared_ptr<std::vector<double>> times;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,3 +1,61 @@
|
||||
#include "ASMTConstraintSet.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
void MbD::ASMTConstraintSet::readMarkerI(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("MarkerI") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
markerI = readString(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTConstraintSet::readMarkerJ(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("MarkerJ") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
markerJ = readString(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTConstraintSet::readFXonIs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "FXonI", fxs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTConstraintSet::readFYonIs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "FYonI", fys);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTConstraintSet::readFZonIs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "FZonI", fzs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTConstraintSet::readTXonIs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "TXonI", txs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTConstraintSet::readTYonIs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "TYonI", tys);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTConstraintSet::readTZonIs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "TZonI", tzs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,17 @@ namespace MbD {
|
||||
{
|
||||
//
|
||||
public:
|
||||
void readMarkerI(std::vector<std::string>& lines);
|
||||
void readMarkerJ(std::vector<std::string>& lines);
|
||||
void readFXonIs(std::vector<std::string>& lines);
|
||||
void readFYonIs(std::vector<std::string>& lines);
|
||||
void readFZonIs(std::vector<std::string>& lines);
|
||||
void readTXonIs(std::vector<std::string>& lines);
|
||||
void readTYonIs(std::vector<std::string>& lines);
|
||||
void readTZonIs(std::vector<std::string>& lines);
|
||||
|
||||
std::string markerI, markerJ;
|
||||
FRowDsptr fxs, fys, fzs, txs, tys, tzs;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ void MbD::ASMTItem::parseASMT(std::vector<std::string>& lines)
|
||||
assert(false);
|
||||
}
|
||||
|
||||
FRowDsptr MbD::ASMTItem::readRowOfDoubles(std::string line)
|
||||
FRowDsptr MbD::ASMTItem::readRowOfDoubles(std::string& line)
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
auto readRowOfDoubles = std::make_shared<FullRow<double>>();
|
||||
@@ -23,7 +23,7 @@ FRowDsptr MbD::ASMTItem::readRowOfDoubles(std::string line)
|
||||
return readRowOfDoubles;
|
||||
}
|
||||
|
||||
FColDsptr MbD::ASMTItem::readColumnOfDoubles(std::string line)
|
||||
FColDsptr MbD::ASMTItem::readColumnOfDoubles(std::string& line)
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
auto readColumnOfDoubles = std::make_shared<FullColumn<double>>();
|
||||
@@ -34,7 +34,7 @@ FColDsptr MbD::ASMTItem::readColumnOfDoubles(std::string line)
|
||||
return readColumnOfDoubles;
|
||||
}
|
||||
|
||||
double MbD::ASMTItem::readDouble(std::string line)
|
||||
double MbD::ASMTItem::readDouble(std::string& line)
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
double d;
|
||||
@@ -42,7 +42,7 @@ double MbD::ASMTItem::readDouble(std::string line)
|
||||
return d;
|
||||
}
|
||||
|
||||
int MbD::ASMTItem::readInt(std::string line)
|
||||
int MbD::ASMTItem::readInt(std::string& line)
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
int i;
|
||||
@@ -50,7 +50,7 @@ int MbD::ASMTItem::readInt(std::string line)
|
||||
return i;
|
||||
}
|
||||
|
||||
bool MbD::ASMTItem::readBool(std::string line)
|
||||
bool MbD::ASMTItem::readBool(std::string& line)
|
||||
{
|
||||
if (line.find("true") != std::string::npos)
|
||||
{
|
||||
@@ -64,3 +64,37 @@ bool MbD::ASMTItem::readBool(std::string line)
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
std::string MbD::ASMTItem::readString(std::string& line)
|
||||
{
|
||||
std::string str = line;
|
||||
str.erase(str.begin(), std::find_if(str.begin(), str.end(), [](unsigned char ch) { return !std::isspace(ch); }));
|
||||
return str;
|
||||
}
|
||||
|
||||
void MbD::ASMTItem::readName(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("Name") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
name = readString(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
std::string MbD::ASMTItem::fullName(std::string partialName)
|
||||
{
|
||||
std::string longerName = "/" + name + partialName;
|
||||
if (owner == nullptr) {
|
||||
return longerName;
|
||||
}
|
||||
else {
|
||||
return owner->fullName(longerName);
|
||||
}
|
||||
}
|
||||
|
||||
void MbD::ASMTItem::readDoublesInto(std::string& str, std::string label, FRowDsptr& row)
|
||||
{
|
||||
auto pos = str.find(label);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + label.length());
|
||||
row = readRowOfDoubles(str);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,17 @@ namespace MbD {
|
||||
public:
|
||||
virtual void initialize();
|
||||
virtual void parseASMT(std::vector<std::string>& lines);
|
||||
FRowDsptr readRowOfDoubles(std::string line);
|
||||
FColDsptr readColumnOfDoubles(std::string line);
|
||||
double readDouble(std::string line);
|
||||
int readInt(std::string line);
|
||||
bool readBool(std::string line);
|
||||
FRowDsptr readRowOfDoubles(std::string& line);
|
||||
FColDsptr readColumnOfDoubles(std::string& line);
|
||||
double readDouble(std::string& line);
|
||||
int readInt(std::string& line);
|
||||
bool readBool(std::string& line);
|
||||
std::string readString(std::string& line);
|
||||
void readName(std::vector<std::string>& lines);
|
||||
std::string fullName(std::string partialName);
|
||||
void readDoublesInto(std::string& str, std::string label, FRowDsptr& row);
|
||||
|
||||
std::string name;
|
||||
ASMTItem* owner;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,18 +4,25 @@ using namespace MbD;
|
||||
|
||||
void MbD::ASMTJoint::parseASMT(std::vector<std::string>& lines)
|
||||
{
|
||||
size_t pos = lines[0].find_first_not_of("\t");
|
||||
auto leadingTabs = lines[0].substr(0, pos);
|
||||
assert(lines[0] == (leadingTabs + "Name"));
|
||||
lines.erase(lines.begin());
|
||||
name = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "MarkerI"));
|
||||
lines.erase(lines.begin());
|
||||
markerI = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "MarkerJ"));
|
||||
lines.erase(lines.begin());
|
||||
markerJ = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
readName(lines);
|
||||
readMarkerI(lines);
|
||||
readMarkerJ(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTJoint::readJointSeries(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
std::string substr = "JointSeries";
|
||||
auto pos = str.find(substr);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + substr.length());
|
||||
auto seriesName = readString(str);
|
||||
assert(fullName("") == seriesName);
|
||||
lines.erase(lines.begin());
|
||||
readFXonIs(lines);
|
||||
readFYonIs(lines);
|
||||
readFZonIs(lines);
|
||||
readTXonIs(lines);
|
||||
readTYonIs(lines);
|
||||
readTZonIs(lines);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "ASMTConstraintSet.h"
|
||||
#include "ForceTorqueData.h"
|
||||
|
||||
namespace MbD {
|
||||
class ASMTJoint : public ASMTConstraintSet
|
||||
@@ -8,8 +9,9 @@ namespace MbD {
|
||||
//
|
||||
public:
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
void readJointSeries(std::vector<std::string>& lines);
|
||||
|
||||
std::string name, markerI, markerJ;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ForceTorqueData>>> jointSeries;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,40 +4,7 @@ using namespace MbD;
|
||||
|
||||
void MbD::ASMTMarker::parseASMT(std::vector<std::string>& lines)
|
||||
{
|
||||
size_t pos = lines[0].find_first_not_of("\t");
|
||||
auto leadingTabs = lines[0].substr(0, pos);
|
||||
while (!lines.empty()) {
|
||||
if (lines[0] == (leadingTabs + "Name")) {
|
||||
lines.erase(lines.begin());
|
||||
name = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Position3D")) {
|
||||
lines.erase(lines.begin());
|
||||
std::istringstream iss(lines[0]);
|
||||
position3D = std::make_shared<FullColumn<double>>();
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
position3D->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RotationMatrix")) {
|
||||
lines.erase(lines.begin());
|
||||
rotationMatrix = std::make_shared<FullMatrix<double>>(3, 0);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto& row = rotationMatrix->at(i);
|
||||
std::istringstream iss(lines[0]);
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
row->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
readName(lines);
|
||||
readPosition3D(lines);
|
||||
readRotationMatrix(lines);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "ASMTItem.h"
|
||||
#include "ASMTSpatialItem.h"
|
||||
#include "FullColumn.h"
|
||||
#include "FullMatrix.h"
|
||||
|
||||
namespace MbD {
|
||||
class ASMTMarker : public ASMTItem
|
||||
class ASMTMarker : public ASMTSpatialItem
|
||||
{
|
||||
//
|
||||
public:
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
|
||||
std::string name;
|
||||
FColDsptr position3D;
|
||||
FMatDsptr rotationMatrix;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
#include "ASMTMotion.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
void MbD::ASMTMotion::readMotionSeries(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
std::string substr = "MotionSeries";
|
||||
auto pos = str.find(substr);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + substr.length());
|
||||
auto seriesName = readString(str);
|
||||
assert(fullName("") == seriesName);
|
||||
lines.erase(lines.begin());
|
||||
readFXonIs(lines);
|
||||
readFYonIs(lines);
|
||||
readFZonIs(lines);
|
||||
readTXonIs(lines);
|
||||
readTYonIs(lines);
|
||||
readTZonIs(lines);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "ASMTConstraintSet.h"
|
||||
#include "ForceTorqueData.h"
|
||||
|
||||
namespace MbD {
|
||||
class ASMTMotion : public ASMTConstraintSet
|
||||
{
|
||||
//
|
||||
public:
|
||||
void readMotionSeries(std::vector<std::string>& lines);
|
||||
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ForceTorqueData>>> motionSeries;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,123 +5,78 @@ using namespace MbD;
|
||||
|
||||
void MbD::ASMTPart::parseASMT(std::vector<std::string>& lines)
|
||||
{
|
||||
size_t pos = lines[0].find_first_not_of("\t");
|
||||
auto leadingTabs = lines[0].substr(0, pos);
|
||||
while (!lines.empty()) {
|
||||
if (lines[0] == (leadingTabs + "Name")) {
|
||||
lines.erase(lines.begin());
|
||||
name = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Position3D")) {
|
||||
lines.erase(lines.begin());
|
||||
position3D = readColumnOfDoubles(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RotationMatrix")) {
|
||||
lines.erase(lines.begin());
|
||||
rotationMatrix = std::make_shared<FullMatrix<double>>(3);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto row = readRowOfDoubles(lines[0]);
|
||||
rotationMatrix->atiput(i, row);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Velocity3D")) {
|
||||
lines.erase(lines.begin());
|
||||
velocity3D = readColumnOfDoubles(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Omega3D")) {
|
||||
lines.erase(lines.begin());
|
||||
omega3D = readColumnOfDoubles(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "FeatureOrder")) {
|
||||
lines.erase(lines.begin());
|
||||
//featureOrder = std::make_shared<std::vector<std::shared_ptr<ASMTRefPoint>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "PrincipalMassMarker"));
|
||||
//std::vector<std::string> featureOrderLines(lines.begin(), it);
|
||||
//while (!featureOrderLines.empty()) {
|
||||
// if (featureOrderLines[0] == (leadingTabs + "\tExtrusion")) {
|
||||
// featureOrderLines.erase(featureOrderLines.begin());
|
||||
// auto extrusion = CREATE<ASMTExtrusion>::With();
|
||||
// extrusion->parseASMT(featureOrderLines);
|
||||
// featureOrder->push_back(extrusion);
|
||||
// extrusion->owner = this;
|
||||
// }
|
||||
// else {
|
||||
// assert(false);
|
||||
// }
|
||||
//}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "PrincipalMassMarker")) {
|
||||
lines.erase(lines.begin());
|
||||
principalMassMarker = CREATE<ASMTPrincipalMassMarker>::With();
|
||||
principalMassMarker->parseASMT(lines);
|
||||
principalMassMarker->owner = this;
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RefPoints")) {
|
||||
lines.erase(lines.begin());
|
||||
refPoints = std::make_shared<std::vector<std::shared_ptr<ASMTRefPoint>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "RefCurves"));
|
||||
std::vector<std::string> refPointsLines(lines.begin(), it);
|
||||
while (!refPointsLines.empty()) {
|
||||
if (refPointsLines[0] == (leadingTabs + "\tRefPoint")) {
|
||||
refPointsLines.erase(refPointsLines.begin());
|
||||
auto refPoint = CREATE<ASMTRefPoint>::With();
|
||||
refPoint->parseASMT(refPointsLines);
|
||||
refPoints->push_back(refPoint);
|
||||
refPoint->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RefCurves")) {
|
||||
lines.erase(lines.begin());
|
||||
refCurves = std::make_shared<std::vector<std::shared_ptr<ASMTRefCurve>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs + "RefSurfaces"));
|
||||
std::vector<std::string> refCurvesLines(lines.begin(), it);
|
||||
while (!refCurvesLines.empty()) {
|
||||
if (refCurvesLines[0] == (leadingTabs + "\tRefCurve")) {
|
||||
refCurvesLines.erase(refCurvesLines.begin());
|
||||
auto refCurve = CREATE<ASMTRefCurve>::With();
|
||||
refCurve->parseASMT(refCurvesLines);
|
||||
refCurves->push_back(refCurve);
|
||||
refCurve->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RefSurfaces")) {
|
||||
lines.erase(lines.begin());
|
||||
refSurfaces = std::make_shared<std::vector<std::shared_ptr<ASMTRefSurface>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs.substr(0, leadingTabs.size() - 1) + "Part"));
|
||||
std::vector<std::string> refSurfacesLines(lines.begin(), it);
|
||||
while (!refSurfacesLines.empty()) {
|
||||
if (refSurfacesLines[0] == (leadingTabs + "\tRefSurface")) {
|
||||
refSurfacesLines.erase(refSurfacesLines.begin());
|
||||
auto refSurface = CREATE<ASMTRefSurface>::With();
|
||||
refSurface->parseASMT(refSurfacesLines);
|
||||
refSurfaces->push_back(refSurface);
|
||||
refSurface->owner = this;
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
readName(lines);
|
||||
readPosition3D(lines);
|
||||
readRotationMatrix(lines);
|
||||
readVelocity3D(lines);
|
||||
readOmega3D(lines);
|
||||
readFeatureOrder(lines);
|
||||
readPrincipalMassMarker(lines);
|
||||
readRefPoints(lines);
|
||||
readRefCurves(lines);
|
||||
readRefSurfaces(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTPart::readFeatureOrder(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("FeatureOrder") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
//featureOrder = std::make_shared<std::vector<std::shared_ptr<ASMTRefPoint>>>();
|
||||
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
|
||||
return s.find("PrincipalMassMarker") != std::string::npos;
|
||||
});
|
||||
//std::vector<std::string> featureOrderLines(lines.begin(), it);
|
||||
//while (!featureOrderLines.empty()) {
|
||||
// if (featureOrderLines[0] == (leadingTabs + "\tExtrusion")) {
|
||||
// featureOrderLines.erase(featureOrderLines.begin());
|
||||
// auto extrusion = CREATE<ASMTExtrusion>::With();
|
||||
// extrusion->parseASMT(featureOrderLines);
|
||||
// featureOrder->push_back(extrusion);
|
||||
// extrusion->owner = this;
|
||||
// }
|
||||
// else {
|
||||
// assert(false);
|
||||
// }
|
||||
//}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTPart::readPrincipalMassMarker(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("PrincipalMassMarker") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
principalMassMarker = CREATE<ASMTPrincipalMassMarker>::With();
|
||||
principalMassMarker->parseASMT(lines);
|
||||
principalMassMarker->owner = this;
|
||||
}
|
||||
|
||||
void MbD::ASMTPart::readPartSeries(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
std::string substr = "PartSeries";
|
||||
auto pos = str.find(substr);
|
||||
assert(pos != std::string::npos);
|
||||
str.erase(0, pos + substr.length());
|
||||
auto seriesName = readString(str);
|
||||
assert(fullName("") == seriesName);
|
||||
lines.erase(lines.begin());
|
||||
//xs, ys, zs, bryxs, bryys, bryzs
|
||||
readXs(lines);
|
||||
readYs(lines);
|
||||
readZs(lines);
|
||||
readBryantxs(lines);
|
||||
readBryantys(lines);
|
||||
readBryantzs(lines);
|
||||
readVXs(lines);
|
||||
readVYs(lines);
|
||||
readVZs(lines);
|
||||
readOmegaXs(lines);
|
||||
readOmegaYs(lines);
|
||||
readOmegaZs(lines);
|
||||
readAXs(lines);
|
||||
readAYs(lines);
|
||||
readAZs(lines);
|
||||
readAlphaXs(lines);
|
||||
readAlphaYs(lines);
|
||||
readAlphaZs(lines);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "ASMTItem.h"
|
||||
#include "ASMTSpatialContainer.h"
|
||||
#include "ASMTRefPoint.h"
|
||||
#include "ASMTRefCurve.h"
|
||||
#include "ASMTRefSurface.h"
|
||||
#include "ASMTPrincipalMassMarker.h"
|
||||
#include "PosVelAccData.h"
|
||||
|
||||
namespace MbD {
|
||||
class ASMTPart : public ASMTItem
|
||||
class ASMTPart : public ASMTSpatialContainer
|
||||
{
|
||||
//
|
||||
public:
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
void readFeatureOrder(std::vector<std::string>& lines);
|
||||
void readPrincipalMassMarker(std::vector<std::string>& lines);
|
||||
void readPartSeries(std::vector<std::string>& lines);
|
||||
|
||||
std::string name;
|
||||
FColDsptr position3D, velocity3D, omega3D;
|
||||
FMatDsptr rotationMatrix;
|
||||
std::shared_ptr<ASMTPrincipalMassMarker> principalMassMarker;
|
||||
//std::shared_ptr<std::vector<std::shared_ptr<ASMTFeature>>> featureOrder;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefPoint>>> refPoints;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefCurve>>> refCurves;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefSurface>>> refSurfaces;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<PosVelAccData>>> partSeries;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace MbD {
|
||||
public:
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
|
||||
std::string name;
|
||||
FColDsptr position3D;
|
||||
FMatDsptr rotationMatrix;
|
||||
double mass, density;
|
||||
|
||||
@@ -5,54 +5,32 @@ using namespace MbD;
|
||||
|
||||
void MbD::ASMTRefPoint::parseASMT(std::vector<std::string>& lines)
|
||||
{
|
||||
size_t pos = lines[0].find_first_not_of("\t");
|
||||
auto leadingTabs = lines[0].substr(0, pos);
|
||||
while (!lines.empty()) {
|
||||
if (lines[0] == (leadingTabs + "Position3D")) {
|
||||
lines.erase(lines.begin());
|
||||
std::istringstream iss(lines[0]);
|
||||
position3D = std::make_shared<FullColumn<double>>();
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
position3D->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "RotationMatrix")) {
|
||||
lines.erase(lines.begin());
|
||||
rotationMatrix = std::make_shared<FullMatrix<double>>(3, 0);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto& row = rotationMatrix->at(i);
|
||||
std::istringstream iss(lines[0]);
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
row->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
}
|
||||
else if (lines[0] == (leadingTabs + "Markers")) {
|
||||
lines.erase(lines.begin());
|
||||
markers = std::make_shared<std::vector<std::shared_ptr<ASMTMarker>>>();
|
||||
auto it = std::find(lines.begin(), lines.end(), (leadingTabs.substr(0, leadingTabs.size() - 1) + "RefPoint"));
|
||||
std::vector<std::string> markersLines(lines.begin(), it);
|
||||
while (!markersLines.empty()) {
|
||||
if (markersLines[0] == (leadingTabs + "\tMarker")) {
|
||||
markersLines.erase(markersLines.begin());
|
||||
auto marker = CREATE<ASMTMarker>::With();
|
||||
marker->parseASMT(markersLines);
|
||||
markers->push_back(marker);
|
||||
marker->owner = this;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
readPosition3D(lines);
|
||||
readRotationMatrix(lines);
|
||||
readMarkers(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTRefPoint::readMarkers(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("Markers") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
markers = std::make_shared<std::vector<std::shared_ptr<ASMTMarker>>>();
|
||||
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
|
||||
return s.find("RefPoint") != std::string::npos;
|
||||
});
|
||||
std::vector<std::string> markersLines(lines.begin(), it);
|
||||
while (!markersLines.empty()) {
|
||||
readMarker(markersLines);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTRefPoint::readMarker(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("Marker") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
auto marker = CREATE<ASMTMarker>::With();
|
||||
marker->parseASMT(lines);
|
||||
markers->push_back(marker);
|
||||
marker->owner = this;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "ASMTItem.h"
|
||||
#include "ASMTSpatialItem.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "ASMTMarker.h"
|
||||
|
||||
namespace MbD {
|
||||
class ASMTRefPoint : public ASMTItem
|
||||
class ASMTRefPoint : public ASMTSpatialItem
|
||||
{
|
||||
//
|
||||
public:
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
void readMarkers(std::vector<std::string>& lines);
|
||||
void readMarker(std::vector<std::string>& lines);
|
||||
|
||||
FColDsptr position3D;
|
||||
FMatDsptr rotationMatrix;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTMarker>>> markers;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,18 +4,23 @@ using namespace MbD;
|
||||
|
||||
void MbD::ASMTRotationalMotion::parseASMT(std::vector<std::string>& lines)
|
||||
{
|
||||
size_t pos = lines[0].find_first_not_of("\t");
|
||||
auto leadingTabs = lines[0].substr(0, pos);
|
||||
assert(lines[0] == (leadingTabs + "Name"));
|
||||
readName(lines);
|
||||
readMotionJoint(lines);
|
||||
readRotationZ(lines);
|
||||
}
|
||||
|
||||
void MbD::ASMTRotationalMotion::readMotionJoint(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("MotionJoint") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
name = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "MotionJoint"));
|
||||
lines.erase(lines.begin());
|
||||
motionJoint = lines[0];
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "RotationZ"));
|
||||
lines.erase(lines.begin());
|
||||
rotationZ = lines[0];
|
||||
motionJoint = readString(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTRotationalMotion::readRotationZ(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("RotationZ") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
rotationZ = readString(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@ namespace MbD {
|
||||
//
|
||||
public:
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
void readMotionJoint(std::vector<std::string>& lines);
|
||||
void readRotationZ(std::vector<std::string>& lines);
|
||||
|
||||
std::string name, motionJoint, rotationZ;
|
||||
std::string motionJoint, rotationZ;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
192
MbDCode/ASMTSpatialContainer.cpp
Normal file
192
MbDCode/ASMTSpatialContainer.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
#include "ASMTSpatialContainer.h"
|
||||
|
||||
void MbD::ASMTSpatialContainer::readRefPoints(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("RefPoints") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
refPoints = std::make_shared<std::vector<std::shared_ptr<ASMTRefPoint>>>();
|
||||
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
|
||||
return s.find("RefCurves") != std::string::npos;
|
||||
});
|
||||
std::vector<std::string> refPointsLines(lines.begin(), it);
|
||||
while (!refPointsLines.empty()) {
|
||||
readRefPoint(refPointsLines);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readRefPoint(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("RefPoint") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
auto refPoint = CREATE<ASMTRefPoint>::With();
|
||||
refPoint->parseASMT(lines);
|
||||
refPoints->push_back(refPoint);
|
||||
refPoint->owner = this;
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readRefCurves(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("RefCurves") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
refCurves = std::make_shared<std::vector<std::shared_ptr<ASMTRefCurve>>>();
|
||||
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
|
||||
return s.find("RefSurfaces") != std::string::npos;
|
||||
});
|
||||
std::vector<std::string> refCurvesLines(lines.begin(), it);
|
||||
while (!refCurvesLines.empty()) {
|
||||
readRefCurve(refCurvesLines);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readRefCurve(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readRefSurfaces(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("RefSurfaces") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
refSurfaces = std::make_shared<std::vector<std::shared_ptr<ASMTRefSurface>>>();
|
||||
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
|
||||
return s.find("Part") != std::string::npos;
|
||||
});
|
||||
std::vector<std::string> refSurfacesLines(lines.begin(), it);
|
||||
while (!refSurfacesLines.empty()) {
|
||||
readRefSurface(refSurfacesLines);
|
||||
}
|
||||
lines.erase(lines.begin(), it);
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readRefSurface(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readXs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "X", xs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readYs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "Y", ys);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readZs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "Z", zs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readBryantxs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "Bryantx", bryxs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readBryantys(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "Bryanty", bryys);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readBryantzs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "Bryantz", bryzs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readVXs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "VX", vxs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readVYs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "VY", vys);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readVZs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "VZ", vzs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readOmegaXs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "OmegaX", omexs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readOmegaYs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "OmegaY", omeys);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readOmegaZs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "OmegaZ", omezs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readAXs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "AX", axs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readAYs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "AY", ays);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readAZs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "AZ", azs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readAlphaXs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "AlphaX", alpxs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readAlphaYs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "AlphaY", alpys);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialContainer::readAlphaZs(std::vector<std::string>& lines)
|
||||
{
|
||||
std::string str = lines[0];
|
||||
readDoublesInto(str, "AlphaZ", alpzs);
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
47
MbDCode/ASMTSpatialContainer.h
Normal file
47
MbDCode/ASMTSpatialContainer.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include "ASMTSpatialItem.h"
|
||||
#include "ASMTRefPoint.h"
|
||||
#include "ASMTRefCurve.h"
|
||||
#include "ASMTRefSurface.h"
|
||||
|
||||
namespace MbD {
|
||||
class ASMTSpatialContainer : public ASMTSpatialItem
|
||||
{
|
||||
//
|
||||
public:
|
||||
void readRefPoints(std::vector<std::string>& lines);
|
||||
void readRefPoint(std::vector<std::string>& lines);
|
||||
void readRefCurves(std::vector<std::string>& lines);
|
||||
void readRefCurve(std::vector<std::string>& lines);
|
||||
void readRefSurfaces(std::vector<std::string>& lines);
|
||||
void readRefSurface(std::vector<std::string>& lines);
|
||||
void readXs(std::vector<std::string>& lines);
|
||||
void readYs(std::vector<std::string>& lines);
|
||||
void readZs(std::vector<std::string>& lines);
|
||||
void readBryantxs(std::vector<std::string>& lines);
|
||||
void readBryantys(std::vector<std::string>& lines);
|
||||
void readBryantzs(std::vector<std::string>& lines);
|
||||
void readVXs(std::vector<std::string>& lines);
|
||||
void readVYs(std::vector<std::string>& lines);
|
||||
void readVZs(std::vector<std::string>& lines);
|
||||
void readOmegaXs(std::vector<std::string>& lines);
|
||||
void readOmegaYs(std::vector<std::string>& lines);
|
||||
void readOmegaZs(std::vector<std::string>& lines);
|
||||
void readAXs(std::vector<std::string>& lines);
|
||||
void readAYs(std::vector<std::string>& lines);
|
||||
void readAZs(std::vector<std::string>& lines);
|
||||
void readAlphaXs(std::vector<std::string>& lines);
|
||||
void readAlphaYs(std::vector<std::string>& lines);
|
||||
void readAlphaZs(std::vector<std::string>& lines);
|
||||
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefPoint>>> refPoints;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefCurve>>> refCurves;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefSurface>>> refSurfaces;
|
||||
FRowDsptr xs, ys, zs, bryxs, bryys, bryzs;
|
||||
FRowDsptr vxs, vys, vzs, omexs, omeys, omezs;
|
||||
FRowDsptr axs, ays, azs, alpxs, alpys, alpzs;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
59
MbDCode/ASMTSpatialItem.cpp
Normal file
59
MbDCode/ASMTSpatialItem.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "ASMTSpatialItem.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
void MbD::ASMTSpatialItem::readPosition3D(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("Position3D") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
std::istringstream iss(lines[0]);
|
||||
position3D = std::make_shared<FullColumn<double>>();
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
position3D->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialItem::readRotationMatrix(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("RotationMatrix") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
rotationMatrix = std::make_shared<FullMatrix<double>>(3, 0);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto& row = rotationMatrix->at(i);
|
||||
std::istringstream iss(lines[0]);
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
row->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialItem::readVelocity3D(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("Velocity3D") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
std::istringstream iss(lines[0]);
|
||||
velocity3D = std::make_shared<FullColumn<double>>();
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
velocity3D->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialItem::readOmega3D(std::vector<std::string>& lines)
|
||||
{
|
||||
assert(lines[0].find("Omega3D") != std::string::npos);
|
||||
lines.erase(lines.begin());
|
||||
std::istringstream iss(lines[0]);
|
||||
omega3D = std::make_shared<FullColumn<double>>();
|
||||
double d;
|
||||
while (iss >> d) {
|
||||
omega3D->push_back(d);
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
20
MbDCode/ASMTSpatialItem.h
Normal file
20
MbDCode/ASMTSpatialItem.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "ASMTItem.h"
|
||||
|
||||
namespace MbD {
|
||||
class ASMTSpatialItem : public ASMTItem
|
||||
{
|
||||
//
|
||||
public:
|
||||
void readPosition3D(std::vector<std::string>& lines);
|
||||
void readRotationMatrix(std::vector<std::string>& lines);
|
||||
void readVelocity3D(std::vector<std::string>& lines);
|
||||
void readOmega3D(std::vector<std::string>& lines);
|
||||
|
||||
FColDsptr position3D, velocity3D, omega3D;
|
||||
FMatDsptr rotationMatrix;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MbD {
|
||||
public:
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
|
||||
std::string name, motionJoint, translationZ;
|
||||
std::string motionJoint, translationZ;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace MbD {
|
||||
//
|
||||
public:
|
||||
CADSystem() {
|
||||
mbdSystem->externalSystem = this;
|
||||
mbdSystem->externalSystem->cadSystem = this;
|
||||
}
|
||||
|
||||
void outputFor(AnalysisType type);
|
||||
|
||||
31
MbDCode/ExternalSystem.cpp
Normal file
31
MbDCode/ExternalSystem.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "ExternalSystem.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
void MbD::ExternalSystem::preMbDrun()
|
||||
{
|
||||
}
|
||||
|
||||
void MbD::ExternalSystem::outputFor(AnalysisType type)
|
||||
{
|
||||
}
|
||||
|
||||
void MbD::ExternalSystem::logString(std::string& str)
|
||||
{
|
||||
}
|
||||
|
||||
void MbD::ExternalSystem::logString(double value)
|
||||
{
|
||||
}
|
||||
|
||||
void MbD::ExternalSystem::runOndselPiston()
|
||||
{
|
||||
}
|
||||
|
||||
void MbD::ExternalSystem::runPiston()
|
||||
{
|
||||
}
|
||||
|
||||
void MbD::ExternalSystem::postMbDrun()
|
||||
{
|
||||
}
|
||||
32
MbDCode/ExternalSystem.h
Normal file
32
MbDCode/ExternalSystem.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "enum.h"
|
||||
#include <string>
|
||||
|
||||
//#include "CADSystem.h"
|
||||
//#include "ASMTAssembly.h"
|
||||
|
||||
namespace MbD {
|
||||
class CADSystem;
|
||||
class ASMTAssembly;
|
||||
|
||||
class ExternalSystem
|
||||
{
|
||||
//
|
||||
public:
|
||||
void preMbDrun();
|
||||
void outputFor(AnalysisType type);
|
||||
void logString(std::string& str);
|
||||
void logString(double value);
|
||||
void runOndselPiston();
|
||||
void runPiston();
|
||||
void postMbDrun();
|
||||
|
||||
|
||||
CADSystem* cadSystem;
|
||||
ASMTAssembly* asmtAssembly;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ int main()
|
||||
|
||||
auto externalSys = std::make_shared<CADSystem>();
|
||||
externalSys->runOndselPiston();
|
||||
externalSys->runPiston();
|
||||
runSpMat();
|
||||
//externalSys->runPiston();
|
||||
//runSpMat();
|
||||
}
|
||||
|
||||
void runSpMat() {
|
||||
|
||||
@@ -159,6 +159,8 @@
|
||||
<ClCompile Include="ASMTRevoluteJoint.cpp" />
|
||||
<ClCompile Include="ASMTRotationalMotion.cpp" />
|
||||
<ClCompile Include="ASMTSimulationParameters.cpp" />
|
||||
<ClCompile Include="ASMTSpatialContainer.cpp" />
|
||||
<ClCompile Include="ASMTSpatialItem.cpp" />
|
||||
<ClCompile Include="ASMTTranslationalMotion.cpp" />
|
||||
<ClCompile Include="AtPointConstraintIJ.cpp" />
|
||||
<ClCompile Include="AtPointConstraintIqcJc.cpp" />
|
||||
@@ -181,7 +183,8 @@
|
||||
<ClCompile Include="CREATE.cpp" />
|
||||
<ClCompile Include="CylindricalJoint.cpp" />
|
||||
<ClCompile Include="CylSphJoint.cpp" />
|
||||
<ClCompile Include="DataPosVelAcc.cpp" />
|
||||
<ClCompile Include="ExternalSystem.cpp" />
|
||||
<ClCompile Include="PosVelAccData.cpp" />
|
||||
<ClCompile Include="DiagonalMatrix.cpp" />
|
||||
<ClCompile Include="DifferenceOperator.cpp" />
|
||||
<ClCompile Include="DirectionCosineConstraintIJ.cpp" />
|
||||
@@ -390,6 +393,8 @@
|
||||
<ClInclude Include="ASMTRevoluteJoint.h" />
|
||||
<ClInclude Include="ASMTRotationalMotion.h" />
|
||||
<ClInclude Include="ASMTSimulationParameters.h" />
|
||||
<ClInclude Include="ASMTSpatialContainer.h" />
|
||||
<ClInclude Include="ASMTSpatialItem.h" />
|
||||
<ClInclude Include="ASMTTranslationalMotion.h" />
|
||||
<ClInclude Include="AtPointConstraintIJ.h" />
|
||||
<ClInclude Include="AtPointConstraintIqcJc.h" />
|
||||
@@ -412,7 +417,8 @@
|
||||
<ClInclude Include="CREATE.h" />
|
||||
<ClInclude Include="CylindricalJoint.h" />
|
||||
<ClInclude Include="CylSphJoint.h" />
|
||||
<ClInclude Include="DataPosVelAcc.h" />
|
||||
<ClInclude Include="ExternalSystem.h" />
|
||||
<ClInclude Include="PosVelAccData.h" />
|
||||
<ClInclude Include="DiagonalMatrix.h" />
|
||||
<ClInclude Include="DifferenceOperator.h" />
|
||||
<ClInclude Include="DirectionCosineConstraintIJ.h" />
|
||||
|
||||
@@ -429,7 +429,7 @@
|
||||
<ClCompile Include="StateData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DataPosVelAcc.cpp">
|
||||
<ClCompile Include="PosVelAccData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CADSystem.cpp">
|
||||
@@ -702,6 +702,15 @@
|
||||
<ClCompile Include="ASMTGeneralMotion.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ASMTSpatialItem.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ASMTSpatialContainer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ExternalSystem.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Array.h">
|
||||
@@ -1127,7 +1136,7 @@
|
||||
<ClInclude Include="StateData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DataPosVelAcc.h">
|
||||
<ClInclude Include="PosVelAccData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CADSystem.h">
|
||||
@@ -1400,6 +1409,15 @@
|
||||
<ClInclude Include="ASMTGeneralMotion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ASMTSpatialItem.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ASMTSpatialContainer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ExternalSystem.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="MbDCode.rc">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "CREATE.h"
|
||||
#include "DiagonalMatrix.h"
|
||||
#include "EulerParameters.h"
|
||||
#include "DataPosVelAcc.h"
|
||||
#include "PosVelAccData.h"
|
||||
|
||||
|
||||
using namespace MbD;
|
||||
@@ -538,7 +538,7 @@ std::shared_ptr<StateData> Part::stateData()
|
||||
auto omeOpO = this->omeOpO();
|
||||
auto aOpO = this->qXddot();
|
||||
auto alpOpO = this->alpOpO();
|
||||
auto answer = std::make_shared<DataPosVelAcc>();
|
||||
auto answer = std::make_shared<PosVelAccData>();
|
||||
answer->rFfF = rOpO;
|
||||
answer->aAFf = aAOp;
|
||||
answer->vFfF = vOpO;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include <ostream>
|
||||
|
||||
#include "DataPosVelAcc.h"
|
||||
#include "PosVelAccData.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
std::ostream& DataPosVelAcc::printOn(std::ostream& s) const
|
||||
std::ostream& PosVelAccData::printOn(std::ostream& s) const
|
||||
{
|
||||
s << "refData = " << *refData << std::endl;
|
||||
s << "rFfF = " << *rFfF << std::endl;
|
||||
@@ -3,13 +3,13 @@
|
||||
#include "StateData.h"
|
||||
|
||||
namespace MbD {
|
||||
class DataPosVelAcc : public StateData
|
||||
class PosVelAccData : public StateData
|
||||
{
|
||||
//refData rFfF aAFf vFfF omeFfF aFfF alpFfF
|
||||
public:
|
||||
std::ostream& printOn(std::ostream& s) const override;
|
||||
|
||||
std::shared_ptr<DataPosVelAcc> refData;
|
||||
std::shared_ptr<PosVelAccData> refData;
|
||||
FColDsptr rFfF, vFfF, omeFfF, aFfF, alpFfF;
|
||||
FMatDsptr aAFf;
|
||||
};
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "SystemSolver.h"
|
||||
#include "Time.h"
|
||||
#include "CREATE.h"
|
||||
#include "CADSystem.h"
|
||||
#include "ExternalSystem.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
@@ -26,6 +26,7 @@ System* MbD::System::root()
|
||||
|
||||
void System::initialize()
|
||||
{
|
||||
externalSystem = std::make_shared<ExternalSystem>();
|
||||
time = CREATE<Time>::With();
|
||||
parts = std::make_shared<std::vector<std::shared_ptr<Part>>>();
|
||||
jointsMotions = std::make_shared<std::vector<std::shared_ptr<Joint>>>();
|
||||
@@ -53,6 +54,7 @@ void MbD::System::addMotion(std::shared_ptr<PrescribedMotion> motion)
|
||||
|
||||
void System::runKINEMATIC()
|
||||
{
|
||||
externalSystem->preMbDrun();
|
||||
while (true)
|
||||
{
|
||||
initializeLocally();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "Item.h"
|
||||
#include "PrescribedMotion.h"
|
||||
#include "ExternalSystem.h"
|
||||
|
||||
//using namespace CAD;
|
||||
|
||||
@@ -25,7 +26,6 @@ namespace MbD {
|
||||
class Constraint;
|
||||
class ForceTorqueItem;
|
||||
//class CAD::CADSystem;
|
||||
class CADSystem;
|
||||
|
||||
class System : public Item
|
||||
{
|
||||
@@ -63,8 +63,7 @@ namespace MbD {
|
||||
double rotationLimit();
|
||||
void outputFor(AnalysisType type);
|
||||
|
||||
//CAD::CADSystem* externalSystem; //Use raw pointer to point backwards
|
||||
CADSystem* externalSystem; //Use raw pointer to point backwards
|
||||
std::shared_ptr<ExternalSystem> externalSystem;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<Part>>> parts;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<Joint>>> jointsMotions;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ForceTorqueItem>>> forcesTorques;
|
||||
|
||||
Reference in New Issue
Block a user