]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #149 fix: Implemented update procedure for constraint when its attributes was...
authorazv <azv@opencascade.com>
Tue, 23 Sep 2014 12:13:27 +0000 (16:13 +0400)
committerazv <azv@opencascade.com>
Tue, 23 Sep 2014 12:13:27 +0000 (16:13 +0400)
src/SketchSolver/SketchSolver_ConstraintGroup.cpp

index 723ae3836baa22d39a04f2058c8a4c52de97c329..df7b1614ec6fde25b838f82e8c7534618622732e 100644 (file)
@@ -281,7 +281,7 @@ bool SketchSolver_ConstraintGroup::changeConstraint(
       aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr());
   }
 
-  if (aConstrMapIter == myConstraintMap.end()) {
+  if (aConstrMapIter == myConstraintMap.end()) { // Add new constraint
     // Several points may be coincident, it is not necessary to store all constraints between them.
     // Try to find sequence of coincident points which connects the points of new constraint
     if (aConstrType == SLVS_C_POINTS_COINCIDENT) {
@@ -302,6 +302,17 @@ bool SketchSolver_ConstraintGroup::changeConstraint(
     int aConstrPos = Search(aConstraint.h, myConstraints);
     aConstrIter = myConstraints.begin() + aConstrPos;
     myNeedToSolve = true;
+  } else { // Attributes of constraint may be changed => update constraint
+    Slvs_hEntity* aCurrentAttr[] = {&aConstrIter->ptA, &aConstrIter->ptB,
+                                   &aConstrIter->entityA, &aConstrIter->entityB,
+                                   &aConstrIter->entityC, &aConstrIter->entityD};
+    for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) {
+      if (*(aCurrentAttr[indAttr]) != aConstrEnt[indAttr])
+      {
+        *(aCurrentAttr[indAttr]) = aConstrEnt[indAttr];
+        myNeedToSolve = true;
+      }
+    }
   }
 
   checkConstraintConsistence(*aConstrIter);