Salome HOME
Eliminate regression in "Multi" constraints (issue #1185)
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMovement.cpp
index 85542cb42c7cad8c36e86a18530dc18c8479da23..7f4c8d78be74bc356fa3c967a41d612b9bbb1b0f 100644 (file)
@@ -49,7 +49,8 @@ static std::list<EntityWrapperPtr> movedEntities(
   for (; anOldIt != anOldSubs.end() && aNewIt != aNewSubs.end(); ++anOldIt, ++aNewIt) {
     std::list<EntityWrapperPtr> aMovedSubs = movedEntities(
         *anOldIt, theOldStorage, *aNewIt, theNewStorage);
-    if (aMovedSubs.size() != 1 || aMovedSubs.front() != *anOldIt)
+    if ((*anOldIt)->type() == ENTITY_POINT && // check only the points to be moved (because arcs in PlaneGCS have scalar subs too)
+       (aMovedSubs.size() != 1 || aMovedSubs.front() != *anOldIt))
       isFullyMoved = false;
     aMoved.insert(aMoved.end(), aMovedSubs.begin(), aMovedSubs.end());
   }
@@ -96,3 +97,21 @@ void SketchSolver_ConstraintMovement::getAttributes(
   theAttributes.clear();
   theAttributes.insert(theAttributes.begin(), aMoved.begin(), aMoved.end());
 }
+
+bool SketchSolver_ConstraintMovement::remove()
+{
+  cleanErrorMsg();
+  // Move fixed entities back to the current group
+  std::vector<EntityWrapperPtr>::iterator aMoveIt = myMovedEntities.begin();
+  for (; aMoveIt != myMovedEntities.end(); ++aMoveIt) {
+    if ((*aMoveIt)->baseAttribute())
+      myStorage->update((*aMoveIt)->baseAttribute(), myGroupID);
+    else if ((*aMoveIt)->baseFeature())
+      myStorage->update((*aMoveIt)->baseFeature(), myGroupID);
+  }
+
+  // Remove base feature
+  if (myBaseFeature)
+    myStorage->removeEntity(myBaseFeature);
+  return true;
+}