Salome HOME
Using test for testing number of sub-shapes.
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMovement.cpp
index 85542cb42c7cad8c36e86a18530dc18c8479da23..916b8d5515d988d4eeca5cd5fc8d713ae96b74af 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #include <SketchSolver_ConstraintMovement.h>
 #include <SketchSolver_Error.h>
 #include <SketchSolver_Manager.h>
@@ -49,7 +51,9 @@ 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)
+    // check only the points to be moved (because arcs in PlaneGCS have scalar subs too)
+    if ((*anOldIt)->type() == ENTITY_POINT &&
+       (aMovedSubs.size() != 1 || aMovedSubs.front() != *anOldIt))
       isFullyMoved = false;
     aMoved.insert(aMoved.end(), aMovedSubs.begin(), aMovedSubs.end());
   }
@@ -96,3 +100,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;
+}