Salome HOME
Fix for the issue #593: do not remove naming attribute, but use TNaming_Builder for...
[modules/shaper.git] / src / SketchSolver / SketchSolver_Group.cpp
index 419cc3e87b51241c5d45d1db49fd0020d4c70aac..cc24d79f2fa81c8f1d33d4fec9e5bfd767decc92 100644 (file)
@@ -242,12 +242,14 @@ bool SketchSolver_Group::changeConstraint(
         theConstraint->attribute(SketchPlugin_ConstraintMirror::ENTITY_A()));
     if (aRefAttr && aRefAttr->isObject()) {
       FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
-      SolverConstraintPtr aConstraint =
-          SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature);
-      if (aConstraint) {
-        aConstraint->setGroup(this);
-        aConstraint->setStorage(myStorage);
-        setTemporary(aConstraint);
+      if (aFeature) {
+        SolverConstraintPtr aConstraint =
+            SketchSolver_Builder::getInstance()->createRigidConstraint(aFeature);
+        if (aConstraint) {
+          aConstraint->setGroup(this);
+          aConstraint->setStorage(myStorage);
+          setTemporary(aConstraint);
+        }
       }
     }
   }
@@ -424,7 +426,7 @@ bool SketchSolver_Group::resolveConstraints()
       else {
         // To avoid overconstraint situation, we will remove temporary constraints one-by-one
         // and try to find the case without overconstraint
-        int aNbTemp = (int)myTempConstraints.size();
+        int aNbTemp = myStorage->numberTemporary();
         while (true) {
           aResult = myConstrSolver.solve();
           if (aResult == SLVS_RESULT_OKAY || aNbTemp <= 0)
@@ -575,7 +577,8 @@ bool SketchSolver_Group::isConsistent()
 void SketchSolver_Group::removeTemporaryConstraints()
 {
   myTempConstraints.clear();
-  myStorage->removeTemporaryConstraints();
+  while (myStorage->numberTemporary())
+    myStorage->deleteTemporaryConstraint();
   // Clean lists of removed entities in the storage
   std::set<Slvs_hParam> aRemPar;
   std::set<Slvs_hEntity> aRemEnt;