From eea82b5b4283b2c85e33453c17e99e0bb4cf9b77 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 22 Sep 2014 13:04:12 +0400 Subject: [PATCH] Issue #148 fix: Eliminated recursive resolving of constraints --- src/SketchSolver/SketchSolver_ConstraintGroup.cpp | 7 ++++--- src/SketchSolver/SketchSolver_ConstraintGroup.h | 3 ++- src/SketchSolver/SketchSolver_ConstraintManager.cpp | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index bd70204c7..6b445b187 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -606,10 +606,10 @@ Slvs_hParam SketchSolver_ConstraintGroup::changeParameter( // Class: SketchSolver_ConstraintGroup // Purpose: solve the set of constraints for the current group // ============================================================================ -void SketchSolver_ConstraintGroup::resolveConstraints() +bool SketchSolver_ConstraintGroup::resolveConstraints() { if (!myNeedToSolve) - return; + return false; myConstrSolver.setGroupID(myID); myConstrSolver.setParameters(myParams); @@ -621,7 +621,7 @@ void SketchSolver_ConstraintGroup::resolveConstraints() if (aResult == SLVS_RESULT_OKAY) { // solution succeeded, store results into correspondent attributes // Obtain result into the same list of parameters if (!myConstrSolver.getResult(myParams)) - return; + return true; // We should go through the attributes map, because only attributes have valued parameters std::map, Slvs_hEntity>::iterator anEntIter = @@ -634,6 +634,7 @@ void SketchSolver_ConstraintGroup::resolveConstraints() removeTemporaryConstraints(); myNeedToSolve = false; + return true; } // ============================================================================ diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.h b/src/SketchSolver/SketchSolver_ConstraintGroup.h index 42ce8ddd5..5d7123903 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.h +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.h @@ -98,8 +98,9 @@ class SketchSolver_ConstraintGroup void splitGroup(std::vector& theCuts); /** \brief Start solution procedure if necessary and update attributes of features + * \return \c false when no need to solve constraints */ - void resolveConstraints(); + bool resolveConstraints(); /** \brief Searches the constraints built on the entity and emit the signal to update them * \param[in] theEntity attribute of the constraint diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index ea7a29bcd..ac0223064 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -349,11 +349,14 @@ boost::shared_ptr SketchSolver_ConstraintManager::findWork // ============================================================================ void SketchSolver_ConstraintManager::resolveConstraints() { + bool needToUpdate = false; std::vector::iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) - (*aGroupIter)->resolveConstraints(); + if ((*aGroupIter)->resolveConstraints()) + needToUpdate = true; // Features may be updated => send events - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + if (needToUpdate) + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } -- 2.39.2