| 1 |
#ifndef _RATTLE_H_
|
| 2 |
#define _RATTLE_H_ |
| 3 |
|
| 4 |
#include "Shake.hpp" |
| 5 |
#include "ConstraintPair.hpp"
|
| 6 |
|
| 7 |
//Rattle Constraint Algorithn
|
| 8 |
//Reference
|
| 9 |
//H.C. Andersen, J. Comput. Phys. 54, 24(1983)
|
| 10 |
//RattleA and Shake are identical |
| 11 |
typedef Shake RattleA; |
| 12 |
|
| 13 |
////////////////////////////////////////////////////////////////////////////////
|
| 14 |
//Declaration of DCRattleBFunctor
|
| 15 |
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
class DCRattleBFunctor : public CallbackFunctor{
|
| 17 |
public:
|
| 18 |
DCRattleBFunctor(SimInfo* rhs) : CallbackFunctor(rhs){}
|
| 19 |
protected:
|
| 20 |
virtual int operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2);
|
| 21 |
virtual int operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB);
|
| 22 |
virtual int operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2);
|
| 23 |
}; |
| 24 |
|
| 25 |
////////////////////////////////////////////////////////////////////////////////
|
| 26 |
//Declaration of JCRattleBFunctor
|
| 27 |
////////////////////////////////////////////////////////////////////////////////
|
| 28 |
class JCRattleBFunctor : public CallbackFunctor{
|
| 29 |
public:
|
| 30 |
JCRattleBFunctor(SimInfo* rhs) : CallbackFunctor(rhs){}
|
| 31 |
protected:
|
| 32 |
virtual int operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2);
|
| 33 |
virtual int operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB);
|
| 34 |
virtual int operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2);
|
| 35 |
};
|
| 36 |
|
| 37 |
////////////////////////////////////////////////////////////////////////////////
|
| 38 |
//Declaration of RattleB
|
| 39 |
////////////////////////////////////////////////////////////////////////////////
|
| 40 |
class RattleB : public ConstraintAlgorithm{ |
| 41 |
public:
|
| 42 |
RattleB(SimInfo* rhs) : ConstraintAlgorithm(rhs){
|
| 43 |
registerCallback(typeid(DistanceConstraintPair), new DCRattleBFunctor(rhs));
|
| 44 |
registerCallback(typeid(JointConstraintPair), new JCRattleBFunctor(rhs));
|
| 45 |
}
|
| 46 |
};
|
| 47 |
|
| 48 |
////////////////////////////////////////////////////////////////////////////////
|
| 49 |
//Declaration of RattleAlgorithm
|
| 50 |
////////////////////////////////////////////////////////////////////////////////
|
| 51 |
//class RattleAlgorithm will encapsulate preConstraint, RattleA and RattleB
|
| 52 |
class RattleFramework : public ConsAlgoFramework{
|
| 53 |
public:
|
| 54 |
RattleFramework(SimInfo* rhs) : ConsAlgoFramework(rhs){
|
| 55 |
raAlgo = new RattleA(rhs);
|
| 56 |
rbAlgo = new RattleB(rhs);
|
| 57 |
}
|
| 58 |
|
| 59 |
~RattleFramework(){
|
| 60 |
delete raAlgo;
|
| 61 |
delete rbAlgo;
|
| 62 |
}
|
| 63 |
|
| 64 |
void doRattleA(){
|
| 65 |
raAlgo->doConstrain();
|
| 66 |
}
|
| 67 |
|
| 68 |
void doRattleB(){
|
| 69 |
rbAlgo->doConstrain();
|
| 70 |
}
|
| 71 |
private:
|
| 72 |
RattleA* raAlgo;
|
| 73 |
RattleB* rbAlgo;
|
| 74 |
};
|
| 75 |
#endif //ifndef _RATTLE_H_ |