From 394c1f62d864244ca1062828abbe735158031218 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 24 May 2019 13:24:10 +0000 Subject: [PATCH] Remove forceDofCheck parameter from SolveRank(). NFC. It makes no sense to solve by substitution (therefore weakening rank check) in SolveRank(), since that's the whole point of SolveRank(). In addition, because SolveRank() is currently always called right after AddConstraint(), forceDofCheck would always be true anyway. In addition, it makes no sense to have TestRankForGroup() dependent on the result of the previous solve. (For SolveGroup(), solving by substitution after we know that rank test succeeds makes dragging points much faster.) --- src/generate.cpp | 5 +++-- src/solvespace.h | 2 +- src/system.cpp | 8 ++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/generate.cpp b/src/generate.cpp index 8cd7350..ee343f5 100644 --- a/src/generate.cpp +++ b/src/generate.cpp @@ -554,8 +554,9 @@ void SolveSpaceUI::SolveGroup(hGroup hg, bool andFindFree) { SolveResult SolveSpaceUI::TestRankForGroup(hGroup hg) { WriteEqSystemForGroup(hg); Group *g = SK.GetGroup(hg); - SolveResult result = sys.SolveRank(g, NULL, NULL, false, false, - /*forceDofCheck=*/!g->dofCheckOk); + SolveResult result = sys.SolveRank(g, NULL, NULL, + /*andFindBad=*/false, + /*andFindFree=*/false); FreeAllTemporary(); return result; } diff --git a/src/solvespace.h b/src/solvespace.h index 3fde8fb..7fe4f66 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -312,7 +312,7 @@ public: bool andFindBad, bool andFindFree, bool forceDofCheck = false); SolveResult SolveRank(Group *g, int *dof, List *bad, - bool andFindBad, bool andFindFree, bool forceDofCheck = false); + bool andFindBad, bool andFindFree); void Clear(); }; diff --git a/src/system.cpp b/src/system.cpp index 07cad70..8801caf 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -518,7 +518,7 @@ didnt_converge: } SolveResult System::SolveRank(Group *g, int *dof, List *bad, - bool andFindBad, bool andFindFree, bool forceDofCheck) + bool andFindBad, bool andFindFree) { WriteEquationsExceptFor(Constraint::NO_CONSTRAINT, g); @@ -526,10 +526,6 @@ SolveResult System::SolveRank(Group *g, int *dof, List *bad, param.ClearTags(); eq.ClearTags(); - if(!forceDofCheck) { - SolveBySubstitution(); - } - // Now write the Jacobian, and do a rank test; that // tells us if the system is inconsistently constrained. if(!WriteJacobian(0)) { @@ -539,7 +535,7 @@ SolveResult System::SolveRank(Group *g, int *dof, List *bad, bool rankOk = TestRank(); if(!rankOk) { if(!g->allowRedundant) { - if(andFindBad) FindWhichToRemoveToFixJacobian(g, bad, forceDofCheck); + if(andFindBad) FindWhichToRemoveToFixJacobian(g, bad, /*forceDofCheck=*/true); } } else { // This is not the full Jacobian, but any substitutions or single-eq