]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchSolver/SketchSolver_Group.cpp
Salome HOME
Fit incorrect movement of a line which boundary coincident to a point from another...
[modules/shaper.git] / src / SketchSolver / SketchSolver_Group.cpp
index b51828ba9d0eb78e560f1d934f11f9801a4642a3..7fdc32a4c5e74b5c2c1ee514339fd2d28f60e298 100644 (file)
@@ -30,6 +30,7 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintMirror.h>
 #include <SketchPlugin_ConstraintRigid.h>
+#include <SketchPlugin_ConstraintTangent.h>
 #include <SketchPlugin_Feature.h>
 
 #include <SketchPlugin_Arc.h>
@@ -230,7 +231,7 @@ bool SketchSolver_Group::changeConstraint(
         continue;
       aConstraint->setGroup(this);
       aConstraint->setStorage(myStorage);
-      myTempConstraints.insert(aConstraint);
+      setTemporary(aConstraint);
     }
   }
   // Fix base features for mirror
@@ -272,7 +273,7 @@ void SketchSolver_Group::moveFeature(std::shared_ptr<SketchPlugin_Feature> theFe
     return;
   aConstraint->setGroup(this);
   aConstraint->setStorage(myStorage);
-  myTempConstraints.insert(aConstraint);
+  setTemporary(aConstraint);
 }
 
 // ============================================================================
@@ -294,7 +295,7 @@ void SketchSolver_Group::fixFeaturesList(AttributeRefListPtr theList)
       continue;
     aConstraint->setGroup(this);
     aConstraint->setStorage(myStorage);
-    myTempConstraints.insert(aConstraint);
+    setTemporary(aConstraint);
   }
 }
 
@@ -413,9 +414,18 @@ void SketchSolver_Group::mergeGroups(const SketchSolver_Group& theGroup)
   if (!myFeatureStorage)
     myFeatureStorage = FeatureStoragePtr(new SketchSolver_FeatureStorage);
 
+  std::vector<ConstraintPtr> aComplexConstraints;
   ConstraintConstraintMap::const_iterator aConstrIter = theGroup.myConstraints.begin();
+  // append simple constraints
   for (; aConstrIter != theGroup.myConstraints.end(); aConstrIter++)
-    changeConstraint(aConstrIter->first);
+    if (isComplexConstraint(aConstrIter->first))
+      aComplexConstraints.push_back(aConstrIter->first);
+    else
+      changeConstraint(aConstrIter->first);
+  // append complex constraints
+  std::vector<ConstraintPtr>::iterator aComplexIter = aComplexConstraints.begin();
+  for (; aComplexIter != aComplexConstraints.end(); aComplexIter++)
+      changeConstraint(*aComplexIter);
 }
 
 // ============================================================================
@@ -513,6 +523,7 @@ bool SketchSolver_Group::isConsistent()
 void SketchSolver_Group::removeTemporaryConstraints()
 {
   myTempConstraints.clear();
+  myStorage->removeTemporaryConstraints();
   // Clean lists of removed entities in the storage
   std::set<Slvs_hParam> aRemPar;
   std::set<Slvs_hEntity> aRemEnt;
@@ -539,3 +550,27 @@ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
   if (aCIter != myConstraints.end())
     myConstraints.erase(aCIter);
 }
+
+// ============================================================================
+//  Function: isComplexConstraint
+//  Class:    SketchSolver_Group
+//  Purpose:  verifies the constraint is complex, i.e. it needs another constraints to be created before
+// ============================================================================
+bool SketchSolver_Group::isComplexConstraint(FeaturePtr theConstraint)
+{
+  return theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID() ||
+         theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID() ||
+         theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID();
+}
+
+// ============================================================================
+//  Function: setTemporary
+//  Class:    SketchSolver_Group
+//  Purpose:  append given constraint to th group of temporary constraints
+// ============================================================================
+void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
+{
+  theConstraint->makeTemporary();
+  myTempConstraints.insert(theConstraint);
+}
+