]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implement extended status of previously solved/failed set of constraints
authorazv <azv@opencascade.com>
Thu, 24 Dec 2015 10:46:52 +0000 (13:46 +0300)
committerazv <azv@opencascade.com>
Thu, 24 Dec 2015 10:50:41 +0000 (13:50 +0300)
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h
src/SketchSolver/SketchSolver_ISolver.h

index 11f25e8d0447d0541e1ff3e7784fbc616bf8cd99..7ef43366f6655847175729af79ad06ddfeaf37e7 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;
@@ -333,31 +333,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;
         }
       }
     }
index 4eb67e619784c0fa56daabd6d6679f4834e92635..f1520d3bd94b47099f4769facd16fded4bb060b4 100644 (file)
@@ -168,7 +168,7 @@ private:
 
   SolverPtr mySketchSolver;  ///< Solver for set of equations obtained by constraints
 
-  bool myPrevSolved; ///< Indicates that previous solving was done correctly
+  SketchSolver_SolveStatus myPrevResult; ///< Result of previous solution of the set of constraints
 };
 
 #endif
index 19c2c5e22565d2f6cb72cfa928f966e1e7c17523..a23807ee31275c6511283aa0fac945a84e1fa0c3 100644 (file)
@@ -16,7 +16,8 @@ enum SketchSolver_SolveStatus {
   STATUS_OK,
   STATUS_INCONSISTENT,
   STATUS_EMPTYSET,
-  STATUS_FAILED // set if no one other status is applicable
+  STATUS_FAILED, // set if no one other status is applicable
+  STATUS_UNKNOWN // set for newly created groups
 };