# | Line 3 | Line 3 | |
---|---|---|
3 | ||
4 | #include "RigidBody.hpp" | |
5 | #include "Atom.hpp" | |
6 | + | #include "Vector3d.hpp" |
7 | ||
8 | ||
9 | + | class Vector3dData : public GenericData{ |
10 | + | public: |
11 | + | Vector3d getData() {return vec;} |
12 | + | void setData(const Vector3d& rhs) { vec = rhs;} |
13 | + | private: |
14 | + | Vector3d vec; |
15 | + | |
16 | + | }; |
17 | + | |
18 | //class ConstraintElement is designed to not only provide the interface of StuntDouble, but also | |
19 | //neccessary functionality to retrieve old position, old velocity and etc. | |
20 | //First of all, those old data should be stored inside StuntDouble. We decide to store it on StuntDouble's | |
# | Line 62 | Line 72 | class ConstraintElement{ | |
72 | void setZangle(double zAngle) {refSd->setZangle(zAngle);} | |
73 | void addZangle(double zAngle) {refSd->addZangle(zAngle);} | |
74 | ||
75 | + | StuntDouble* getStuntDouble() {return refSd;} |
76 | ||
77 | virtual void getOldPos(double pos[3])=0; | |
78 | virtual void getOldVel(double vel[3])=0; | |
# | Line 75 | Line 86 | class ConstraintElement{ | |
86 | bool getMoving() {return movingData->getData();} | |
87 | void setMoving(bool status) {movingData->setData(status);} | |
88 | ||
89 | + | //constraint force |
90 | + | void addConsForce(const Vector3d& frc){ |
91 | + | Vector3d tempFrc; |
92 | + | tempFrc = consForceData->getData(); |
93 | + | tempFrc += frc; |
94 | + | consForceData->setData(tempFrc); |
95 | + | } |
96 | + | Vector3d getConsForce() { return consForceData->getData();} |
97 | + | void setConsTorque(const Vector3d& frc) {consForceData->setData(frc);} |
98 | + | |
99 | + | |
100 | + | //constraint torque |
101 | + | void addConsTorque(const Vector3d& trq){ |
102 | + | Vector3d tempTrq; |
103 | + | tempTrq = consTorqueData->getData(); |
104 | + | tempTrq += trq; |
105 | + | consTorqueData->setData(tempTrq); |
106 | + | } |
107 | + | Vector3d getConsTorque() { return consTorqueData->getData();} |
108 | + | void setConsForce(const Vector3d& trq) {consTorqueData->setData(trq);} |
109 | + | |
110 | + | |
111 | virtual void saveOldState() = 0; | |
112 | ||
113 | protected: | |
# | Line 85 | Line 118 | class ConstraintElement{ | |
118 | private: | |
119 | BoolData* movedData; | |
120 | BoolData* movingData; | |
121 | < | |
121 | > | Vector3dData* consForceData; |
122 | > | Vector3dData* consTorqueData; |
123 | }; | |
124 | ||
125 | ||
# | Line 98 | Line 132 | struct ConsAtomInfo{ | |
132 | double a[3][3]; | |
133 | double j[3]; | |
134 | double q[4]; | |
135 | + | double frc[3]; |
136 | + | double trq[3]; |
137 | }; | |
138 | ||
139 | class ConsAtomData : public GenericData{ | |
# | Line 180 | Line 216 | class ConstraintRigidBody : public ConstraintElement{ | |
216 | ||
217 | void getOldAtomPos(double pos[3]) {oldRb->getAtomPos(pos, consAtomIndex);} | |
218 | void getCurAtomPos(double pos[3]) {((RigidBody*)refSd)->getAtomPos(pos, consAtomIndex);} | |
219 | < | |
219 | > | |
220 | > | void getOldAtomVel(double vel[3]) {oldRb->getAtomVel(vel, consAtomIndex);}; |
221 | > | void getCurAtomVel(double vel[3]) {((RigidBody*)refSd)->getAtomVel(vel, consAtomIndex);}; |
222 | > | |
223 | > | void getRefCoor(double pos[3]) {return ((RigidBody*)refSd)->getAtomRefCoor(pos, consAtomIndex);} |
224 | RigidBody* getRigidBody() { return dynamic_cast<RigidBody*>(refSd);} | |
225 | ||
226 | virtual void saveOldState(); | |
227 | + | |
228 | + | void restoreUnconsStatus(); |
229 | + | |
230 | ||
231 | private: | |
232 | int consAtomIndex; | |
233 | RigidBody* oldRb; | |
234 | + | |
235 | }; | |
236 | #endif // endif _CONSTRAINTELEMENT_H_ |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |