]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Avoid too much recalculations of DoF while moving feature
authorazv <azv@opencascade.com>
Wed, 22 Jun 2016 09:07:14 +0000 (12:07 +0300)
committerazv <azv@opencascade.com>
Wed, 22 Jun 2016 09:07:40 +0000 (12:07 +0300)
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h
src/SketchSolver/SketchSolver_Manager.cpp
src/SketchSolver/SketchSolver_Manager.h

index a39aab6e6a535330fec2df414fbec7dfc3e6fd19..285a55cbb364cc0d79f1ea183d9aa87ce71680a8 100644 (file)
@@ -246,7 +246,7 @@ bool SketchSolver_Group::updateFeature(FeaturePtr theFeature)
   return isUpdated;
 }
 
-void SketchSolver_Group::moveFeature(FeaturePtr theFeature)
+bool SketchSolver_Group::moveFeature(FeaturePtr theFeature)
 {
   BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
 
@@ -260,7 +260,7 @@ void SketchSolver_Group::moveFeature(FeaturePtr theFeature)
   // Then, create temporary Fixed constraint
   SolverConstraintPtr aConstraint = aBuilder->createMovementConstraint(theFeature);
   if (!aConstraint)
-    return;
+    return false;
   aConstraint->process(myStorage, getId(), getWorkplaneId());
   if (aConstraint->error().empty())
     setTemporary(aConstraint);
@@ -279,6 +279,7 @@ void SketchSolver_Group::moveFeature(FeaturePtr theFeature)
         aFixedRadius->remove();
     }
   }
+  return true;
 }
 
 // ============================================================================
index 89a14f49072f636f22721367182e52d385c498a5..ea22b03d0175aba0eea37a21841dc4424a279dcf 100644 (file)
@@ -81,8 +81,9 @@ class SketchSolver_Group
   /** \brief Updates the data corresponding the specified feature moved in GUI.
    *         Additional Fixed constraints are created.
    *  \param[in] theFeature the feature to be updated
+   *  \return \c true, if the feature is moved
    */
-  void moveFeature(FeaturePtr theFeature);
+  bool moveFeature(FeaturePtr theFeature);
 
   /** \brief Verifies the feature attributes are used in this group
    *  \param[in] theFeature constraint or any other object for verification of interaction
index 350ef59abd044764b7c81e6d2c571f9b3e9cc366..d430a9651675ca523c9aa0d4640414455d45fcc6 100644 (file)
@@ -130,8 +130,9 @@ void SketchSolver_Manager::processEvent(
       for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
         std::shared_ptr<SketchPlugin_Feature> aSFeature = 
             std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
-        if (aSFeature) {
-          moveEntity(aSFeature);
+        if (aSFeature && moveEntity(aSFeature)) {
+          // Want to avoid recalculation of DoF too frequently.
+          // So, set the flag when the feature is really moved.
           hasProperFeature = true;
         }
       }
@@ -365,23 +366,22 @@ bool SketchSolver_Manager::changeFeature(std::shared_ptr<SketchPlugin_Feature> t
 //  Function: moveEntity
 //  Purpose:  update element moved on the sketch, which is used by constraints
 // ============================================================================
-void SketchSolver_Manager::moveEntity(std::shared_ptr<SketchPlugin_Feature> theFeature)
+bool SketchSolver_Manager::moveEntity(std::shared_ptr<SketchPlugin_Feature> theFeature)
 {
   bool isMoved = false;
   std::list<SketchSolver_Group*>::iterator aGroupIt = myGroups.begin();
   for (; aGroupIt != myGroups.end(); aGroupIt++)
-    if (!(*aGroupIt)->isEmpty() && (*aGroupIt)->isInteract(theFeature)) {
-      (*aGroupIt)->moveFeature(theFeature);
-      isMoved = true;
-    }
+    if (!(*aGroupIt)->isEmpty() && (*aGroupIt)->isInteract(theFeature))
+      isMoved = (*aGroupIt)->moveFeature(theFeature) || isMoved;
 
   if (!isMoved && theFeature->getKind() == SketchPlugin_Arc::ID()) {
     // Workaround to move arc.
     // If the arc has not been constrained, we will push it into empty group and apply movement.
     for (aGroupIt = myGroups.begin(); aGroupIt != myGroups.end(); aGroupIt++)
       if ((*aGroupIt)->isEmpty())
-        (*aGroupIt)->moveFeature(theFeature);
+        isMoved = (*aGroupIt)->moveFeature(theFeature) || isMoved;
   }
+  return isMoved;
 }
 
 // ============================================================================
index 0781129c0f2c43cb1e0aae70299e4ef18115220c..c0866c558493a500b98dfb9351a22c6fd206306e 100644 (file)
@@ -79,8 +79,9 @@ protected:
 
   /** \brief Updates entity which is moved in GUI
    *  \param[in] theFeature entity to be updated
+   *  \return \c true, if the entity has been moved
    */
-  void moveEntity(std::shared_ptr<SketchPlugin_Feature> theFeature);
+  bool moveEntity(std::shared_ptr<SketchPlugin_Feature> theFeature);
 
   /** \brief Goes through the list of groups and solve the constraints
    *  \param[in] theGroups  list of groups to be resolved (if empty list, all groups are resolved)