1 |
tim |
1232 |
#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 |
tim |
1248 |
int doRattleA(){
|
65 |
tim |
1232 |
raAlgo->doConstrain();
|
66 |
tim |
1248 |
return raAlgo->haveError()? -1 : 1;
|
67 |
|
|
|
68 |
tim |
1232 |
}
|
69 |
|
|
|
70 |
tim |
1248 |
int doRattleB(){
|
71 |
tim |
1232 |
rbAlgo->doConstrain();
|
72 |
tim |
1248 |
return rbAlgo->haveError()? -1 : 1;
|
73 |
|
|
|
74 |
tim |
1232 |
}
|
75 |
|
|
private:
|
76 |
|
|
RattleA* raAlgo;
|
77 |
|
|
RattleB* rbAlgo;
|
78 |
|
|
};
|
79 |
|
|
#endif //ifndef _RATTLE_H_ |