Oops, don't just crash when the MAX_UNKNOWNS limit is exceeded.
[git-p4: depot-paths = "//depot/solvespace/": change = 1943]
This commit is contained in:
parent
a4dc518a89
commit
11e4c7f5d9
|
@ -250,7 +250,7 @@ public:
|
||||||
double B[], int N);
|
double B[], int N);
|
||||||
bool SolveLeastSquares(void);
|
bool SolveLeastSquares(void);
|
||||||
|
|
||||||
void WriteJacobian(int tag);
|
bool WriteJacobian(int tag);
|
||||||
void EvalJacobian(void);
|
void EvalJacobian(void);
|
||||||
|
|
||||||
void WriteEquationsExceptFor(hConstraint hc, hGroup hg);
|
void WriteEquationsExceptFor(hConstraint hc, hGroup hg);
|
||||||
|
|
14
system.cpp
14
system.cpp
|
@ -3,11 +3,13 @@
|
||||||
const double System::RANK_MAG_TOLERANCE = 1e-4;
|
const double System::RANK_MAG_TOLERANCE = 1e-4;
|
||||||
const double System::CONVERGE_TOLERANCE = 1e-10;
|
const double System::CONVERGE_TOLERANCE = 1e-10;
|
||||||
|
|
||||||
void System::WriteJacobian(int tag) {
|
bool System::WriteJacobian(int tag) {
|
||||||
int a, i, j;
|
int a, i, j;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
for(a = 0; a < param.n; a++) {
|
for(a = 0; a < param.n; a++) {
|
||||||
|
if(j >= MAX_UNKNOWNS) return false;
|
||||||
|
|
||||||
Param *p = &(param.elem[a]);
|
Param *p = &(param.elem[a]);
|
||||||
if(p->tag != tag) continue;
|
if(p->tag != tag) continue;
|
||||||
mat.param[j] = p->h;
|
mat.param[j] = p->h;
|
||||||
|
@ -17,6 +19,8 @@ void System::WriteJacobian(int tag) {
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for(a = 0; a < eq.n; a++) {
|
for(a = 0; a < eq.n; a++) {
|
||||||
|
if(i >= MAX_UNKNOWNS) return false;
|
||||||
|
|
||||||
Equation *e = &(eq.elem[a]);
|
Equation *e = &(eq.elem[a]);
|
||||||
if(e->tag != tag) continue;
|
if(e->tag != tag) continue;
|
||||||
|
|
||||||
|
@ -43,6 +47,8 @@ void System::WriteJacobian(int tag) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
mat.m = i;
|
mat.m = i;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::EvalJacobian(void) {
|
void System::EvalJacobian(void) {
|
||||||
|
@ -449,7 +455,11 @@ void System::Solve(Group *g, bool andFindFree) {
|
||||||
|
|
||||||
// Now write the Jacobian for what's left, and do a rank test; that
|
// Now write the Jacobian for what's left, and do a rank test; that
|
||||||
// tells us if the system is inconsistently constrained.
|
// tells us if the system is inconsistently constrained.
|
||||||
WriteJacobian(0);
|
if(!WriteJacobian(0)) {
|
||||||
|
g->solved.how = Group::TOO_MANY_UNKNOWNS;
|
||||||
|
TextWindow::ReportHowGroupSolved(g->h);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EvalJacobian();
|
EvalJacobian();
|
||||||
|
|
||||||
|
|
|
@ -516,6 +516,10 @@ void TextWindow::ShowGroupSolveInfo(void) {
|
||||||
Printf(true, "%FxSOLVE FAILED!%Fd inconsistent system");
|
Printf(true, "%FxSOLVE FAILED!%Fd inconsistent system");
|
||||||
Printf(true, "remove any one of these to fix it");
|
Printf(true, "remove any one of these to fix it");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Group::TOO_MANY_UNKNOWNS:
|
||||||
|
Printf(true, "Too many unknowns in a single group!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < g->solved.remove.n; i++) {
|
for(int i = 0; i < g->solved.remove.n; i++) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user