aEndPoint.setValue(X, Y)
model.do()
movementTime = timer() - movementTime
- print movementTime
assert movementTime < expectedTime, "Time to move point {0} is greater than expected {1}".format(movementTime, expectedTime)
assert math.fabs(aEndPoint.x() - X) < TOLERANCE and math.fabs(aEndPoint.y() - Y) < TOLERANCE, "({0}, {1}) != ({2}, {3})".format(aEndPoint.x(), aEndPoint.y(), X, Y)
averageTime += movementTime
nbMoves += 1
aDeltaX = aEndPoint.x() - aCenter.x()
- aDeltaY - aEndPoint.y() - aCenter.y()
+ aDeltaY = aEndPoint.y() - aCenter.y()
print "Movement average time: {0}".format(averageTime / nbMoves)
model.end()
// Workaround: avoid tangent constraint in the list of redundant
if (theType == CONSTRAINT_TANGENT_CIRCLE_LINE ||
- theType == CONSTRAINT_TANGENT_CIRCLE_CIRCLE)
- myTangentIDs.insert(theConstraint->getTag());
+ theType == CONSTRAINT_TANGENT_CIRCLE_CIRCLE ||
+ theType == CONSTRAINT_PT_PT_COINCIDENT ||
+ theType == CONSTRAINT_PT_ON_CIRCLE ||
+ theType == CONSTRAINT_PT_ON_LINE)
+ myConstraintIDsNotRedundant.insert(theConstraint->getTag());
}
void PlaneGCSSolver_Solver::removeConstraint(ConstraintID theID)
{
myConstraints.erase(theID);
- myTangentIDs.erase(theID);
+ myConstraintIDsNotRedundant.erase(theID);
if (myConstraints.empty()) {
myEquationSystem->clear();
myDOF = (int)myParameters.size();
GCS::VEC_I aRedundant;
myEquationSystem->getRedundant(aRedundant);
- if (!aRedundant.empty())
- aResult = GCS::Failed;
+ if (!aRedundant.empty()) {
+ collectConflicting();
+ if (!myConflictingIDs.empty())
+ aResult = GCS::Failed;
+ }
SolveStatus aStatus;
if (aResult == GCS::Success) {
GCS::VEC_I aTemp = aConflict;
aConflict.clear();
for (GCS::VEC_I::iterator anIt = aTemp.begin(); anIt != aTemp.end(); ++anIt)
- if (myTangentIDs.find(*anIt) == myTangentIDs.end())
+ if (myConstraintIDsNotRedundant.find(*anIt) == myConstraintIDsNotRedundant.end())
aConflict.push_back(*anIt);
myConflictingIDs.insert(aConflict.begin(), aConflict.end());
myNext->update(theFeature);
}
-static bool hasExternalPoint(const std::set<EntityWrapperPtr>& theCoincidences)
+static bool hasAnotherExternalPoint(const std::set<EntityWrapperPtr>& theCoincidences,
+ const EntityWrapperPtr& thePoint)
{
std::set<EntityWrapperPtr>::const_iterator anIt = theCoincidences.begin();
for (; anIt != theCoincidences.end(); ++anIt)
- if ((*anIt)->type() == ENTITY_POINT && (*anIt)->isExternal())
+ if ((*anIt)->type() == ENTITY_POINT && (*anIt)->isExternal() && *anIt != thePoint)
return true;
return false;
}
bool isAccepted = true;
std::list<std::set<EntityWrapperPtr> >::iterator anIt = myCoincident.begin();
- std::list<std::set<EntityWrapperPtr> >::iterator aFound1 = myCoincident.end();
- std::list<std::set<EntityWrapperPtr> >::iterator aFound2 = myCoincident.end();
+ std::list<std::set<EntityWrapperPtr> >::iterator
+ aFound[2] = {myCoincident.end(), myCoincident.end()};
+
for (; anIt != myCoincident.end(); ++anIt) {
- if (aFound1 == myCoincident.end() && anIt->find(theEntity1) != anIt->end())
- aFound1 = anIt;
- if (aFound2 == myCoincident.end() && anIt->find(theEntity2) != anIt->end())
- aFound2 = anIt;
- if (aFound1 != myCoincident.end() && aFound2 != myCoincident.end())
+ if (aFound[0] == myCoincident.end() && anIt->find(theEntity1) != anIt->end())
+ aFound[0] = anIt;
+ if (aFound[1] == myCoincident.end() && anIt->find(theEntity2) != anIt->end())
+ aFound[1] = anIt;
+ if (aFound[0] != myCoincident.end() && aFound[1] != myCoincident.end())
break;
}
- if (aFound1 == myCoincident.end() && aFound2 == myCoincident.end()) {
+ if (aFound[0] == myCoincident.end() && aFound[1] == myCoincident.end()) {
// new group of coincidence
std::set<EntityWrapperPtr> aNewCoinc;
aNewCoinc.insert(theEntity1);
aNewCoinc.insert(theEntity2);
myCoincident.push_back(aNewCoinc);
- } else if (aFound1 == aFound2) // same group => already coincident
+ } else if (aFound[0] == aFound[1]) // same group => already coincident
isAccepted = false;
else {
if (theEntity1->type() == ENTITY_POINT && theEntity2->type() == ENTITY_POINT &&
(theEntity1->isExternal() || theEntity2->isExternal())) {
- bool hasExternal = aFound1 != myCoincident.end() && hasExternalPoint(*aFound1);
- hasExternal = hasExternal || (aFound2 != myCoincident.end() && hasExternalPoint(*aFound2));
+ bool hasExternal = false;
+ for (int i = 0; i < 2 && !hasExternal; ++i) {
+ if (aFound[i] != myCoincident.end()) {
+ if (theEntity1->isExternal())
+ hasExternal = hasAnotherExternalPoint(*aFound[i], theEntity1);
+ if (!hasExternal && theEntity2->isExternal())
+ hasExternal = hasAnotherExternalPoint(*aFound[i], theEntity2);
+ }
+ }
if (hasExternal)
isAccepted = false;
}
- if (aFound1 == myCoincident.end())
- aFound2->insert(theEntity1);
- else if (aFound2 == myCoincident.end())
- aFound1->insert(theEntity2);
+ if (aFound[0] == myCoincident.end())
+ aFound[1]->insert(theEntity1);
+ else if (aFound[1] == myCoincident.end())
+ aFound[0]->insert(theEntity2);
else { // merge two groups
- aFound1->insert(aFound2->begin(), aFound2->end());
- myCoincident.erase(aFound2);
+ aFound[0]->insert(aFound[1]->begin(), aFound[1]->end());
+ myCoincident.erase(aFound[1]);
}
}