From 13bbe3426159f4407fc058bb1a1b3427e31a94ba Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 17 Sep 2015 16:49:13 +0300 Subject: [PATCH] Improve performance of sketch solver by disabling by default the search of failed constraints --- src/SketchSolver/SketchSolver_Group.cpp | 2 ++ src/SketchSolver/SketchSolver_Solver.cpp | 2 +- src/SketchSolver/SketchSolver_Solver.h | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 560550f6e..cc60f0c25 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -549,6 +549,7 @@ bool SketchSolver_Group::resolveConstraints() bool aResolved = false; if (myStorage->isNeedToResolve() && !isEmpty()) { myConstrSolver.setGroupID(myID); + myConstrSolver.calculateFailedConstraints(false); myStorage->initializeSolver(myConstrSolver); int aResult = SLVS_RESULT_OKAY; @@ -572,6 +573,7 @@ bool SketchSolver_Group::resolveConstraints() isLastChance = true; } else aNbTemp = myStorage->deleteTemporaryConstraint(); + myConstrSolver.calculateFailedConstraints(true); // something failed => need to find it myStorage->initializeSolver(myConstrSolver); } } diff --git a/src/SketchSolver/SketchSolver_Solver.cpp b/src/SketchSolver/SketchSolver_Solver.cpp index a14fa2365..36979d747 100644 --- a/src/SketchSolver/SketchSolver_Solver.cpp +++ b/src/SketchSolver/SketchSolver_Solver.cpp @@ -27,7 +27,7 @@ SketchSolver_Solver::SketchSolver_Solver() // If the set of constraints is inconsistent, // the failed field will contain wrong constraints - myEquationsSystem.calculateFaileds = 1; + myEquationsSystem.calculateFaileds = 0; } SketchSolver_Solver::~SketchSolver_Solver() diff --git a/src/SketchSolver/SketchSolver_Solver.h b/src/SketchSolver/SketchSolver_Solver.h index 46e83afd0..f90d71fd2 100644 --- a/src/SketchSolver/SketchSolver_Solver.h +++ b/src/SketchSolver/SketchSolver_Solver.h @@ -75,6 +75,11 @@ class SketchSolver_Solver */ void setDraggedParameters(const Slvs_hParam* theDragged); + /** \brief Set or unset the flag which allows to find all failed constraints + */ + void calculateFailedConstraints(bool theSic) + { myEquationsSystem.calculateFaileds = theSic ? 1 : 0; } + /** \brief Solve the set of equations * \return identifier whether solution succeeded */ -- 2.39.2