1 //#**************************************************************
2 //#
3 //# filename:             script_parser.h
4 //#
5 //# author:               Gerstmayr Johannes
6 //#
7 //# generated:						July 2004
8 //# description:          parser for creating objects in script language
9 //#
10 //# remarks:
11 //#
12 //# Copyright (c) 2003-2013 Johannes Gerstmayr, Linz Center of Mechatronics GmbH, Austrian
13 //# Center of Competence in Mechatronics GmbH, Institute of Technical Mechanics at the
14 //# Johannes Kepler Universitaet Linz, Austria. All rights reserved.
15 //#
16 //# This file is part of HotInt.
17 //# HotInt is free software: you can redistribute it and/or modify it under the terms of
18 //# the HOTINT license. See folder 'licenses' for more details.
19 //#
20 //# bug reports are welcome!!!
21 //# WWW:		www.hotint.org
22 //# email:	bug_reports@hotint.org or support@hotint.org
23 //#**************************************************************
24 
25 
26 #ifndef SCRIPT_PARSER__H
27 #define SCRIPT_PARSER__H
28 
29 class CEDCParser;
30 class CMBSParser;
31 struct MBSObjectFactoryInterface;
32 
33 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
35 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37 //Parsing input files:
38 
39 //typedef enum {TAEflexible=1, TAEconstraint=2, TAE2D = 4, TAEspecial_connector=8} TAddElementType; //$ DR 2012-07: old code
40 
41 ////+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42 ////parser for ElementDataContainer:
43 ////$JG2012-01-27: created
44 ////string-->EDC
45 ////EDC-->string
46 
47 //these are default values for the creation of bodies, sensors, etc.
48 class Default_ParserObjectValues
49 {
50 public:
Default_ParserObjectValues()51 	Default_ParserObjectValues()
52 	{
53 		defaultbodycol = Vector3D(0.2,0.2,0.8);
54 		defaultconstraintcol = Vector3D(0.2,0.8,0.2);
55 		defaultbodypos = Vector3D(0.,0.,0.);
56 		defaultbodyvel = Vector3D(0.,0.,0.);
57 		defaultbodyangle = Vector3D(0.,0.,0.);
58 		defaultbodyangularvel = Vector3D(0.,0.,0.);
59 		defaultbodysize = Vector3D(1.,1.,1.);
60 		defaultbodyrho = 1000;
61 		defaultconstraintdim = Vector3D(0.1,0.1,16.);
62 
63 		defaultsensorvisible = 1;
64 		defaultsensorwriteresults = 3;
65 		defaultsensorprecision = 17;
66 		defaultsensordrawdim = Vector3D(0.001,6,0);
67 
68 		defaultgeomtile = 16;
69 		defaultgeomcol = Vector3D(0.5,0.5,0.5);
70     defaultgeomdim = Vector3D(1,1,1);
71     defaulttransparency=-1;
72 
73 		//flexible bodies:
74 		defaultbodyEm = 1e8;
75 		defaultbodynu = 0.;
76 	}
77 public:
78 	Vector3D defaultbodycol;
79 	Vector3D defaultconstraintcol;
80 	Vector3D defaultbodypos;
81 	Vector3D defaultbodyvel;
82 	Vector3D defaultbodyangle;
83 	Vector3D defaultbodyangularvel;
84 	Vector3D defaultbodysize;
85 	double defaultbodyrho;
86 	Vector3D defaultconstraintdim;
87 
88 	int defaultsensorvisible;
89 	int defaultsensorwriteresults;
90 	int defaultsensorprecision;
91 	Vector3D defaultsensordrawdim;
92 
93 	int defaultgeomtile;
94 	Vector3D defaultgeomcol;
95 	Vector3D defaultgeomdim;
96   double defaulttransparency;
97 
98 	//flexible bodies:
99 	double defaultbodyEm;
100 	double defaultbodynu;
101 };
102 
103 //typedef enum {TCT_AddElement=1, TCT_AddConstraint=2, TCT_AddSensor=3, TCT_AddLoad=4, TCT_AddGeomElement=5, } TEDCParser_CommandType;
104 
105 typedef enum { TCO_None = 0, TCO_FollowedByContainer = 1, TCO_LeftHandSideOnly = 2, TCO_RequiresHandle = 4} TEDCParser_CommandOption;
106 
107 //class for EDC-based commands, which can be parsed
108 class CEDC_Command
109 {
110 public:
111 	//initialization
CEDC_Command(int id)112 	CEDC_Command(int id)
113 	{
114 		command_id = id;
115 	}
116 
117 	//unit command id, which is automatically assigned
GetCommandID()118 	virtual int GetCommandID() const {return command_id;}
119 
120 	//name of command in parser
CommandName()121 	virtual const char* CommandName() const {assert(0); return "";}
122 
123 	//Tex description for the docu
GetCommandTexDescription()124 	virtual mystr GetCommandTexDescription() const {return "";};
GetCommandTexParameterDescription()125 	virtual mystr GetCommandTexParameterDescription() const {return "";};
GetCommandTexReturnValueDescription()126 	virtual mystr GetCommandTexReturnValueDescription() const {return "";};
GetCommandExampleFileName()127 	virtual mystr GetCommandExampleFileName() const {return "";};
128 
129 	//number of fixed parameters, which are necessary for the execution of the command
NParameters()130 	virtual int NParameters() const {return 0;}
131 
HasReturnValue()132 	virtual int HasReturnValue() const {return 0;} //0: no return value, 1: has a return value (ElementData)
GetOptions()133 	virtual int GetOptions() const {return 0;} //some options, which are not yet specified
134 
135 	//execute command, 1==success, 0==failed
ExecuteCommand(MBS * mbs,CEDCParser * edcParser,TArray<ElementDataContainer * > & parameter_EDCs,ElementData & return_value,int option)136 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option) {assert(0); return 0;}
137 
138 	//convert textual (inline, not previously defined as variables) parameter to numerical value
139 	//NOTE: inline definition of Vector is NOT working:
140 	//in function GetParameterEDC spaces get contracted, "," are interpreted as seperators for arguments
141 	virtual int EvaluateTextualParameterEntry(MBS* mbs, CEDCParser * edcParser, ElementDataContainer* param_edc);
142 
143 private:
144 	int command_id;
145 };
146 
147 class CEDC_ComAddElement: public CEDC_Command
148 {
149 public:
150 	//initialization
CEDC_ComAddElement(int id)151 	CEDC_ComAddElement(int id): CEDC_Command(id) {}
152 
CommandName()153 	virtual const char* CommandName() const {return "AddElement";}
154 
155 	//description for the docu
GetCommandTexDescription()156 	virtual mystr GetCommandTexDescription() const {return "Adds an element to the system. See the description of the elements above in order to get the available options.";};
GetCommandTexParameterDescription()157 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is an ElementDataContainer with the data of the element. ATTENTION: the entry element\\_type must exist!";};
GetCommandTexReturnValueDescription()158 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value of this command is the number of the element in the MBS.";};
GetCommandExampleFileName()159 	virtual mystr GetCommandExampleFileName() const {return "AddElement.txt";};
160 
NParameters()161 	virtual int NParameters() const {return 1;}
HasReturnValue()162 	virtual int HasReturnValue() const {return 1;}
GetOptions()163 	virtual int GetOptions() const {return 0;}
164 
IsAddElement()165 	virtual int IsAddElement() const {return 1;} //this only distinguishes the AddElement from the AddConstraint command
166 
167 	//execute command, 1==success, 0==failed
168 	//it is already checked, that the number of parameters is equal to the desired number of parameters
169 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
170 private:
171 };
172 
173 class CEDC_ComAddConstraint: public CEDC_ComAddElement
174 {
175 public:
176 	//initialization
CEDC_ComAddConstraint(int id)177 	CEDC_ComAddConstraint(int id): CEDC_ComAddElement(id) {}
178 
CommandName()179 	virtual const char* CommandName() const {return "AddConnector";}
IsAddElement()180 	virtual int IsAddElement() const {return 0;} //this only distinguishes the AddElement from the AddConstraint command
GetCommandTexDescription()181 	virtual mystr GetCommandTexDescription() const {return "Adds a connector to the system. See the description of the connectors above in order to get the available options.";};
GetCommandTexParameterDescription()182 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is an ElementDataContainer with the data of the connector. ATTENTION: the entry element\\_type must exist!";};
GetCommandTexReturnValueDescription()183 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value of this command is the number of the connector in the MBS.";};
GetCommandExampleFileName()184 	virtual mystr GetCommandExampleFileName() const {return "AddConnector.txt";};
185 };
186 //$ RL 2012-7-19:[
187 class CEDC_ComAddGeomElement: public CEDC_Command
188 {
189 public:
190 	//initialization
CEDC_ComAddGeomElement(int id)191 	CEDC_ComAddGeomElement(int id): CEDC_Command(id) {}
192 
CommandName()193 	virtual const char* CommandName() const {return "AddGeomElement";}
NParameters()194 	virtual int NParameters() const {return 1;}
HasReturnValue()195 	virtual int HasReturnValue() const {return 1;}
196 
197 	//description for the docu
GetCommandTexDescription()198 	virtual mystr GetCommandTexDescription() const {return "This command adds an geometric element.";};
GetCommandTexParameterDescription()199 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is an ElementDataContainer with the data of the geometric element. ATTENTION: the entry geom\\_element\\_type must exist!";};
GetCommandTexReturnValueDescription()200 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value of this command is the number of the geometric element in the MBS.";}
GetCommandExampleFileName()201 	virtual mystr GetCommandExampleFileName() const {return "AddGeomElement.txt";};
202 
203 
204 	//execute command, 1==success, 0==failed
205 	//it is already checked, that the number of parameters is equal to the desired number of parameters
206 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
207 private:
208 };
209 
210 class CEDC_ComInclude: public CEDC_Command
211 {
212 public:
213 	//initialization
CEDC_ComInclude(int id)214 	CEDC_ComInclude(int id): CEDC_Command(id) {}
215 
CommandName()216 	virtual const char* CommandName() const {return "Include";}
NParameters()217 	virtual int NParameters() const {return 1;}
HasReturnValue()218 	virtual int HasReturnValue() const {return 0;}
219 
220 
221 	//description for the docu
GetCommandTexDescription()222 	virtual mystr GetCommandTexDescription() const {return "This command includes a file.";};
GetCommandTexParameterDescription()223 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is the absolut or relative filename. If a relative filename is used, than the path is relative to the last file! Be carefull, if you use this command more than one time in a file.";};
GetCommandTexReturnValueDescription()224 	virtual mystr GetCommandTexReturnValueDescription() const {return "There is no return value defined yet.";}
GetCommandExampleFileName()225 	virtual mystr GetCommandExampleFileName() const {return "Include.txt";};
226 
227 
228 	//execute command, 1==success, 0==failed
229 	//it is already checked, that the number of parameters is equal to the desired number of parameters
230 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
231 private:
232 };
233 //$ RL 2012-7-19:]
234 
235 class CEDC_ComPrint: public CEDC_Command
236 {
237 public:
238 	//initialization
CEDC_ComPrint(int id)239 	CEDC_ComPrint(int id): CEDC_Command(id) {}
240 
CommandName()241 	virtual const char* CommandName() const {return "Print";}
NParameters()242 	virtual int NParameters() const {return 1;}
HasReturnValue()243 	virtual int HasReturnValue() const {return 0;}
244 
245 	//description for the docu
GetCommandTexDescription()246 	virtual mystr GetCommandTexDescription() const {return "Prints a text to the output window";};
247 	virtual mystr GetCommandTexParameterDescription() const;
GetCommandTexReturnValueDescription()248 	virtual mystr GetCommandTexReturnValueDescription() const {return "There is no return value for this command";};
GetCommandExampleFileName()249 	virtual mystr GetCommandExampleFileName() const {return "Print.txt";};
250 
251 
252 	//execute command, 1==success, 0==failed
253 	//it is already checked, that the number of parameters is equal to the desired number of parameters
254 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
255 private:
256 };
257 
258 class CEDC_ComAddLoad: public CEDC_Command
259 {
260 public:
261 	//initialization
CEDC_ComAddLoad(int id)262 	CEDC_ComAddLoad(int id): CEDC_Command(id) {}
263 
CommandName()264 	virtual const char* CommandName() const {return "AddLoad";}
NParameters()265 	virtual int NParameters() const {return 1;}
HasReturnValue()266 	virtual int HasReturnValue() const {return 1;}
267 
268 	//execute command, 1==success, 0==failed
269 	//it is already checked, that the number of parameters is equal to the desired number of parameters
270 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
GetCommandTexDescription()271 	virtual mystr GetCommandTexDescription() const {return "Adds a load to the system. See the description of the loads above in order to get the available options. You have to adjust the value 'loads' in the element to assign the load to the element.";};
GetCommandTexParameterDescription()272 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is an ElementDataContainer with the data of the load. ATTENTION: the entry load\\_type must exist!";};
GetCommandTexReturnValueDescription()273 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value of this command is the number of the load in the MBS.";};
GetCommandExampleFileName()274 	virtual mystr GetCommandExampleFileName() const {return "AddLoad.txt";};
275 private:
276 };
277 
278 //$ DR 2012-10
279 class CEDC_ComAddSensor: public CEDC_Command
280 {
281 public:
282 	//initialization
CEDC_ComAddSensor(int id)283 	CEDC_ComAddSensor(int id): CEDC_Command(id) {}
284 
CommandName()285 	virtual const char* CommandName() const {return "AddSensor";}
NParameters()286 	virtual int NParameters() const {return 1;}
HasReturnValue()287 	virtual int HasReturnValue() const {return 1;}
288 
289 	//execute command, 1==success, 0==failed
290 	//it is already checked, that the number of parameters is equal to the desired number of parameters
291 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
GetCommandTexDescription()292 	virtual mystr GetCommandTexDescription() const {return "Adds a sensor to the system. See the description of the sensors above in order to get the available options.";};
GetCommandTexParameterDescription()293 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is an ElementDataContainer with the data of the sensor. ATTENTION: the entry sensor\\_type must exist!";};
GetCommandTexReturnValueDescription()294 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value of this command is the number of the sensor in the MBS.";};
GetCommandExampleFileName()295 	virtual mystr GetCommandExampleFileName() const {return "AddSensor.txt";};
296 private:
297 };
298 
299 //$ DR 2012-12-11:[
300 class CEDC_ComLoadSTL: public CEDC_Command
301 {
302 public:
303 	//initialization
CEDC_ComLoadSTL(int id)304 	CEDC_ComLoadSTL(int id): CEDC_Command(id) {}
305 
CommandName()306 	virtual const char* CommandName() const {return "ReadSTLFile";}
NParameters()307 	virtual int NParameters() const {return 1;}
HasReturnValue()308 	virtual int HasReturnValue() const {return 1;}
309 
310 
311 	//description for the docu
GetCommandTexDescription()312 	virtual mystr GetCommandTexDescription() const {return "This command reads a stl-mesh from a file and stores the data in an ElementDataContainer.";};
GetCommandTexParameterDescription()313 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is the absolut or relative filename.";};
GetCommandTexReturnValueDescription()314 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is an ElementDataContainer with 2 entries: triangles and points.";}
GetCommandExampleFileName()315 	virtual mystr GetCommandExampleFileName() const {return "ReadSTLFile.txt";};
316 
317 
318 	//execute command, 1==success, 0==failed
319 	//it is already checked, that the number of parameters is equal to the desired number of parameters
320 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
321 private:
322 };
323 //$ DR 2012-12-11:]
324 
325 class CEDC_ComAddMaterial: public CEDC_Command
326 {
327 public:
328 	//initialization
CEDC_ComAddMaterial(int id)329 	CEDC_ComAddMaterial(int id): CEDC_Command(id) {}
330 
CommandName()331 	virtual const char* CommandName() const {return "AddMaterial";}
NParameters()332 	virtual int NParameters() const {return 1;}
HasReturnValue()333 	virtual int HasReturnValue() const {return 1;}
334 
335 	//execute command, 1==success, 0==failed
336 	//it is already checked, that the number of parameters is equal to the desired number of parameters
337 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
GetCommandTexDescription()338 	virtual mystr GetCommandTexDescription() const {return "Adds a material to the system. See the description of the materials above in order to get the available options.";};
GetCommandTexParameterDescription()339 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is an ElementDataContainer with the data of the material. ATTENTION: the entry material\\_type must exist!";};
GetCommandTexReturnValueDescription()340 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value of this command is the number of the material in the MBS.";};
GetCommandExampleFileName()341 	virtual mystr GetCommandExampleFileName() const {return "AddMaterial.txt";};
342 private:
343 };
344 
345 //$ DR 2013-01
346 class CEDC_ComAddBeam3DProperties: public CEDC_Command
347 {
348 public:
349 	//initialization
CEDC_ComAddBeam3DProperties(int id)350 	CEDC_ComAddBeam3DProperties(int id): CEDC_Command(id) {}
351 
CommandName()352 	virtual const char* CommandName() const {return "AddBeamProperties";}
NParameters()353 	virtual int NParameters() const {return 1;}
HasReturnValue()354 	virtual int HasReturnValue() const {return 1;}
355 
356 	//execute command, 1==success, 0==failed
357 	//it is already checked, that the number of parameters is equal to the desired number of parameters
358 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
GetCommandTexDescription()359 	virtual mystr GetCommandTexDescription() const {return "Adds a BeamProperty to the system. See the description of the BeamProperties above in order to get the available options.";};
GetCommandTexParameterDescription()360 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is an ElementDataContainer with the data of the BeamProperties. ATTENTION: the entry material\\_type must exist!";};
GetCommandTexReturnValueDescription()361 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value of this command is the number of the node in the MBS.";};
GetCommandExampleFileName()362 	virtual mystr GetCommandExampleFileName() const {return "AddBeamProperties.txt";};
363 private:
364 };
365 
366 //$ DR 2013-01
367 class CEDC_ComAddNode: public CEDC_Command
368 {
369 public:
370 	//initialization
CEDC_ComAddNode(int id)371 	CEDC_ComAddNode(int id): CEDC_Command(id) {}
372 
CommandName()373 	virtual const char* CommandName() const {return "AddNode";}
NParameters()374 	virtual int NParameters() const {return 1;}
HasReturnValue()375 	virtual int HasReturnValue() const {return 1;}
376 
377 	//execute command, 1==success, 0==failed
378 	//it is already checked, that the number of parameters is equal to the desired number of parameters
379 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
GetCommandTexDescription()380 	virtual mystr GetCommandTexDescription() const {return "Adds a node to the system. See the description of the nodes above in order to get the available options.";};
GetCommandTexParameterDescription()381 	virtual mystr GetCommandTexParameterDescription() const {return "The parameter of this command is an ElementDataContainer with the data of the node. ATTENTION: the entry node\\_type must exist!";};
GetCommandTexReturnValueDescription()382 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value of this command is the number of the node in the MBS.";};
GetCommandExampleFileName()383 	virtual mystr GetCommandExampleFileName() const {return "AddNode.txt";};
384 private:
385 };
386 
387 
388 //$ DR 2013-01-30:[
389 class CEDC_ComComputeInertia: public CEDC_Command
390 {
391 public:
392 	//initialization
CEDC_ComComputeInertia(int id)393 	CEDC_ComComputeInertia(int id): CEDC_Command(id) {}
394 
CommandName()395 	virtual const char* CommandName() const {return "ComputeInertia";}
NParameters()396 	virtual int NParameters() const {return 1;}
HasReturnValue()397 	virtual int HasReturnValue() const {return 1;}
398 
399 	//description for the docu
GetCommandTexDescription()400 	virtual mystr GetCommandTexDescription() const {return "This command computes the mass, moment of inertia, volume and center of mass based on the information about the geometry and the material of a body";};
401 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()402 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is an ElementDataContainer with 4 entries: volume, mass, moment\\_of\\_inertia and center\\_of\\_mass";}
GetCommandExampleFileName()403 	virtual mystr GetCommandExampleFileName() const {return "ComputeInertia.txt";};
404 
405 
406 	//execute command, 1==success, 0==failed
407 	//it is already checked, that the number of parameters is equal to the desired number of parameters
408 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
409 private:
410 };
411 //$ DR 2013-01-30:]
412 
413 //$ DR 2013-02-19:[
414 class CEDC_ComTransformPoints: public CEDC_Command
415 {
416 public:
417 	//initialization
CEDC_ComTransformPoints(int id)418 	CEDC_ComTransformPoints(int id): CEDC_Command(id) {}
419 
CommandName()420 	virtual const char* CommandName() const {return "TransformPoints";}
NParameters()421 	virtual int NParameters() const {return 3;}
HasReturnValue()422 	virtual int HasReturnValue() const {return 1;}
423 
424 	//description for the docu
GetCommandTexDescription()425 	virtual mystr GetCommandTexDescription() const {return "With this command, the geometry described by the points can be transformed. It is possible to apply rotation and/or translation and/or scaling. The new point pN is computed according to the formula pN = trans + rot*p.";};
426 	virtual mystr GetCommandTexParameterDescription() const;
GetCommandTexReturnValueDescription()427 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is a Matrix containing the transformed points pN.";}
GetCommandExampleFileName()428 	virtual mystr GetCommandExampleFileName() const {return "TransformPoints.txt";};
429 
430 	//execute command, 1==success, 0==failed
431 	//it is already checked, that the number of parameters is equal to the desired number of parameters
432 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
433 private:
434 };
435 //$ DR 2013-02-19:]
436 
437 //$ DR 2013-07-04:[
438 class CEDC_ComLoadVecFromFile: public CEDC_Command
439 {
440 public:
441 	//initialization
CEDC_ComLoadVecFromFile(int id)442 	CEDC_ComLoadVecFromFile(int id): CEDC_Command(id) {}
443 
CommandName()444 	virtual const char* CommandName() const {return "LoadVectorFromFile";}
NParameters()445 	virtual int NParameters() const {return 2;}
HasReturnValue()446 	virtual int HasReturnValue() const {return 1;}
447 
448 	//description for the docu
GetCommandTexDescription()449 	virtual mystr GetCommandTexDescription() const {return "This command reads a vector from a file and returns this vector.";};
450 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()451 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is the vector.";}
GetCommandExampleFileName()452 	virtual mystr GetCommandExampleFileName() const {return "LoadVectorFromFile.txt";};
453 
454 	//execute command, 1==success, 0==failed
455 	//it is already checked, that the number of parameters is equal to the desired number of parameters
456 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
457 private:
458 };
459 //$ DR 2013-07-04:]
460 
461 //$ AD 2013-07-11:[
462 class CEDC_ComSum: public CEDC_Command
463 {
464 public:
465 	//initialization
CEDC_ComSum(int id)466 	CEDC_ComSum(int id): CEDC_Command(id) {}
467 
CommandName()468 	virtual const char* CommandName() const {return "Sum";}
NParameters()469 	virtual int NParameters() const {return 2;}
HasReturnValue()470 	virtual int HasReturnValue() const {return 1;}
471 
472 	//description for the docu
GetCommandTexDescription()473 	virtual mystr GetCommandTexDescription() const {return "This command adds two components of the same type ( scalar, vector or matrix ).";};
474 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()475 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is the sum of the two inputs.";}
GetCommandExampleFileName()476 	virtual mystr GetCommandExampleFileName() const {return "Add_Mult.txt";};
477 
478 	//execute command, 1==success, 0==failed
479 	//it is already checked, that the number of parameters is equal to the desired number of parameters
480 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
481 private:
482 };
483 
484 class CEDC_ComProduct: public CEDC_Command
485 {
486 public:
487 	//initialization
CEDC_ComProduct(int id)488 	CEDC_ComProduct(int id): CEDC_Command(id) {}
489 
CommandName()490 	virtual const char* CommandName() const {return "Product";}
NParameters()491 	virtual int NParameters() const {return 2;}
HasReturnValue()492 	virtual int HasReturnValue() const {return 1;}
493 
494 	//description for the docu
GetCommandTexDescription()495 	virtual mystr GetCommandTexDescription() const {return "This command multiplies two components of the type ( scalar, vector or matrix ) when the operation is defined.";};
496 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()497 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is the product of the two inputs.";}
GetCommandExampleFileName()498 	virtual mystr GetCommandExampleFileName() const {return "Add_Mult.txt";};
499 
500 	//execute command, 1==success, 0==failed
501 	//it is already checked, that the number of parameters is equal to the desired number of parameters
502 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
503 private:
504 };
505 
506 class CEDC_ComTranspose: public CEDC_Command
507 {
508 public:
509 	//initialization
CEDC_ComTranspose(int id)510 	CEDC_ComTranspose(int id): CEDC_Command(id) {}
511 
CommandName()512 	virtual const char* CommandName() const {return "Transpose";}
NParameters()513 	virtual int NParameters() const {return 1;}
HasReturnValue()514 	virtual int HasReturnValue() const {return 1;}
515 
516 	//description for the docu
GetCommandTexDescription()517 	virtual mystr GetCommandTexDescription() const {return "This command transposes a matrix or vector.";};
518 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()519 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is a matrix or a vector.";}
GetCommandExampleFileName()520 	virtual mystr GetCommandExampleFileName() const {return "Add_Mult.txt";};
521 
522 	//execute command, 1==success, 0==failed
523 	//it is already checked, that the number of parameters is equal to the desired number of parameters
524 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
525 private:
526 };
527 
528 //$! AD 2013-07-15 commented out Class Scalar product for the time being, functionality is in ComProduct...
529 ////class CEDC_ComScalarProduct: public CEDC_Command
530 ////{
531 ////public:
532 ////	//initialization
533 ////	CEDC_ComScalarProduct(int id): CEDC_Command(id) {}
534 ////
535 ////	virtual const char* CommandName() const {return "ScalarProduct";}
536 ////	virtual int NParameters() const {return 2;}
537 ////	virtual int HasReturnValue() const {return 1;}
538 ////
539 ////	//description for the docu
540 ////	virtual mystr GetCommandTexDescription() const {return "This command computes the scalar product of two vectors.";};
541 ////	virtual mystr GetCommandTexParameterDescription() const ;
542 ////	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is the scalar product.";}
543 ////	virtual mystr GetCommandExampleFileName() const {return "Add_Mult.txt";};
544 ////
545 ////	//execute command, 1==success, 0==failed
546 ////	//it is already checked, that the number of parameters is equal to the desired number of parameters
547 ////	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
548 ////private:
549 ////};
550 
551 class CEDC_ComCrossProduct: public CEDC_Command
552 {
553 public:
554 	//initialization
CEDC_ComCrossProduct(int id)555 	CEDC_ComCrossProduct(int id): CEDC_Command(id) {}
556 
CommandName()557 	virtual const char* CommandName() const {return "CrossProduct";}
NParameters()558 	virtual int NParameters() const {return 2;}
HasReturnValue()559 	virtual int HasReturnValue() const {return 1;}
560 
561 	//description for the docu
GetCommandTexDescription()562 	virtual mystr GetCommandTexDescription() const {return "This command computes the cross product of two vectors.";};
563 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()564 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is the scalar cross product.";}
GetCommandExampleFileName()565 	virtual mystr GetCommandExampleFileName() const {return "Add_Mult.txt";};
566 
567 	//execute command, 1==success, 0==failed
568 	//it is already checked, that the number of parameters is equal to the desired number of parameters
569 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
570 private:
571 };
572 //$ AD 2013-07-11:]
573 
574 //$ AD 2013-09-13:[ loop and condition
575 class CEDC_ComFor: public CEDC_Command
576 {
577 public:
578 	//initialization
CEDC_ComFor(int id)579 	CEDC_ComFor(int id): CEDC_Command(id) {}
580 
CommandName()581 	virtual const char* CommandName() const {return "for";}
NParameters()582 	virtual int NParameters() const {return 3;}
HasReturnValue()583 	virtual int HasReturnValue() const {return 1;}
GetOptions()584 	virtual int GetOptions() const {return TCO_FollowedByContainer + TCO_LeftHandSideOnly;} // the command is followed by a code block in a { } container
585 
586 	//description for the docu
GetCommandTexDescription()587 	virtual mystr GetCommandTexDescription() const {return "This command starts a FOR loop for the subsequent block.";};
588 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()589 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is the number of iterations.";}
GetCommandExampleFileName()590 	virtual mystr GetCommandExampleFileName() const {return "Loop_Cond.txt";};
591 	//execute command, 1==success, 0==failed
592 	//it is already checked, that the number of parameters is equal to the desired number of parameters
593 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
594 private:
595 };
596 
597 class CEDC_ComIf: public CEDC_Command
598 {
599 public:
600 	//initialization
CEDC_ComIf(int id)601 	CEDC_ComIf(int id): CEDC_Command(id) {}
602 
CommandName()603 	virtual const char* CommandName() const {return "if";}
NParameters()604 	virtual int NParameters() const {return 1;}
HasReturnValue()605 	virtual int HasReturnValue() const {return 1;}
GetOptions()606 	virtual int GetOptions() const {return TCO_FollowedByContainer + TCO_LeftHandSideOnly;} // the command is followed by a code block in a { } container
607 
608 	//description for the docu
GetCommandTexDescription()609 	virtual mystr GetCommandTexDescription() const {return "This command evaluates an IF condition for the subsequent block.";};
610 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()611 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is the 1 for true and 0 for false.";}
GetCommandExampleFileName()612 	virtual mystr GetCommandExampleFileName() const {return "Loop_Cond.txt";};
613 	//execute command, 1==success, 0==failed
614 	//it is already checked, that the number of parameters is equal to the desired number of parameters
615 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
616 private:
617 };
618 //$ AD 2013-09-13:]
619 
620 //$ AD 2013-10-09:[ functions to generate specific handles
621 class CEDC_ComMesh_GenerateNewMesh: public CEDC_Command
622 {
623 public:
624 	//initialization
CEDC_ComMesh_GenerateNewMesh(int id)625 	CEDC_ComMesh_GenerateNewMesh(int id): CEDC_Command(id) {}
626 
CommandName()627 	virtual const char* CommandName() const {return "GenerateNewMesh";}
NParameters()628 	virtual int NParameters() const {return 1;}
HasReturnValue()629 	virtual int HasReturnValue() const {return 1;}
630 
631 	//description for the docu
GetCommandTexDescription()632 	virtual mystr GetCommandTexDescription() const {return "This command generates a Handle to a Mesh Object for further operations.";};
633 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()634 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is a special EDC (Handle) that must be assigned to a new variable.";}
GetCommandExampleFileName()635 	virtual mystr GetCommandExampleFileName() const {return "Mesh.txt";};
636 	//execute command, 1==success, 0==failed
637 	//it is already checked, that the number of parameters is equal to the desired number of parameters
638 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
639 private:
640 };
641 //$ AD 2013-10-09:]
642 
643 //$ AD 2013-10-09:[ Mesh commands
644 class CEDC_ComMesh_GenerateBeam: public CEDC_Command
645 {
646 public:
647 	//initialization
CEDC_ComMesh_GenerateBeam(int id)648 	CEDC_ComMesh_GenerateBeam(int id): CEDC_Command(id) {}
649 
CommandName()650 	virtual const char* CommandName() const {return "GenerateBeam";}
NParameters()651 	virtual int NParameters() const {return 1;}
HasReturnValue()652 	virtual int HasReturnValue() const {return 1;}
GetOptions()653 	virtual int GetOptions() const {return TCO_RequiresHandle;}
654 
655 	//description for the docu
GetCommandTexDescription()656 	virtual mystr GetCommandTexDescription() const {return "This command generates a Beam within a Mesh Object.";};
657 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()658 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is a list of element numbers for the newly generated beam elements.";}
GetCommandExampleFileName()659 	virtual mystr GetCommandExampleFileName() const {return "Mesh.txt";};
660 	//execute command, 1==success, 0==failed
661 	//it is already checked, that the number of parameters is equal to the desired number of parameters
662 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
663 private:
664 };
665 
666 class CEDC_ComMesh_GeneratePlate: public CEDC_Command
667 {
668 public:
669 	//initialization
CEDC_ComMesh_GeneratePlate(int id)670 	CEDC_ComMesh_GeneratePlate(int id): CEDC_Command(id) {}
671 
CommandName()672 	virtual const char* CommandName() const {return "GeneratePlate";}
NParameters()673 	virtual int NParameters() const {return 1;}
HasReturnValue()674 	virtual int HasReturnValue() const {return 1;}
GetOptions()675 	virtual int GetOptions() const {return TCO_RequiresHandle;}
676 
677 	//description for the docu
GetCommandTexDescription()678 	virtual mystr GetCommandTexDescription() const {return "This command generates a Plate within a Mesh Object.";};
679 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()680 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is a list of element numbers for the newly generated plate elements.";}
GetCommandExampleFileName()681 	virtual mystr GetCommandExampleFileName() const {return "Mesh.txt";};
682 	//execute command, 1==success, 0==failed
683 	//it is already checked, that the number of parameters is equal to the desired number of parameters
684 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
685 private:
686 };
687 
688 class CEDC_ComMesh_GetNodesInBox: public CEDC_Command
689 {
690 public:
691 	//initialization
CEDC_ComMesh_GetNodesInBox(int id)692 	CEDC_ComMesh_GetNodesInBox(int id): CEDC_Command(id) {}
693 
CommandName()694 	virtual const char* CommandName() const {return "GetNodesInBox";}
NParameters()695 	virtual int NParameters() const {return 1;}
HasReturnValue()696 	virtual int HasReturnValue() const {return 1;}
GetOptions()697 	virtual int GetOptions() const {return TCO_RequiresHandle;}
698 
699 	//description for the docu
GetCommandTexDescription()700 	virtual mystr GetCommandTexDescription() const {return "This command returns a list of nodes (registered to the mesh) in a given box.";};
701 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()702 	virtual mystr GetCommandTexReturnValueDescription() const {return "The return value is a list of node numbers.";}
GetCommandExampleFileName()703 	virtual mystr GetCommandExampleFileName() const {return "Mesh.txt";};
704 	//execute command, 1==success, 0==failed
705 	//it is already checked, that the number of parameters is equal to the desired number of parameters
706 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
707 private:
708 };
709 
710 class CEDC_ComMesh_GlueMesh: public CEDC_Command
711 {
712 	public:
713 	//initialization
CEDC_ComMesh_GlueMesh(int id)714 	CEDC_ComMesh_GlueMesh(int id): CEDC_Command(id) {}
715 
CommandName()716 	virtual const char* CommandName() const {return "GlueMesh";}
NParameters()717 	virtual int NParameters() const {return 1;}
HasReturnValue()718 	virtual int HasReturnValue() const {return 1;}
GetOptions()719 	virtual int GetOptions() const {return TCO_RequiresHandle;}
720 
721 	//description for the docu
GetCommandTexDescription()722 	virtual mystr GetCommandTexDescription() const {return "This command glues mesh together.";};
GetCommandTexParameterDescription()723 	virtual mystr GetCommandTexParameterDescription() const {return "TODO.";};
GetCommandTexReturnValueDescription()724 	virtual mystr GetCommandTexReturnValueDescription() const {return "TODO.";}
GetCommandExampleFileName()725 	virtual mystr GetCommandExampleFileName() const {return "Mesh.txt";};
726 	//execute command, 1==success, 0==failed
727 	//it is already checked, that the number of parameters is equal to the desired number of parameters
728 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
729 private:
730 };
731 //$ AD 2013-10-09:]
732 
733 //$ AD 2013-11-27: command to determine if a specific
734 class CEDC_Check_Entry_Exists: public CEDC_Command
735 {
736 	public:
737 	//initialization
CEDC_Check_Entry_Exists(int id)738 	CEDC_Check_Entry_Exists(int id): CEDC_Command(id) {}
CommandName()739 	virtual const char* CommandName() const {return "DoesEntryExist";}
NParameters()740 	virtual int NParameters() const {return 1;}
HasReturnValue()741 	virtual int HasReturnValue() const {return 1;}
GetOptions()742 	virtual int GetOptions() const {return TCO_None;}
743 
744 	//description for the docu
GetCommandTexDescription()745 	virtual mystr GetCommandTexDescription() const {return "This command glues mesh together.";};
746 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()747 	virtual mystr GetCommandTexReturnValueDescription() const {return "returns 0 if the entry does not exist, returns 1 if the entry exists.";}
GetCommandExampleFileName()748 	virtual mystr GetCommandExampleFileName() const {return "Mesh.txt";};
749 	//execute command, 1==success, 0==failed
750 	//it is already checked, that the number of parameters is equal to the desired number of parameters
751 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
752 private:
753 };
754 
755 //$ AD 2013-12-13: command compare strings - could be used for other comparisons as well
756 class CEDC_Compare: public CEDC_Command
757 {
758 	public:
759 	//initialization
CEDC_Compare(int id)760 	CEDC_Compare(int id): CEDC_Command(id) {}
CommandName()761 	virtual const char* CommandName() const {return "Compare";}
NParameters()762 	virtual int NParameters() const {return 2;}
HasReturnValue()763 	virtual int HasReturnValue() const {return 1;}
GetOptions()764 	virtual int GetOptions() const {return TCO_None;}
765 
766 	//description for the docu
GetCommandTexDescription()767 	virtual mystr GetCommandTexDescription() const {return "This command compares two strings.";};
768 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()769 	virtual mystr GetCommandTexReturnValueDescription() const {return "returns 0 if both strings are identical, returns >0 or <0 otherwise indicating which string has higher value .";}
GetCommandExampleFileName()770 	virtual mystr GetCommandExampleFileName() const {return "strings.txt";};
771 	//execute command, 1==success, 0==failed
772 	//it is already checked, that the number of parameters is equal to the desired number of parameters
773 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
774 private:
775 };
776 
777 //$ AD 2013-12-13: command concatinate strings
778 class CEDC_StrCat: public CEDC_Command
779 {
780 	public:
781 	//initialization
CEDC_StrCat(int id)782 	CEDC_StrCat(int id): CEDC_Command(id) {}
CommandName()783 	virtual const char* CommandName() const {return "StrCat";}
NParameters()784 	virtual int NParameters() const {return 2;}
HasReturnValue()785 	virtual int HasReturnValue() const {return 1;}
GetOptions()786 	virtual int GetOptions() const {return TCO_None;}
787 
788 	//description for the docu
GetCommandTexDescription()789 	virtual mystr GetCommandTexDescription() const {return "This command joins two strings together";};
790 	virtual mystr GetCommandTexParameterDescription() const ;
GetCommandTexReturnValueDescription()791 	virtual mystr GetCommandTexReturnValueDescription() const {return "returns a single string - strA+strB.";}
GetCommandExampleFileName()792 	virtual mystr GetCommandExampleFileName() const {return "strings.txt";};
793 	//execute command, 1==success, 0==failed
794 	//it is already checked, that the number of parameters is equal to the desired number of parameters
795 	virtual int ExecuteCommand(MBS * mbs, CEDCParser * edcParser, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
796 private:
797 };
798 
799 
800 class CEDCParser
801 {
802 public:
803 	//initialize parser
804 	//CEDCParser(MBS * mbs);
CEDCParser()805 	CEDCParser(): commands(), class_names(), class_descriptions()
806 	{
807  		mbs = NULL;
808 		Initialize();
809 	};
810 
811 	//$ YV 2012-12-30: expression parser is also stored as a member here
SetMBS(MBS * mbs,CMBSParser * mbsParser)812 	virtual void SetMBS(MBS * mbs, CMBSParser * mbsParser)
813 	{
814 		this->mbs = mbs;
815 		this->mbsParser = mbsParser;
816 	}
GetMBS()817 	virtual const MBS * GetMBS() const {return mbs;}
GetMBS()818 	virtual MBS* GetMBS() {return mbs;}
819 
820 	virtual void Initialize();
821 
822 	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
823 	//auxiliary functions:
824 	virtual int ReadComment(mystr& str, int& pos, ElementData& ed, const mystr& dataname); //read comment at end of statement into ElementData
825 	virtual int ReadBoolIntDoubleExpression(mystr& text, int& pos, ElementData& ed, const mystr& elemname); //read expression containing bool (yes/no), int/double or a mathematical expression
826 	virtual int ReadMatrixVector(const mystr& text, ElementData& ed, const mystr& elemname, const mystr& dataname); //read structure in [] containing matrix or vector
827 	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
828 
EDCError(const mystr & str)829 	virtual void EDCError(const mystr& str) {mbs->UO(UO_LVL_err) << "EDC Parser error: '" << str << "' at line " << line_cnt << "\n";}
EDCWarning(const mystr & str)830 	virtual void EDCWarning(const mystr& str) {mbs->UO(UO_LVL_err) << "EDC Parser warning: '" << str << "' at line " << line_cnt << "\n";}
831 
832 	virtual int MakeFilenameAbsolute(mystr& filename);	// checks if filename has relative path, and if yes, converts it into an absolute one. returns 1 if success
833 	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
834 	//commands, set up all possible commands:
InitializeCommands()835 	virtual void InitializeCommands()
836 	{
837 		//add all EDC-commands manually here!
838 		int comcnt = 0;
839 
840 		for(int i=1; i<=commands.Length(); i++) {delete commands(i);}	//$ DR 2012-10: clear array, because this function is called several times
841 		commands.Flush();
842 
843 		CEDC_ComAddElement* cae = new CEDC_ComAddElement(++comcnt);
844 		commands.Add(cae);
845 
846 		CEDC_ComAddGeomElement* cage = new CEDC_ComAddGeomElement(++comcnt);
847 		commands.Add(cage);
848 
849 		CEDC_ComAddConstraint* cac = new CEDC_ComAddConstraint(++comcnt);		//$ DR 2012-08
850 		commands.Add(cac);
851 
852 		CEDC_ComAddLoad* cal = new CEDC_ComAddLoad(++comcnt);		//$ DR 2012-10
853 		commands.Add(cal);
854 
855 		CEDC_ComAddSensor* cas = new CEDC_ComAddSensor(++comcnt);		//$ DR 2012-10
856 		commands.Add(cas);
857 
858 		CEDC_ComAddMaterial* cam = new CEDC_ComAddMaterial(++comcnt);		//$ DR+PG 2012-12
859 		commands.Add(cam);
860 
861 		CEDC_ComAddBeam3DProperties* cabp = new CEDC_ComAddBeam3DProperties(++comcnt);		//$ DR+PG 2012-12
862 		commands.Add(cabp);
863 
864 		CEDC_ComAddNode* can = new CEDC_ComAddNode(++comcnt);			//$ DR 2013-01
865 		commands.Add(can);
866 
867 		CEDC_ComInclude* caincl = new CEDC_ComInclude(++comcnt);
868 		commands.Add(caincl);
869 
870 		CEDC_ComPrint* cpr = new CEDC_ComPrint(++comcnt);		//$ DR 2012-11
871 		commands.Add(cpr);
872 
873 		CEDC_ComLoadSTL* clstl = new CEDC_ComLoadSTL(++comcnt);		//$ DR 2012-12
874 		commands.Add(clstl);
875 
876 		CEDC_ComLoadVecFromFile* clvff = new CEDC_ComLoadVecFromFile(++comcnt);			//$ DR 2013-07
877 		commands.Add(clvff);
878 
879 		CEDC_ComTransformPoints* ctp = new CEDC_ComTransformPoints(++comcnt);		//$ DR 2013-02-19
880 		commands.Add(ctp);
881 
882 		CEDC_ComComputeInertia* cci = new CEDC_ComComputeInertia(++comcnt);			//$ DR 2013-01
883 		commands.Add(cci);
884 
885 		CEDC_ComSum* cs = new CEDC_ComSum(++comcnt);			//$ AD 2013-07
886 		commands.Add(cs);
887 
888 		CEDC_ComProduct* cp = new CEDC_ComProduct(++comcnt);    //$ AD 2013-07
889 		commands.Add(cp);
890 
891 		CEDC_ComTranspose* ct = new CEDC_ComTranspose(++comcnt);    //$ AD 2013-07
892 		commands.Add(ct);
893 
894 		//CEDC_ComScalarProduct* csp = new CEDC_ComScalarProduct(++comcnt);    //$ AD 2013-07
895 		//commands.Add(csp);
896 
897 		CEDC_ComCrossProduct* ccp = new CEDC_ComCrossProduct(++comcnt);    //$ AD 2013-07
898 		commands.Add(ccp);
899 
900 		CEDC_ComFor* cfor = new CEDC_ComFor(++comcnt);    //$ AD 2013-09
901 		commands.Add(cfor);
902 
903 		CEDC_ComIf* cif = new CEDC_ComIf(++comcnt);    //$ AD 2013-09
904 		commands.Add(cif);
905 
906 		CEDC_ComMesh_GenerateNewMesh* cmgmesh = new CEDC_ComMesh_GenerateNewMesh(++comcnt);    //$ AD 2013-09
907 		commands.Add(cmgmesh);
908 
909 		CEDC_ComMesh_GenerateBeam* cmgbeam = new CEDC_ComMesh_GenerateBeam(++comcnt);    //$ AD 2013-09
910 		commands.Add(cmgbeam);
911 
912 		CEDC_ComMesh_GeneratePlate* cmgplate = new CEDC_ComMesh_GeneratePlate(++comcnt);    //$ AD 2013-10
913 		commands.Add(cmgplate);
914 
915 		CEDC_ComMesh_GetNodesInBox* cmgetnodes = new CEDC_ComMesh_GetNodesInBox(++comcnt);    //$ AD 2013-10
916 		commands.Add(cmgetnodes);
917 
918 		CEDC_ComMesh_GlueMesh* cmgluemesh = new CEDC_ComMesh_GlueMesh(++comcnt);    //$ AD 2013-10
919 		commands.Add(cmgluemesh);
920 
921 		CEDC_Check_Entry_Exists* cmentryexists = new CEDC_Check_Entry_Exists(++comcnt);    //$ AD 2013-11
922 		commands.Add(cmentryexists);
923 
924 		CEDC_Compare* cmcompare = new CEDC_Compare(++comcnt);    //$ AD 2013-12
925 		commands.Add(cmcompare);
926 
927 		CEDC_StrCat* cmstrcat = new CEDC_StrCat(++comcnt);    //$ AD 2013-12
928 		commands.Add(cmstrcat);
929 
930 	};
931 
932 	//get the command type_id from the command_name; also provide the number of parameters and optional flags for the command
933 	//return 0, if failed
GetCommandType(const mystr & command_name,int & n_parameters,int & has_return_value,int & option)934 	virtual int GetCommandType(const mystr& command_name, int& n_parameters, int& has_return_value, int& option)
935 	{
936 		n_parameters = 0;
937 		has_return_value = 0;
938 		option = 0;
939 		for (int i=1; i <= commands.Length(); i++)
940 		{
941 			if (mystr(commands(i)->CommandName()) == command_name) //==>STringCMP would be more efficient
942 			{
943 				n_parameters = commands(i)->NParameters();
944 				has_return_value = commands(i)->HasReturnValue();
945 				option = commands(i)->GetOptions();
946 				return i;
947 			}
948 		}
949 		return 0;
950 	}
951 
GetCommandTypeName(int i)952 	virtual mystr GetCommandTypeName(int i) const {return mystr(commands(i)->CommandName());}
NCommands()953 	virtual int NCommands() const {return commands.Length();}
GetCommand(int i)954 	virtual CEDC_Command* GetCommand(int i) const {return commands(i);}
955 
956 // AD 2013-10-16: single call for commands - collect code from String2TreeEDC and ReadBoolIntDoubleExpression - returns "com_id" (including 0 for no command) or "-1" on error
957 	virtual int IdentifyAndExecuteCommand(mystr& dataname, mystr& str, int& pos, ElementData& return_value, int flag_RHS = 0);
958 
959 // AD 2013-10-16: identifies command type and checks restrictions - returns "com_id" (including 0 for no command) or "-1" on error
960 	virtual int IdentifyCommand(mystr& dataname, int& n_params, int& has_return_value, int& option, int flag_RHS );
961 
962 // AD 2013-10-16: parses parameters into EDCs - returns "1" on success and "0" on error
963 	virtual int ParseCommandParameter(TArray<ElementDataContainer*>& parameter_EDCs, mystr& dataname, int n_params, mystr& str, int& pos, int option);
964 
965 //execute a command with type_id, a list of EDCs for command parameters and an option
966 	virtual int ExecuteCommand(int command_type_id, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
967 
968 // AD 2013-10-16: perform a check for the datafile version (once)
969 	virtual int HotintDataFileVersionCheck(int& version_check_performed, ElementDataContainer& edc_version);
970 
971 
972 
973 
974 	//get TArray<ElementDataContainer*> of comma-separated parameter sets for a command
975 	virtual int GetParameterEDC(mystr text, TArray<ElementDataContainer*>& parameter_EDCs);
976 	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
977 
978 	//main EDC parsing functions:
979 	//transform edc into string, works already for TreeEDCs!
980 	virtual void EDC2String(const ElementDataContainer& edc, mystr& str, const mystr& indent = "");
981 	//virtual void EDC2TexTable(const ElementDataContainer& edc, mystr& str, const mystr& indent = "", const mystr& treename = ""); //$ DR 2013-01-11 moved to models_auto_documentation
982 
983 	//transforms string into edc until a keyword is read, returns remaining string:
984 	virtual int String2EDC(/*MBS * mbs, */mystr& str, ElementDataContainer& edc, ElementDataContainer& testedc);
985 
986 	////////transforms a string automatically into a tree edc; only accepts: double, string (""), vector, matrix
987 	//////virtual int String2TreeEDC(/*MBS * mbs, */mystr str, ElementDataContainer& edc);
988 	////////recursive version of string to TreeEDC conversion
989 	//////virtual int String2TreeEDC_recursive(mystr str, ElementDataContainer& edc);
990 
991   // AD 2013-09-24: these functions parses a string ans applies it ENTRY BY ENTRY to the target element data container
992 	virtual int ParseAndExecuteString(mystr str, ElementDataContainer& edc);
993 	virtual int ParseAndExecuteString_recursive(mystr str, ElementDataContainer& edc);
994 	//virtual int AddReplaceSingleEntry(ElementData& entryED, ElementDataContainer& targetEDC);
995 
DPOV()996 	virtual Default_ParserObjectValues& DPOV() {return dpov;}
DPOV()997 	virtual const Default_ParserObjectValues& DPOV() const {return dpov;}
998 
999 	// DR 2013-01-14: this function evaluates a command of the parser, using the parameter_EDC as additional input data
1000 	// AD 2013-10-16: remark: can be called from .cpp model for a) testing new script function, b) use existing script routines
1001 	virtual int ExecuteParserCommand(mystr & command, TArray<ElementDataContainer*>& parameter_EDCs, ElementData& return_value, int option);
1002 
1003 	// +++++++++++++ the classs descriptions are not used at the moment +++++++++++++++++++++++	DR 2013-01-11
1004 	//virtual void AddClassDescriptions_Auto();
1005 	//add a class name with a description to the parser
AddClassDescription(const mystr & name,const mystr & description)1006 	virtual void AddClassDescription(const mystr& name, const mystr& description)
1007 	{
1008 		class_names.Add(name);
1009 		class_descriptions.Add(description);
1010 	}
1011 	//get a description for a certain class name
GetClassDescription(const mystr & name)1012 	virtual mystr GetClassDescription(const mystr& name)
1013 	{
1014 		for (int i=1; i <= class_names.Length(); i++)
1015 		{
1016 			if (name == mystr(class_names(i))) return mystr(class_descriptions(i));
1017 		}
1018 		return "";
1019 	}
1020 	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1021 
PrintOutput()1022  	virtual bool PrintOutput() {
1023  		bool val = oo;
1024  		if (mbs)
1025  		{
1026  			if (mbs->GetOptions()->LoggingOptions()->EDCParserGeneralInformation() == 1)
1027  			{
1028  				val = true;
1029  			}
1030  			else
1031  			{
1032  				val = false;
1033  			}
1034  		}
1035 
1036  		return val;
1037  	}
1038 
1039 public:
GetObjectFactory()1040 	MBSObjectFactoryInterface * GetObjectFactory() { return pObjectFactory; }
SetObjectFactory(MBSObjectFactoryInterface * pObjectFactory)1041 	void SetObjectFactory(MBSObjectFactoryInterface * pObjectFactory) { this->pObjectFactory = pObjectFactory; }
1042 
1043 public:
GetMBSParser()1044 	CMBSParser* GetMBSParser() { return mbsParser; }
1045 
1046 private:
1047 	MBS * mbs;
1048 	CMBSParser * mbsParser;
1049 	MBSObjectFactoryInterface * pObjectFactory;		// a pointer to the instance in the models and elements module
1050 
1051 	Default_ParserObjectValues dpov; //default parser object values
1052 
1053   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1054 	//commands:
1055 	TArray<CEDC_Command*> commands;
1056   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1057 
1058 	//$ DR 2013-01-11 not used at the moment:
1059 	MyStrList class_names, class_descriptions; //this are two lists, which provide a detailed .tex based description for a single class
1060 
1061 	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1062 	//definitions of characters for parsing:
1063 	mystr el; //end of line
1064 	char elc;
1065 	char obc;  //open brace, for sub structure
1066 	char cbc;  //closing brace
1067 	mystr ob;
1068 	mystr cb;
1069 	char ofc;  //open function (round '(') bracket
1070 	char cfc;  //close function (round ')') bracket
1071 	mystr of;
1072 	mystr cf;
1073 	char osbc;  //open square bracket, for vector or matrix
1074 	char csbc;  //closing square bracket
1075 	mystr osb;  //open square bracket, for vector or matrix
1076 	mystr csb;  //closing square bracket
1077 	mystr ds;	//double stop - not used any more
1078 	mystr eq;		//equal sign
1079 	mystr semicolon; //double stop
1080 	char semicolonc; //double stop
1081 	char commac; //comma
1082 	mystr comma; //comma
1083 	char doublequote; //for strings or text
1084 	char dotc; //dot
1085 	mystr dot; //dot
1086 	mystr space; //space
1087 	char spacec;
1088 	char tabc;
1089 	mystr tab;
1090 	mystr bool_yes;
1091 	mystr bool_no;
1092 
1093 	char commentc; //comment
1094 	mystr comment; //comment
1095 	mystr matrixsep; //may be changed to semicolon ...
1096 
1097   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1098 	//other variables and switches:
1099 	int line_cnt; //line counter in EDC
1100 	int total_lines; //total number of lines in string
1101 	int oo; //turn on / off detailed output
1102 
1103 	int version_check_performed;    // flag to perform a version check when first command is encountered
1104 
LoadError(const mystr & str)1105 	void LoadError(const mystr& str) {mbs->UO() << "Error in load file: " << str.c_str() << "\n";}
1106 };
1107 #endif
1108