FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CModelWriter.h
1
10#ifndef C_MODEL_WRITER_H
11#define C_MODEL_WRITER_H
12#include "IntegratorOptions.h"
13
14#include "sfh/linalg.h"
15#include <tuple>
16#include <vector>
17#include <string>
18
20{
21public:
22 virtual ~CModelWriter();
23 CModelWriter(std::string outDir, std::string name, bool usePlaceholders = false)
24 {
25 m_outDir = outDir;
26 m_name = name;
27 m_usePlaceholders = usePlaceholders;
28 }
29
31 static std::string ArrayToText(double* adProperty, unsigned short iSize);
32
34 static std::string MakePropString(std::string sName, double val, std::string placeholder, bool usePlaceholder);
35
37 static std::string MakePropString(std::string sName, std::string sProperty,
38 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
39
41 static std::string MakePropString(std::string sName, double* adProperty, unsigned short iSize,
42 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
43
45 static std::string MakePropString(std::string sName, int iProperty,
46 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
47
49 static std::string MakePropString(std::string sName, std::tuple<double, double, double> adProperty,
50 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
51
53 static std::string MakePropString(std::string sName, int* aiProperty, unsigned short iSize,
54 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
55
57 static std::string MakePropString(std::string sName, double dProperty,
58 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
59
61 static std::string MakePropString(std::string sName, double dProperty1, double dProperty2,
62 double dProperty3, short iMainIndent = kMainIndent,
63 short iEqualIndent = kEqualIndent);
64
66 static std::string MakePropString(std::string sName, double dProperty1, double dProperty2,
67 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
68
70 static std::string MakePropString(std::string sName, sfh::linalg::Vec2 SProperty,
71 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
72
74 static std::string MakePropString(std::string sName, sfh::linalg::Vec3 SProperty,
75 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
76
78 static std::string MakePropString(std::string sName, std::vector<double> VdProperty,
79 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
80
82 static std::string MakePropString(std::string sName, std::vector<int> ViProperty,
83 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
84
86 static std::string MakePropString(std::string sName, std::vector<std::string> VsProperty,
87 short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
88
90 static std::string MakePosForceConnectionString(std::string forceObject, int forcePortIndex,
91 std::string posObject, int posPortIndex, std::string forcePortPrefix = "", std::string posPortPrefix = "",
92 bool dropForceFeedback = false, short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
93
95 std::string MakePosForceConnectionString(std::string forceOutObject, std::string forceOutPort, std::string posInPort,
96 std::string velInPort, std::string posOutObject, std::string posOutPort, std::string velOutPort, std::string forceInPort,
97 bool dropForceFeedback = false, short iMainIndent = kMainIndent, short iEqualIndent = kEqualIndent);
98
101
103 bool SendToFile(const std::string sFileName, const std::string* const psOutputString);
104
105 void SetOutDirectory(std::string outDir) { m_outDir = outDir; }
106
107 void SetName(std::string name);
108
109 std::string GetName() const { return m_name; }
110
111protected:
114
116 std::string m_sModel;
117 std::string m_sBaseFileName;
118 std::string m_name;
119
121 static const unsigned short kEqualIndent = 45;
122
124 static const unsigned short kMainIndent = 3;
125 std::string m_outDir;
126 bool m_usePlaceholders;
127};
128
129#endif
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