1 |
#ifndef __STUNTDOUBLE_HPP__ |
2 |
#define __STUNTDOUBLE_HPP__ |
3 |
|
4 |
#include <map> |
5 |
#include "GenericData.hpp" |
6 |
|
7 |
#define OT_ATOM 0 |
8 |
#define OT_DATOM 1 |
9 |
#define OT_RIGIDBODY 2 |
10 |
|
11 |
using namespace std; |
12 |
class BaseVisitor; |
13 |
|
14 |
|
15 |
enum StorageMethod {smRotation, smQuaternion}; |
16 |
|
17 |
class StuntDouble { |
18 |
public: |
19 |
virtual ~StuntDouble(); |
20 |
|
21 |
int getObjType(); |
22 |
|
23 |
bool isAtom(){ |
24 |
return objType == OT_ATOM || objType == OT_DATOM; |
25 |
} |
26 |
|
27 |
bool isDirectionalAtom(){ |
28 |
return objType == OT_DATOM; |
29 |
} |
30 |
|
31 |
bool isRigidBody(){ |
32 |
return objType == OT_RIGIDBODY; |
33 |
} |
34 |
|
35 |
bool isDirectional(){ |
36 |
return isDirectionalAtom() || isRigidBody(); |
37 |
} |
38 |
|
39 |
virtual double getMass(void); |
40 |
|
41 |
virtual void getPos(double pos[3]); |
42 |
virtual void setPos(double pos[3]); |
43 |
|
44 |
virtual void getVel(double vel[3]); |
45 |
virtual void setVel(double vel[3]); |
46 |
|
47 |
virtual void getFrc(double frc[3]); |
48 |
virtual void setFrc(double frc[3]); |
49 |
virtual void addFrc(double frc[3]); |
50 |
|
51 |
virtual void getA(double A[3][3]); |
52 |
virtual void setA(double A[3][3]); |
53 |
|
54 |
virtual void getJ(double j[3]); |
55 |
virtual void setJ(double j[3]); |
56 |
|
57 |
virtual void getQ( double q[4] ); // get the quanternions |
58 |
virtual void setQ( double q[4] ); |
59 |
|
60 |
virtual void setType(char* type) = 0; |
61 |
virtual char* getType() = 0; |
62 |
|
63 |
|
64 |
virtual void getTrq(double trq[3]); |
65 |
virtual void setTrq(double trq[3]); |
66 |
virtual void addTrq(double trq[3]); |
67 |
|
68 |
virtual void getI(double I[3][3]); |
69 |
virtual void lab2Body(double vec[3]); |
70 |
|
71 |
virtual void getGrad(double grad[6]); |
72 |
virtual void setEuler(double phi, double theta, double psi); |
73 |
virtual void getEulerAngles(double eulers[3]); |
74 |
|
75 |
virtual bool isLinear() {return false;} |
76 |
virtual int linearAxis() {return -1;} |
77 |
|
78 |
virtual double getZangle(); |
79 |
virtual void setZangle(double zAngle); |
80 |
virtual void addZangle(double zAngle); |
81 |
|
82 |
virtual void accept(BaseVisitor* v) = 0; |
83 |
|
84 |
void addProperty(GenericData* data); |
85 |
void removeProperty(const string& propName); |
86 |
GenericData* getProperty(const string& propName); |
87 |
|
88 |
StorageMethod getStorageMethd(){return stMethod;} |
89 |
void setStorageMethod(StorageMethod method) {stMethod = method;} |
90 |
|
91 |
protected: |
92 |
StuntDouble(){} |
93 |
|
94 |
//prevent default copy constructor copy information from properties which will cause problem |
95 |
StuntDouble(const StuntDouble& sd){ |
96 |
objType = sd.objType; |
97 |
} |
98 |
|
99 |
int objType; |
100 |
|
101 |
map<string, GenericData*> properties; |
102 |
|
103 |
StorageMethod stMethod; |
104 |
//static int numGetQ = 0; |
105 |
//static int numGetA = 0; |
106 |
}; |
107 |
|
108 |
#endif |