Salome HOME
Delete key regression corrections: in previous implementation sketch entities did...
[modules/shaper.git] / src / SketchSolver / SketchSolver_Group.cpp
index b019c7ed308f8fae41a48515875687cfb3f9c4de..34fb4d17b525179faf294141fff76a7bb9c23f5e 100644 (file)
@@ -77,7 +77,7 @@ static void sendMessage(const char* theMessageName)
 SketchSolver_Group::SketchSolver_Group(
     std::shared_ptr<ModelAPI_CompositeFeature> theWorkplane)
     : myID(GroupIndexer::NEW_GROUP()),
-      myPrevSolved(true)
+      myPrevResult(STATUS_UNKNOWN)
 {
   // Initialize workplane
   myWorkplaneID = EID_UNKNOWN;
@@ -172,30 +172,6 @@ bool SketchSolver_Group::changeConstraint(
   return true;
 }
 
-
-void SketchSolver_Group::updateConstraints()
-{
-  std::set<SolverConstraintPtr> aPostponed; // postponed constraints Multi-Rotation and Multi-Translation
-
-  ConstraintConstraintMap::iterator anIt = myConstraints.begin();
-  for (; anIt != myConstraints.end(); ++anIt) {
-    if (myChangedConstraints.find(anIt->first) == myChangedConstraints.end())
-      continue;
-    if (anIt->first->getKind() == SketchPlugin_MultiRotation::ID() ||
-        anIt->first->getKind() == SketchPlugin_MultiTranslation::ID())
-      aPostponed.insert(anIt->second);
-    else
-      anIt->second->update();
-  }
-
-  // Update postponed constraints
-  std::set<SolverConstraintPtr>::iterator aSCIter = aPostponed.begin();
-  for (; aSCIter != aPostponed.end(); ++aSCIter)
-    (*aSCIter)->update();
-
-  myChangedConstraints.clear();
-}
-
 static void updateMultiConstraints(ConstraintConstraintMap& theConstraints, FeaturePtr theFeature)
 {
   ConstraintConstraintMap::iterator aCIt = theConstraints.begin();
@@ -293,9 +269,6 @@ bool SketchSolver_Group::updateWorkplane()
 // ============================================================================
 bool SketchSolver_Group::resolveConstraints()
 {
-  if (!myChangedConstraints.empty())
-    updateConstraints();
-
   bool aResolved = false;
   bool isGroupEmpty = isEmpty();
   if (myStorage->isNeedToResolve() && !isGroupEmpty) {
@@ -333,31 +306,31 @@ bool SketchSolver_Group::resolveConstraints()
     } catch (...) {
 //      Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
       getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::SOLVESPACE_CRASH());
-      if (myPrevSolved) {
+      if (myPrevResult == STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
         // the error message should be changed before sending the message
         sendMessage(EVENT_SOLVER_FAILED);
-        myPrevSolved = false;
+        myPrevResult = STATUS_FAILED;
       }
       mySketchSolver->undo();
       return false;
     }
     if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) {  // solution succeeded, store results into correspondent attributes
       myStorage->refresh();
-      if (!myPrevSolved) {
+      if (myPrevResult != STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
         getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue("");
         // the error message should be changed before sending the message
         sendMessage(EVENT_SOLVER_REPAIRED);
-        myPrevSolved = true;
+        myPrevResult = STATUS_OK;
       }
     } else {
       mySketchSolver->undo();
       if (!myConstraints.empty()) {
 //      Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this);
         getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::CONSTRAINTS());
-        if (myPrevSolved) {
+        if (myPrevResult != aResult || myPrevResult == STATUS_UNKNOWN) {
           // the error message should be changed before sending the message
           sendMessage(EVENT_SOLVER_FAILED);
-          myPrevSolved = false;
+          myPrevResult = aResult;
         }
       }
     }
@@ -533,7 +506,6 @@ void SketchSolver_Group::removeTemporaryConstraints()
 // ============================================================================
 void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
 {
-  bool isFullyRemoved = true;
   ConstraintConstraintMap::iterator aCIter = myConstraints.begin();
   for (; aCIter != myConstraints.end(); aCIter++)
     if (aCIter->first == theConstraint) {
@@ -544,18 +516,6 @@ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
     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