1 |
tim |
1232 |
#ifndef _CONSTRAINTALGORITHM_H_ |
2 |
|
|
#define _CONSTRAINTALGORITHM_H_ |
3 |
|
|
|
4 |
|
|
#include <iostream> |
5 |
|
|
#include <map> |
6 |
|
|
#include "CallbackFunctor.hpp" |
7 |
|
|
#include "TypeInfo.hpp" |
8 |
|
|
#include "ConstraintIterator.hpp" |
9 |
|
|
using namespace std; |
10 |
|
|
|
11 |
|
|
class ConstraintManager; |
12 |
|
|
class ConstraintPair; |
13 |
|
|
class JointConstraintPair; |
14 |
|
|
class DistanceConstraintPair; |
15 |
|
|
class SimInfo; |
16 |
|
|
|
17 |
tim |
1248 |
enum ConsAlgoStatus{ |
18 |
|
|
consPairHandlerFail = -3, |
19 |
|
|
consElemHandlerFail = -2, |
20 |
|
|
consFail = -1, |
21 |
|
|
consSuccess = 0, |
22 |
|
|
consAlready = 1}; |
23 |
tim |
1232 |
|
24 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
25 |
|
|
//Declaration of ConstraintAlgorithm |
26 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
27 |
|
|
//base class of constraint algorithm |
28 |
|
|
//Actuallly we encount a triple dispatch problem here, something like |
29 |
|
|
//ConstrainPair(ConsPairType*, ConsElementType1*, ConsElementType2*) |
30 |
|
|
//To solve this problem, we apply visitor pattern and standard double dispatch technique |
31 |
|
|
class ConstraintAlgorithm{ |
32 |
|
|
|
33 |
|
|
public: |
34 |
|
|
~ConstraintAlgorithm(); |
35 |
|
|
virtual void doConstrain(); |
36 |
|
|
|
37 |
|
|
//using RTTI (Run Time Type Information) to dispatch |
38 |
|
|
int doConstrainPair(ConstraintPair* consPair); |
39 |
|
|
void registerCallback(const TypeInfo& ti, CallbackFunctor* functor); |
40 |
|
|
void unRegister(TypeInfo& ti); |
41 |
tim |
1248 |
bool haveError() { return error;} |
42 |
tim |
1232 |
protected: |
43 |
|
|
ConstraintAlgorithm(SimInfo* rhs); |
44 |
|
|
|
45 |
|
|
SimInfo* info; |
46 |
|
|
ConstraintPairIterator* cpIter; |
47 |
|
|
ConstraintElementIterator* ceIter; |
48 |
|
|
|
49 |
|
|
map<TypeInfo, CallbackFunctor*> callbackMap; |
50 |
tim |
1248 |
|
51 |
|
|
bool error; |
52 |
tim |
1232 |
}; |
53 |
|
|
|
54 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
55 |
|
|
//Declaration of ConsAlgoFramework |
56 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
57 |
|
|
class ConsAlgoFramework{ |
58 |
|
|
public: |
59 |
|
|
~ConsAlgoFramework(); |
60 |
|
|
|
61 |
|
|
void doPreConstraint(); |
62 |
|
|
|
63 |
|
|
protected: |
64 |
|
|
ConsAlgoFramework(SimInfo* rhs); |
65 |
|
|
|
66 |
|
|
private: |
67 |
|
|
ConstraintElementIterator* ceIter; |
68 |
|
|
|
69 |
|
|
}; |
70 |
|
|
|
71 |
|
|
#endif //endif _CONSTRAINTALGORITHM_H_ |