AnimatLab  2
Test
VsClassFactory.cpp
1 // VsClassFactory.cpp: implementation of the VsClassFactory class.
2 //
4 
5 #include "StdAfx.h"
6 #include "VsClassFactory.h"
7 
8 #include "VsConstraintRelaxation.h"
9 #include "VsConstraintFriction.h"
10 #include "VsMovableItem.h"
11 #include "VsBody.h"
12 #include "VsJoint.h"
13 #include "VsMotorizedJoint.h"
14 #include "VsRigidBody.h"
15 #include "VsPlane.h"
16 #include "VsPlaneTest.h"
17 #include "VsBox.h"
18 #include "VsBoxTest.h"
19 #include "VsCylinder.h"
20 #include "VsCone.h"
21 #include "VsSphere.h"
22 #include "VsTorus.h"
23 #include "VsEllipsoid.h"
24 #include "VsMouth.h"
25 #include "VsOdorSensor.h"
26 #include "VsFluidPlane.H"
27 #include "VsMeshBase.h"
28 #include "VsMesh.h"
29 #include "VsTerrain.h"
30 
31 #include "VsHinge.h"
32 #include "VsPrismatic.h"
33 #include "VsBallSocket.h"
34 #include "VsRPRO.h"
35 #include "VsUniversal.h"
36 #include "VsFreeJoint.h"
37 #include "VsDistanceJoint.h"
38 
39 #include "VsAttachment.h"
40 
41 #include "VsLine.h"
42 #include "VsLinearHillMuscle.h"
43 #include "VsLinearHillStretchReceptor.h"
44 #include "VsSpring.h"
45 
46 #include "VsOrganism.h"
47 #include "VsStructure.h"
48 #include "VsSimulator.h"
49 
50 #include "VsMaterialType.h"
51 
52 //#include "VsVideoKeyFrame.h"
53 //#include "VsSnapshotKeyFrame.h"
54 
56 #include "VsForceStimulus.h"
57 //#include "VsInverseMuscleCurrent.h"
58 
59 #include "VsHudText.h"
60 #include "VsHud.h"
61 #include "VsSimulationWindow.h"
62 #include "VsScriptedSimulationWindow.h"
63 #include "VsDragger.h"
64 
65 #include "VsLight.h"
66 
67 namespace VortexAnimatSim
68 {
69 
71 // Construction/Destruction
73 
74 VsClassFactory::VsClassFactory()
75 {
76 
77 }
78 
79 VsClassFactory::~VsClassFactory()
80 {
81 
82 }
83 
84 // ************* Body Type Conversion functions ******************************
85 
86 RigidBody *VsClassFactory::CreateRigidBody(std::string strType, bool bThrowError)
87 {
88  RigidBody *lpPart=NULL;
89 
90 try
91 {
92  strType = Std_ToUpper(Std_Trim(strType));
93 
94  if(strType == "BOX")
95  lpPart = new VsBox;
96  else if(strType == "BOXTEST")
97  lpPart = new VsBoxTest;
98  else if(strType == "BOXCONTACTSENSOR")
99  {
100  lpPart = new VsBox;
101  lpPart->IsContactSensor(true);
102  }
103  else if(strType == "CYLINDER")
104  lpPart = new VsCylinder;
105  else if(strType == "CYLINDERCONTACTSENSOR")
106  {
107  lpPart = new VsCylinder;
108  lpPart->IsContactSensor(true);
109  }
110  else if(strType == "CONE")
111  lpPart = new VsCone;
112  else if(strType == "SPHERE")
113  lpPart = new VsSphere;
114  else if(strType == "PLANE")
115  lpPart = new VsPlane;
116  else if(strType == "PLANETEST")
117  lpPart = new VsPlaneTest;
118  else if(strType == "ATTACHMENT")
119  lpPart = new VsAttachment;
120  else if(strType == "LINEARHILLMUSCLE")
121  lpPart = new VsLinearHillMuscle;
122  else if(strType == "LINEARHILLSTRETCHRECEPTOR")
123  lpPart = new VsLinearHillStretchReceptor;
124  else if(strType == "SPRING")
125  lpPart = new VsSpring;
126  else if(strType == "TORUS")
127  lpPart = new VsTorus;
128  else if(strType == "ELLIPSOID")
129  lpPart = new VsEllipsoid;
130  else if(strType == "MOUTH")
131  lpPart = new VsMouth;
132  else if(strType == "ODORSENSOR")
133  lpPart = new VsOdorSensor;
134  else if(strType == "FLUIDPLANE")
135  lpPart = new VsFluidPlane;
136  else if(strType == "TERRAIN")
137  lpPart = new VsTerrain;
138  else if(strType == "MESH")
139  lpPart = new VsMesh;
140  else if(strType == "STOMACH")
141  lpPart = new Stomach;
142  else
143  {
144  lpPart = NULL;
145  if(bThrowError)
146  THROW_PARAM_ERROR(Al_Err_lInvalidPartType, Al_Err_strInvalidPartType, "PartType", strType);
147  }
148 
149  return lpPart;
150 }
151 catch(CStdErrorInfo oError)
152 {
153  if(lpPart) delete lpPart;
154  RELAY_ERROR(oError);
155  return NULL;
156 }
157 catch(...)
158 {
159  if(lpPart) delete lpPart;
160  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
161  return NULL;
162 }
163 }
164 
165 // ************* Body Type Conversion functions ******************************
166 
167 
168 // ************* Body Joint Conversion functions ******************************
169 
170 Joint *VsClassFactory::CreateJoint(std::string strType, bool bThrowError)
171 {
172  Joint *lpJoint=NULL;
173 
174 try
175 {
176  strType = Std_ToUpper(Std_Trim(strType));
177 
178  if(strType == "HINGE")
179  lpJoint = new VsHinge;
180  else if(strType == "PRISMATIC")
181  lpJoint = new VsPrismatic;
182  else if(strType == "BALLSOCKET")
183  lpJoint = new VsBallSocket;
184  else if(strType == "RPRO")
185  lpJoint = new VsRPRO;
186  else if(strType == "STATIC")
187  lpJoint = NULL;
188  else if(strType == "UNIVERSAL")
189  lpJoint = new VsUniversal;
190  else if(strType == "FREEJOINT")
191  lpJoint = new VsFreeJoint;
192  else if(strType == "DISTANCE")
193  lpJoint = new VsDistanceJoint;
194  else
195  {
196  lpJoint = NULL;
197  if(bThrowError)
198  THROW_PARAM_ERROR(Al_Err_lInvalidJointType, Al_Err_strInvalidJointType, "JointType", strType);
199  }
200 
201  return lpJoint;
202 }
203 catch(CStdErrorInfo oError)
204 {
205  if(lpJoint) delete lpJoint;
206  RELAY_ERROR(oError);
207  return NULL;
208 }
209 catch(...)
210 {
211  if(lpJoint) delete lpJoint;
212  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
213  return NULL;
214 }
215 }
216 
217 // ************* Body Joint Conversion functions ******************************
218 
219 // ************* Organism Type Conversion functions ******************************
220 
221 Structure *VsClassFactory::CreateStructure(std::string strType, bool bThrowError)
222 {
223  Structure *lpStructure=NULL;
224 
225 try
226 {
227  strType = Std_ToUpper(Std_Trim(strType));
228 
229  if(strType == "BASIC")
230  lpStructure = new VsOrganism;
231  else if(strType == "ORGANISM")
232  lpStructure = new VsOrganism;
233  else if(strType == "STRUCTURE")
234  lpStructure = new VsStructure;
235  else
236  {
237  lpStructure = NULL;
238  if(bThrowError)
239  THROW_PARAM_ERROR(Al_Err_lInvalidOrganismType, Al_Err_strInvalidOrganismType, "OrganismType", strType);
240  }
241 
242  return lpStructure;
243 }
244 catch(CStdErrorInfo oError)
245 {
246  if(lpStructure) delete lpStructure;
247  RELAY_ERROR(oError);
248  return NULL;
249 }
250 catch(...)
251 {
252  if(lpStructure) delete lpStructure;
253  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
254  return NULL;
255 }
256 }
257 
258 // ************* Organism Type Conversion functions ******************************
259 
260 
261 // ************* Simulator Type Conversion functions ******************************
262 
263 Simulator *VsClassFactory::CreateSimulator(std::string strType, bool bThrowError)
264 {
265  Simulator *lpSimulator=NULL;
266 
267 try
268 {
269  strType = Std_ToUpper(Std_Trim(strType));
270 
271  if(strType == "VORTEXSIMULATOR")
272  lpSimulator = new VsSimulator;
273  else if(strType == "")
274  lpSimulator = new VsSimulator;
275  else
276  {
277  lpSimulator = NULL;
278  if(bThrowError)
279  THROW_PARAM_ERROR(Al_Err_lInvalidSimulatorType, Al_Err_strInvalidSimulatorType, "SimulatorType", strType);
280  }
281 
282  return lpSimulator;
283 }
284 catch(CStdErrorInfo oError)
285 {
286  if(lpSimulator) delete lpSimulator;
287  RELAY_ERROR(oError);
288  return NULL;
289 }
290 catch(...)
291 {
292  if(lpSimulator) delete lpSimulator;
293  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
294  return NULL;
295 }
296 }
297 
298 // ************* Organism Type Conversion functions ******************************
299 
300 
301 
302 // ************* KeyFrame Type Conversion functions ******************************
303 KeyFrame *VsClassFactory::CreateKeyFrame(std::string strType, bool bThrowError)
304 {
305  KeyFrame *lpFrame=NULL;
306 
307 try
308 {
309 // strType = Std_ToUpper(Std_Trim(strType));
310 //
311 // if(strType == "VIDEO")
312 // lpFrame = new VsVideoKeyFrame;
313 // else if(strType == "SNAPSHOT")
314 // lpFrame = new VsSnapshotKeyFrame;
315 // else
316 // {
317 // lpFrame = NULL;
318 // if(bThrowError)
319 // THROW_PARAM_ERROR(Al_Err_lInvalidKeyFrameType, Al_Err_strInvalidKeyFrameType, "KeyFrameType", strType);
320 // }
321 
322  return lpFrame;
323 }
324 catch(CStdErrorInfo oError)
325 {
326  if(lpFrame) delete lpFrame;
327  RELAY_ERROR(oError);
328  return NULL;
329 }
330 catch(...)
331 {
332  if(lpFrame) delete lpFrame;
333  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
334  return NULL;
335 }
336 }
337 
338 // ************* KeyFrame Type Conversion functions ******************************
339 
340 
341 // ************* DataChart Type Conversion functions ******************************
342 
343 DataChart *VsClassFactory::CreateDataChart(std::string strType, bool bThrowError)
344 {
345  DataChart *lpChart=NULL;
346 
347 try
348 {
349  strType = Std_ToUpper(Std_Trim(strType));
350 
351  if(strType == "TABFILE")
352  lpChart = new FileChart;
353  else if(strType == "FILECHART")
354  lpChart = new FileChart;
355  else if(strType == "MEMORYCHART")
356  lpChart = new MemoryChart;
357  else if(strType == "ARRAYCHART")
358  lpChart = new ArrayChart;
359  else
360  {
361  lpChart = NULL;
362  if(bThrowError)
363  THROW_PARAM_ERROR(Al_Err_lInvalidDataChartType, Al_Err_strInvalidDataChartType, "DataChartType", strType);
364  }
365 
366  return lpChart;
367 }
368 catch(CStdErrorInfo oError)
369 {
370  if(lpChart) delete lpChart;
371  RELAY_ERROR(oError);
372  return NULL;
373 }
374 catch(...)
375 {
376  if(lpChart) delete lpChart;
377  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
378  return NULL;
379 }
380 }
381 // ************* DataChart Type Conversion functions ******************************
382 
383 
384 // ************* DataColumn Type Conversion functions ******************************
385 
386 DataColumn *VsClassFactory::CreateDataColumn(std::string strType, bool bThrowError)
387 {
388  DataColumn *lpColumn=NULL;
389 
390 try
391 {
392  strType = Std_ToUpper(Std_Trim(strType));
393 
394  if(strType == "DATACOLUMN")
395  lpColumn = new DataColumn;
396  //else if(strType == "RIGIDBODYDATA")
397  // lpColumn = new RigidBodyDataColumn;
398  //else if(strType == "JOINTDATA")
399  // lpColumn = new JointDataColumn;
400  //else if(strType == "STIMULUSDATA")
401  // lpColumn = new StimulusDataColumn;
402  else
403  {
404  lpColumn = NULL;
405  if(bThrowError)
406  THROW_PARAM_ERROR(Al_Err_lInvalidDataColumnType, Al_Err_strInvalidDataColumnType, "DataColumnType", strType);
407  }
408 
409  return lpColumn;
410 }
411 catch(CStdErrorInfo oError)
412 {
413  if(lpColumn) delete lpColumn;
414  RELAY_ERROR(oError);
415  return NULL;
416 }
417 catch(...)
418 {
419  if(lpColumn) delete lpColumn;
420  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
421  return NULL;
422 }
423 }
424 
425 // ************* DataColumn Type Conversion functions ******************************
426 
427 
428 // ************* Adapter Type Conversion functions ******************************
429 
430 Adapter *VsClassFactory::CreateAdapter(std::string strType, bool bThrowError)
431 {
432  Adapter *lpAdapter=NULL;
433 
434 try
435 {
436  strType = Std_ToUpper(Std_Trim(strType));
437 
438  if(strType == "NODETONODE")
439  lpAdapter = new Adapter;
440  else if(strType == "NODETOPHYSICAL")
441  lpAdapter = new Adapter;
442  else if(strType == "PHYSICALTONODE")
443  lpAdapter = new Adapter;
444  else if(strType == "CONTACT")
445  lpAdapter = new ContactAdapter;
446  else if(strType == "PROPERTYCONTROLADAPTER")
447  lpAdapter = new PropertyControlAdapter;
448  else
449  {
450  lpAdapter = NULL;
451  if(bThrowError)
452  THROW_PARAM_ERROR(Al_Err_lInvalidAdapterType, Al_Err_strInvalidAdapterType, "AdapterType", strType);
453  }
454 
455  return lpAdapter;
456 }
457 catch(CStdErrorInfo oError)
458 {
459  if(lpAdapter) delete lpAdapter;
460  RELAY_ERROR(oError);
461  return NULL;
462 }
463 catch(...)
464 {
465  if(lpAdapter) delete lpAdapter;
466  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
467  return NULL;
468 }
469 }
470 
471 // ************* Adpater Type Conversion functions ******************************
472 
473 
474 // ************* Gain Type Conversion functions ******************************
475 
476 Gain *VsClassFactory::CreateGain(std::string strType, bool bThrowError)
477 {
478  Gain *lpGain=NULL;
479 
480 try
481 {
482  strType = Std_ToUpper(Std_Trim(strType));
483 
484  if(strType == "BELL")
485  lpGain = new BellGain;
486  else if(strType == "EQUATION")
487  lpGain = new EquationGain;
488  else if(strType == "POLYNOMIAL")
489  lpGain = new PolynomialGain;
490  else if(strType == "SIGMOID")
491  lpGain = new SigmoidGain;
492  else
493  {
494  lpGain = NULL;
495  if(bThrowError)
496  THROW_PARAM_ERROR(Al_Err_lInvalidGainType, Al_Err_strInvalidGainType, "GainType", strType);
497  }
498 
499  return lpGain;
500 }
501 catch(CStdErrorInfo oError)
502 {
503  if(lpGain) delete lpGain;
504  RELAY_ERROR(oError);
505  return NULL;
506 }
507 catch(...)
508 {
509  if(lpGain) delete lpGain;
510  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
511  return NULL;
512 }
513 }
514 
515 // ************* Adpater Type Conversion functions ******************************
516 
517 
518 // ************* External Stimulus Type Conversion functions ******************************
519 
520 ExternalStimulus *VsClassFactory::CreateExternalStimulus(std::string strType, bool bThrowError)
521 {
522  ExternalStimulus *lpStimulus=NULL;
523 
524 try
525 {
526  strType = Std_ToUpper(Std_Trim(strType));
527 
528  if(strType == "MOTORVELOCITY" || strType == "MOTORPOSITION")
529  lpStimulus = new VsMotorVelocityStimulus;
530  else if(strType == "FORCEINPUT")
531  lpStimulus = new VsForceStimulus;
532  else if(strType == "NODEINPUT")
533  lpStimulus = new ExternalInputStimulus;
534  else if(strType == "RIGIDBODYINPUT")
535  lpStimulus = new ExternalInputStimulus;
536  else if(strType == "JOINTINPUT")
537  lpStimulus = new ExternalInputStimulus;
538  else if(strType == "ENABLERINPUT")
539  lpStimulus = new EnablerStimulus;
540  else if(strType == "INVERSEMUSCLECURRENT")
541  lpStimulus = new InverseMuscleCurrent;
542  else if(strType == "CURRENT")
544  else if(strType == "VOLTAGECLAMP")
546  else if(strType == "PROPERTYCONTROLSTIMULUS")
548  else
549  {
550  lpStimulus = NULL;
551  if(bThrowError)
552  THROW_PARAM_ERROR(Al_Err_lInvalidExternalStimulusType, Al_Err_strInvalidExternalStimulusType, "ExternalStimulusType", strType);
553  }
554 
555  return lpStimulus;
556 }
557 catch(CStdErrorInfo oError)
558 {
559  if(lpStimulus) delete lpStimulus;
560  RELAY_ERROR(oError);
561  return NULL;
562 }
563 catch(...)
564 {
565  if(lpStimulus) delete lpStimulus;
566  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
567  return NULL;
568 }
569 }
570 
571 // ************* External Stimulus Type Conversion functions ******************************
572 
573 
574 // ************* Hud Item Type Conversion functions ******************************
575 
576 HudItem *VsClassFactory::CreateHudItem(std::string strType, bool bThrowError)
577 {
578  HudItem *lpItem=NULL;
579 
580 try
581 {
582  strType = Std_ToUpper(Std_Trim(strType));
583 
584  if(strType == "HUDTEXT")
585  lpItem = new VsHudText;
586  else
587  {
588  lpItem = NULL;
589  if(bThrowError)
590  THROW_PARAM_ERROR(Vs_Err_lInvalidHudItemType, Vs_Err_strInvalidHudItemType, "HudItem", strType);
591  }
592 
593  return lpItem;
594 }
595 catch(CStdErrorInfo oError)
596 {
597  if(lpItem) delete lpItem;
598  RELAY_ERROR(oError);
599  return NULL;
600 }
601 catch(...)
602 {
603  if(lpItem) delete lpItem;
604  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
605  return NULL;
606 }
607 }
608 
609 // ************* Hud Item Type Conversion functions ******************************
610 
611 // ************* Hud Type Conversion functions ******************************
612 
613 Hud *VsClassFactory::CreateHud(std::string strType, bool bThrowError)
614 {
615  Hud *lpHud=NULL;
616 
617 try
618 {
619  strType = Std_ToUpper(Std_Trim(strType));
620 
621  if(strType == "HUD")
622  lpHud = new VsHud;
623  else
624  {
625  lpHud = NULL;
626  if(bThrowError)
627  THROW_PARAM_ERROR(Vs_Err_lInvalidHudItemType, Vs_Err_strInvalidHudItemType, "Hud", strType);
628  }
629 
630  return lpHud;
631 }
632 catch(CStdErrorInfo oError)
633 {
634  if(lpHud) delete lpHud;
635  RELAY_ERROR(oError);
636  return NULL;
637 }
638 catch(...)
639 {
640  if(lpHud) delete lpHud;
641  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
642  return NULL;
643 }
644 }
645 
646 // ************* Hud Item Type Conversion functions ******************************
647 //
648 // ************* Material Type Conversion functions ******************************
649 
650 MaterialType *VsClassFactory::CreateMaterialItem(std::string strType, bool bThrowError)
651 {
652  MaterialType *lpItem=NULL;
653 
654 try
655 {
656  strType = Std_ToUpper(Std_Trim(strType));
657 
658  if(strType == "BASIC" || strType == "DEFAULT"|| strType == "VORTEX")
659  lpItem = new VsMaterialType;
660  else
661  {
662  lpItem = NULL;
663  if(bThrowError)
664  THROW_PARAM_ERROR(Vs_Err_lInvalidMaterialItemType, Vs_Err_strInvalidMaterialItemType, "Material Pair", strType);
665  }
666 
667  return lpItem;
668 }
669 catch(CStdErrorInfo oError)
670 {
671  if(lpItem) delete lpItem;
672  RELAY_ERROR(oError);
673  return NULL;
674 }
675 catch(...)
676 {
677  if(lpItem) delete lpItem;
678  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
679  return NULL;
680 }
681 }
682 
683 // ************* Material Type Conversion functions ******************************
684 
685 // ************* Material Type Conversion functions ******************************
686 
687 SimulationWindow *VsClassFactory::CreateWindowItem(std::string strType, bool bThrowError)
688 {
689  SimulationWindow *lpItem=NULL;
690 
691 try
692 {
693  strType = Std_ToUpper(Std_Trim(strType));
694 
695  if(strType == "BASIC" || strType == "DEFAULT")
696  lpItem = new VsSimulationWindow;
697  else if(strType == "SCRIPTEDSIMWINDOW")
698  lpItem = new VsScriptedSimulationWindow;
699  else
700  {
701  lpItem = NULL;
702  if(bThrowError)
703  THROW_PARAM_ERROR(Vs_Err_lInvalidSimWindowType, Vs_Err_strInvalidSimWindowType, "Simulation Window", strType);
704  }
705 
706  return lpItem;
707 }
708 catch(CStdErrorInfo oError)
709 {
710  if(lpItem) delete lpItem;
711  RELAY_ERROR(oError);
712  return NULL;
713 }
714 catch(...)
715 {
716  if(lpItem) delete lpItem;
717  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
718  return NULL;
719 }
720 }
721 
722 // ************* Material Type Conversion functions ******************************
723 
724 // ************* Light Conversion functions ******************************
725 
726 Light *VsClassFactory::CreateLight(std::string strType, bool bThrowError)
727 {
728  Light *lpItem=NULL;
729 
730 try
731 {
732  strType = Std_ToUpper(Std_Trim(strType));
733 
734  if(strType == "LIGHT")
735  lpItem = new VsLight;
736  else
737  {
738  lpItem = NULL;
739  if(bThrowError)
740  THROW_PARAM_ERROR(Vs_Err_lInvalidLightType, Vs_Err_strInvalidLightType, "Light Type", strType);
741  }
742 
743  return lpItem;
744 }
745 catch(CStdErrorInfo oError)
746 {
747  if(lpItem) delete lpItem;
748  RELAY_ERROR(oError);
749  return NULL;
750 }
751 catch(...)
752 {
753  if(lpItem) delete lpItem;
754  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
755  return NULL;
756 }
757 }
758 
759 // ************* Light Conversion functions ******************************
760 
761 // ************* External Neural Module Conversion functions ******************************
762 
763 NeuralModule *VsClassFactory::CreateNeuralModule(std::string strType, bool bThrowError)
764 {
765  NeuralModule *lpModule=NULL;
766 
767 try
768 {
769  strType = Std_ToUpper(Std_Trim(strType));
770 
771  if(strType == "PHYSICSNEURALMODULE")
772  {
774  lpModule->ClassFactory(new VsClassFactory());
775  }
776  else
777  {
778  lpModule = NULL;
779  if(bThrowError)
780  THROW_PARAM_ERROR(Al_Err_lInvalidNeuralModuleType, Al_Err_strInvalidNeuralModuleType, "NeuralModule", strType);
781  }
782 
783  return lpModule;
784 }
785 catch(CStdErrorInfo oError)
786 {
787  if(lpModule) delete lpModule;
788  RELAY_ERROR(oError);
789  return NULL;
790 }
791 catch(...)
792 {
793  if(lpModule) delete lpModule;
794  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
795  return NULL;
796 }
797 }
798 
799 
800 // ************* Neural Module Type Conversion functions ******************************
801 
802 // ************* Constraint Relaxation Conversion functions ******************************
803 
804 ConstraintRelaxation *VsClassFactory::CreateConstraintRelaxation(std::string strType, bool bThrowError)
805 {
806  ConstraintRelaxation *lpRelax=NULL;
807 
808 try
809 {
810  strType = Std_ToUpper(Std_Trim(strType));
811 
812  if(strType == "CONSTRAINTRELAXATION" || strType == "DEFAULT")
813  {
814  lpRelax = new VsConstraintRelaxation;
815  }
816  else
817  {
818  lpRelax = NULL;
819  if(bThrowError)
820  THROW_PARAM_ERROR(Al_Err_lInvalidRelaxationType, Al_Err_strInvalidRelaxationType, "Relaxation", strType);
821  }
822 
823  return lpRelax;
824 }
825 catch(CStdErrorInfo oError)
826 {
827  if(lpRelax) delete lpRelax;
828  RELAY_ERROR(oError);
829  return NULL;
830 }
831 catch(...)
832 {
833  if(lpRelax) delete lpRelax;
834  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
835  return NULL;
836 }
837 }
838 
839 
840 // ************* Constraint Relaxation Type Conversion functions ******************************
841 
842 // ************* Constraint Friction Conversion functions ******************************
843 
844 ConstraintFriction *VsClassFactory::CreateConstraintFriction(std::string strType, bool bThrowError)
845 {
846  ConstraintFriction *lpFriction=NULL;
847 
848 try
849 {
850  strType = Std_ToUpper(Std_Trim(strType));
851 
852  if(strType == "CONSTRAINTRELAXATION" || strType == "DEFAULT")
853  {
854  lpFriction = new VsConstraintFriction;
855  }
856  else
857  {
858  lpFriction = NULL;
859  if(bThrowError)
860  THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType, "Friction", strType);
861  }
862 
863  return lpFriction;
864 }
865 catch(CStdErrorInfo oError)
866 {
867  if(lpFriction) delete lpFriction;
868  RELAY_ERROR(oError);
869  return NULL;
870 }
871 catch(...)
872 {
873  if(lpFriction) delete lpFriction;
874  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
875  return NULL;
876 }
877 }
878 
879 
880 // ************* Constraint Friction Type Conversion functions ******************************
881 
882 // ************* RemoteControlLinkage Conversion functions ******************************
883 
884 RemoteControlLinkage *VsClassFactory::CreateRemoteControlLinkage(std::string strType, bool bThrowError)
885 {
886  RemoteControlLinkage *lpLink=NULL;
887 
888 try
889 {
890  strType = Std_ToUpper(Std_Trim(strType));
891 
892  if(strType == "PASSTHROUGHLINKAGE")
893  {
894  lpLink = new PassThroughLinkage;
895  }
896  else if(strType == "PULSEDLINKAGE")
897  {
898  lpLink = new PulsedLinkage;
899  }
900  else
901  {
902  lpLink = NULL;
903  if(bThrowError)
904  THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType, "Friction", strType);
905  }
906 
907  return lpLink;
908 }
909 catch(CStdErrorInfo oError)
910 {
911  if(lpLink) delete lpLink;
912  RELAY_ERROR(oError);
913  return NULL;
914 }
915 catch(...)
916 {
917  if(lpLink) delete lpLink;
918  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
919  return NULL;
920 }
921 }
922 
923 
924 // ************* RemoteControlLinkage Type Conversion functions ******************************
925 
926 
927 // ************* IStdClassFactory functions ******************************
928 
929 CStdSerialize *VsClassFactory::CreateObject(std::string strClassType, std::string strObjectType, bool bThrowError)
930 {
931  CStdSerialize *lpObject=NULL;
932 
933  strClassType = Std_ToUpper(Std_Trim(strClassType));
934 
935  if(strClassType == "RIGIDBODY")
936  lpObject = CreateRigidBody(strObjectType, bThrowError);
937  else if(strClassType == "JOINT")
938  lpObject = CreateJoint(strObjectType, bThrowError);
939  else if(strClassType == "ORGANISM")
940  lpObject = CreateStructure(strObjectType, bThrowError);
941  else if(strClassType == "STRUCTURE")
942  lpObject = CreateStructure(strObjectType, bThrowError);
943  else if(strClassType == "SIMULATOR")
944  lpObject = CreateSimulator(strObjectType, bThrowError);
945  else if(strClassType == "KEYFRAME")
946  lpObject = CreateKeyFrame(strObjectType, bThrowError);
947  else if(strClassType == "DATACHART")
948  lpObject = CreateDataChart(strObjectType, bThrowError);
949  else if(strClassType == "DATACOLUMN")
950  lpObject = CreateDataColumn(strObjectType, bThrowError);
951  else if(strClassType == "EXTERNALSTIMULUS")
952  lpObject = CreateExternalStimulus(strObjectType, bThrowError);
953  else if(strClassType == "ADAPTER")
954  lpObject = CreateAdapter(strObjectType, bThrowError);
955  else if(strClassType == "GAIN")
956  lpObject = CreateGain(strObjectType, bThrowError);
957  else if(strClassType == "HUDITEM")
958  lpObject = CreateHudItem(strObjectType, bThrowError);
959  else if(strClassType == "HUD")
960  lpObject = CreateHud(strObjectType, bThrowError);
961  else if(strClassType == "MATERIAL")
962  lpObject = CreateMaterialItem(strObjectType, bThrowError);
963  else if(strClassType == "SIMULATIONWINDOW")
964  lpObject = CreateWindowItem(strObjectType, bThrowError);
965  else if(strClassType == "LIGHT")
966  lpObject = CreateLight(strObjectType, bThrowError);
967  else if(strClassType == "NEURALMODULE")
968  lpObject = CreateNeuralModule(strObjectType, bThrowError);
969  else if(strClassType == "CONSTRAINTRELAXATION")
970  lpObject = CreateConstraintRelaxation(strObjectType, bThrowError);
971  else if(strClassType == "CONSTRAINTFRICTION")
972  lpObject = CreateConstraintFriction(strObjectType, bThrowError);
973  else if(strClassType == "REMOTECONTROLLINKAGE")
974  lpObject = CreateRemoteControlLinkage(strObjectType, bThrowError);
975  else
976  {
977  lpObject = NULL;
978  if(bThrowError)
979  THROW_PARAM_ERROR(Std_Err_lInvalidClassType, Std_Err_strInvalidClassType, "ClassType", strClassType);
980  }
981 
982  return lpObject;
983 }
984 // ************* IStdClassFactory functions ******************************
985 
986 
987 
988 } //VortexAnimatSim
989 
990 extern "C" __declspec(dllexport) IStdClassFactory* __cdecl GetStdClassFactory()
991 {
992  IStdClassFactory *lpFactory = new VsClassFactory;
993  return lpFactory;
994 }
995 
996 extern "C" __declspec(dllexport) int __cdecl BootstrapRunLibrary(int argc, const char **argv)
997 {
998  Simulator *lpSim = NULL;
999 
1000 try
1001 {
1002  Simulator *lpSim = Simulator::CreateSimulator(argc, argv);
1003 
1004  lpSim->Load();
1005  lpSim->Initialize(argc, argv);
1006  lpSim->VisualSelectionMode(SIMULATION_SELECTION_MODE);
1007  lpSim->Simulate();
1008 
1009  if(lpSim) delete lpSim;
1010 
1011  return 0;
1012 }
1013 catch(CStdErrorInfo oError)
1014 {
1015  if(lpSim) delete lpSim;
1016  printf("Error occurred: %s\n", oError.m_strError) ;
1017  return (int) oError.m_lError;
1018 }
1019 catch(...)
1020 {
1021  if(lpSim) delete lpSim;
1022  printf("An Unknown Error occurred.\n") ;
1023  return -1;
1024 }
1025 }
1026 
Declares the vs prismatic class.
virtual IStdClassFactory * ClassFactory()
Gets the class factory.
Declares the vortex heads-up display class.
Vortex physical structure implementation.
Definition: VsLight.h:25
Declares the vortex relative position, relative orientation class.
Declares the vortex Torus class.
Declares the vortex fluid plane class.
Declares the vortex heads-up display text class.
Vortex physical structure implementation.
Definition: VsStructure.h:25
Declares the vortex organism class.
Vortex ball-and-socket joint class.
Definition: VsBallSocket.h:29
std::string Std_Trim(std::string strVal)
Trims a string.
Declares the vortex mouth class.
Declares the vortex odor sensor class.
Declares the vortex plane class.
Declares the vs motor velocity stimulus class.
Vortex Organism implementation.
Definition: VsOrganism.h:20
Declares the vs universal class.
Current stimulus for neural items.
This stimulus enables or disables a joint or body part for a specified period of time.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
Declares the vortex ellipsoid class.
Declares the vortex hinge class.
virtual bool IsContactSensor()
Query if this object is contact sensor.
Definition: RigidBody.cpp:448
Declares the vortex distance joint class.
Declares the vortex plane class.
Vortex relative position, relative orientation joint class.
Definition: VsRPRO.h:23
Declares the vortex Light class.
Vortex hinge joint class.
Definition: VsHinge.h:36
Declares the vortex ball socket class.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
Declares the vortex structure class.