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