10#ifndef C_MODEL_WRITER_H
11#define C_MODEL_WRITER_H
12#include "IntegratorOptions.h"
14#include "sfh/linalg.h"
23 CModelWriter(std::string outDir, std::string name,
bool usePlaceholders =
false)
27 m_usePlaceholders = usePlaceholders;
31 static std::string
ArrayToText(
double* adProperty,
unsigned short iSize);
34 static std::string
MakePropString(std::string sName,
double val, std::string placeholder,
bool usePlaceholder);
41 static std::string
MakePropString(std::string sName,
double* adProperty,
unsigned short iSize,
49 static std::string
MakePropString(std::string sName, std::tuple<double, double, double> adProperty,
53 static std::string
MakePropString(std::string sName,
int* aiProperty,
unsigned short iSize,
61 static std::string
MakePropString(std::string sName,
double dProperty1,
double dProperty2,
66 static std::string
MakePropString(std::string sName,
double dProperty1,
double dProperty2,
70 static std::string
MakePropString(std::string sName, sfh::linalg::Vec2 SProperty,
74 static std::string
MakePropString(std::string sName, sfh::linalg::Vec3 SProperty,
78 static std::string
MakePropString(std::string sName, std::vector<double> VdProperty,
82 static std::string
MakePropString(std::string sName, std::vector<int> ViProperty,
86 static std::string
MakePropString(std::string sName, std::vector<std::string> VsProperty,
91 std::string posObject,
int posPortIndex, std::string forcePortPrefix =
"", std::string posPortPrefix =
"",
96 std::string velInPort, std::string posOutObject, std::string posOutPort, std::string velOutPort, std::string forceInPort,
103 bool SendToFile(
const std::string sFileName,
const std::string*
const psOutputString);
105 void SetOutDirectory(std::string outDir) { m_outDir = outDir; }
107 void SetName(std::string name);
109 std::string GetName()
const {
return m_name; }
125 std::string m_outDir;
126 bool m_usePlaceholders;
Contains static functions to write properties for fhSim from model to string and strings to model fil...
Definition CModelWriter.h:20
std::string MakePosForceConnectionString(std::string forceOutObject, std::string forceOutPort, std::string posInPort, std::string velInPort, std::string posOutObject, std::string posOutPort, std::string velOutPort, std::string forceInPort, bool dropForceFeedback=false, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a force-pos-vel connection for the fhSim input file.
static std::string MakePropString(std::string sName, double val, std::string placeholder, bool usePlaceholder)
Makes a property string which is replaced with a placeholder if value is NaN or usePlaceholder is tru...
static std::string MakePropString(std::string sName, std::vector< int > ViProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a vector value.
static std::string MakePropString(std::string sName, double dProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a double value.
static std::string ArrayToText(double *adProperty, unsigned short iSize)
Creates a string of a double array.
static std::string MakePropString(std::string sName, double dProperty1, double dProperty2, double dProperty3, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from three double values.
std::string m_sModel
The model string to be written to the model file.
Definition CModelWriter.h:116
static const unsigned short kMainIndent
The default number of tabulations before the property names.
Definition CModelWriter.h:124
static std::string MakePropString(std::string sName, int *aiProperty, unsigned short iSize, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from an integer array value.
static std::string MakePropString(std::string sName, double *adProperty, unsigned short iSize, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a double array value.
static std::string MakePosForceConnectionString(std::string forceObject, int forcePortIndex, std::string posObject, int posPortIndex, std::string forcePortPrefix="", std::string posPortPrefix="", bool dropForceFeedback=false, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a force-pos-vel connection for the fhSim input file.
bool AddIntegration()
Adds the integration options to the model string.
std::string m_name
The name of the model in the main model file.
Definition CModelWriter.h:118
static std::string MakePropString(std::string sName, std::vector< std::string > VsProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a vector value.
IntegratorOptions m_IntegratorOptions
The integrator options.
Definition CModelWriter.h:115
static std::string MakePropString(std::string sName, std::string sProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a string value.
static std::string MakePropString(std::string sName, std::vector< double > VdProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a vector value.
static std::string MakePropString(std::string sName, sfh::linalg::Vec3 SProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a 3D vector value.
bool SendToFile(const std::string sFileName, const std::string *const psOutputString)
Creates a file with the input string as its content.
void SetIntegratorOptions(IntegratorOptions IntOptions)
Sets the integrator options of the system.
static std::string MakePropString(std::string sName, std::tuple< double, double, double > adProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a three value tuple value.
static std::string MakePropString(std::string sName, sfh::linalg::Vec2 SProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a 2D vector value.
static std::string MakePropString(std::string sName, int iProperty, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from an integer value.
static const unsigned short kEqualIndent
The default position of the equal sign in the property strings.
Definition CModelWriter.h:121
static std::string MakePropString(std::string sName, double dProperty1, double dProperty2, short iMainIndent=kMainIndent, short iEqualIndent=kEqualIndent)
Makes a property string for the fhSim input file from a two double values.
std::string m_sBaseFileName
The name of the main model file.
Definition CModelWriter.h:117
Definition IntegratorOptions.h:9