]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Do not recalculate constraints if there are invalid features (issue #874)
authorazv <azv@opencascade.com>
Thu, 3 Sep 2015 08:22:33 +0000 (11:22 +0300)
committerazv <azv@opencascade.com>
Thu, 3 Sep 2015 08:23:47 +0000 (11:23 +0300)
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h

index 8d8b8173554d0a7531a46564ac48fb29471e93d9..9325a6e1ecd5c1d0e6721d7fd2738b78b248ed1c 100644 (file)
@@ -23,6 +23,8 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
 
 #include <SketchPlugin_Constraint.h>
 #include <SketchPlugin_ConstraintEqual.h>
@@ -191,6 +193,9 @@ bool SketchSolver_Group::changeConstraint(
   if (!theConstraint)
     return false;
 
+  if (!checkFeatureValidity(theConstraint))
+    return false;
+
   bool isNewConstraint = myConstraints.find(theConstraint) == myConstraints.end();
   if (isNewConstraint) {
     // Add constraint to the current group
@@ -280,6 +285,9 @@ bool SketchSolver_Group::changeConstraint(
 
 bool SketchSolver_Group::updateFeature(std::shared_ptr<SketchPlugin_Feature> theFeature)
 {
+  if (!checkFeatureValidity(theFeature))
+    return false;
+
   std::set<ConstraintPtr> aConstraints =
       myFeatureStorage->getConstraints(std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature));
   if (aConstraints.empty())
@@ -698,3 +706,19 @@ void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
   myTempConstraints.insert(theConstraint);
 }
 
+
+// ============================================================================
+//  Function: checkFeatureValidity
+//  Class:    SketchSolver_Group
+//  Purpose:  verifies is the feature valid
+// ============================================================================
+bool SketchSolver_Group::checkFeatureValidity(FeaturePtr theFeature)
+{
+  if (!theFeature || !theFeature->data()->isValid())
+    return true;
+
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  return aFactory->validate(theFeature);
+}
+
index 13f614c754cfc3fc8099e434f45b4a428e9c3592..e75accd08dd53a53b0c370b13ec4dd804c0e9ec2 100644 (file)
@@ -157,6 +157,9 @@ private:
   /// \brief Append given constraint to th group of temporary constraints
   void setTemporary(SolverConstraintPtr theConstraint);
 
+  /// \brief Verifies is the feature valid
+  bool checkFeatureValidity(FeaturePtr theFeature);
+
 private:
   Slvs_hGroup myID; ///< Index of the group
   Slvs_hEntity myWorkplaneID; ///< Index of workplane, the group is based on