# | Line 2 | Line 2 | |
---|---|---|
2 | #include "ConstraintPair.hpp" | |
3 | #include "SimInfo.hpp" | |
4 | #include "ConstraintManager.hpp" | |
5 | + | #include "simError.h" |
6 | ||
7 | //////////////////////////////////////////////////////////////////////////////// | |
8 | //Implementation of ConstraintAlgorithm | |
# | Line 27 | Line 28 | void ConstraintAlgorithm::doConstrain(){ | |
28 | } | |
29 | ||
30 | void ConstraintAlgorithm::doConstrain(){ | |
31 | < | const int maxConsIteration = 30; |
31 | > | const int maxConsIteration = 300; |
32 | bool done; | |
33 | int iteration; | |
34 | int maxIteration; | |
# | Line 37 | Line 38 | void ConstraintAlgorithm::doConstrain(){ | |
38 | int exeStatus; | |
39 | ||
40 | ||
41 | + | error = false; |
42 | ||
43 | for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){ | |
44 | consElem = ceIter->currentItem(); | |
# | Line 62 | Line 64 | void ConstraintAlgorithm::doConstrain(){ | |
64 | ||
65 | switch(exeStatus){ | |
66 | case consFail: | |
67 | < | cerr << "ConstraintAlgorithm::doConstrain() Error: Constraint Fail" << endl; |
67 | > | cerr << "ConstraintAlgorithm::doConstrain() Error: Constraint Fail" << endl; |
68 | > | error = true; |
69 | break; | |
70 | case consSuccess: | |
71 | //constrain the pair by moving two elements | |
# | Line 76 | Line 79 | void ConstraintAlgorithm::doConstrain(){ | |
79 | case consPairHandlerFail: | |
80 | //can not found call back functor for constraint pair | |
81 | cerr << "ConstraintAlgorithm::doConstrain() Error: can not found callback functor for constraint pair " << endl; | |
82 | + | error = true; |
83 | break; | |
84 | case consElemHandlerFail: | |
85 | //can not found callback functor for constraint element | |
86 | cerr << "ConstraintAlgorithm::doConstrain() Error: can not found callback functor for constraint element " << endl; | |
87 | + | error = true; |
88 | break; | |
89 | default: | |
90 | cerr << "ConstraintAlgorithm::doConstrain() Error: unrecognized status" << endl; | |
91 | + | error = true; |
92 | break; | |
93 | } | |
94 | }//end for(iter->first()) | |
# | Line 95 | Line 101 | void ConstraintAlgorithm::doConstrain(){ | |
101 | ||
102 | iteration++; | |
103 | }//end while | |
104 | < | |
104 | > | |
105 | > | //if (!done){ |
106 | > | // error = true; |
107 | > | // sprintf(painCave.errMsg, |
108 | > | // "Constraint failure in constrainB, too many iterations: %d\n", |
109 | > | // iteration); |
110 | > | // painCave.isFatal = 1; |
111 | > | // simError(); |
112 | > | //} |
113 | } | |
114 | ||
115 | ||
# | Line 103 | Line 117 | int ConstraintAlgorithm::doConstrainPair(ConstraintPai | |
117 | map<TypeInfo, CallbackFunctor*>::iterator foundResult; | |
118 | CallbackFunctor* functor; | |
119 | ||
120 | < | foundResult = callbackMap.find(typeid(consPair)); |
120 | > | //typeid must operate on deferenced, otherwise it will return the type_info of base class |
121 | > | foundResult = callbackMap.find(TypeInfo(typeid(*consPair))); |
122 | if (foundResult != callbackMap.end()){ | |
123 | functor = foundResult->second; | |
124 | return (*functor)(consPair); | |
# | Line 147 | Line 162 | ConsAlgoFramework::~ConsAlgoFramework(){ | |
162 | ConsAlgoFramework::~ConsAlgoFramework(){ | |
163 | delete ceIter; | |
164 | } | |
165 | + | |
166 | void ConsAlgoFramework::doPreConstraint(){ | |
167 | ConstraintElement* consElem; | |
168 | ||
169 | for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){ | |
170 | consElem = ceIter->currentItem(); | |
171 | consElem->saveOldState(); | |
172 | < | } |
173 | < | } |
172 | > | } |
173 | > | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |