Sketcher: Solver information: Bug fix

=====================================

When the solver converged (but did not succeed) or when the solver succeded but the solution is not OCC-valid, no error message was shown in the solver messages dialog.
This commit is contained in:
Abdullah Tahiri 2015-10-05 17:24:03 +02:00 committed by wmayer
parent 4fb15f2a1b
commit fc128d357d
4 changed files with 17 additions and 6 deletions

View File

@ -2186,6 +2186,7 @@ int Sketch::solve(void)
GCSsys.undoSolution();
updateGeometry();
Base::Console().Warning("Invalid solution from %s solver.\n", solvername.c_str());
ret = GCS::SuccessfulSolutionInvalid;
}else
{
updateNonDrivingConstraints();

View File

@ -141,6 +141,9 @@ App::DocumentObjectExecReturn *SketchObject::execute(void)
lastConflicting=solvedSketch.getConflicting();
lastRedundant=solvedSketch.getRedundant();
lastSolveTime=0.0;
lastSolverStatus=GCS::Failed; // Failure is default for notifying the user unless otherwise proven
solverNeedsUpdate=false;
if (lastDoF < 0) { // over-constrained sketch
@ -211,8 +214,14 @@ int SketchObject::solve(bool updateGeoAfterSolving/*=true*/)
err = -3;
else {
lastSolverStatus=solvedSketch.solve();
if (lastSolverStatus != 0) // solving
if (lastSolverStatus != 0){ // solving
err = -2;
// if solver failed, geometry was never updated, but invalid constraints were likely added before
// solving (see solve in addConstraint), so solver information is definitely invalid.
this->Constraints.touch();
}
}
lastHasRedundancies = solvedSketch.hasRedundancies();

View File

@ -39,9 +39,10 @@ namespace GCS
///////////////////////////////////////
enum SolveStatus {
Success = 0, // Found a solution zeroing the error function
Converged = 1, // Found a solution minimizing the error function
Failed = 2 // Failed to find any solution
Success = 0, // Found a solution zeroing the error function
Converged = 1, // Found a solution minimizing the error function
Failed = 2, // Failed to find any solution
SuccessfulSolutionInvalid = 3, // This is a solution where the solver succeeded, but the resulting geometry is OCE-invalid
};
enum Algorithm {

View File

@ -4374,10 +4374,10 @@ void ViewProviderSketch::UpdateSolverInformation()
signalSetUp(tr("Under-constrained sketch with %1 degrees of freedom").arg(dofs));
}
signalSolved(tr("Solved in %1 sec").arg(getSketchObject()->getLastSolveTime()));
signalSolved(QString::fromLatin1("<font color='green'>%1</font>").arg(tr("Solved in %1 sec").arg(getSketchObject()->getLastSolveTime())));
}
else {
signalSolved(tr("Unsolved (%1 sec)").arg(getSketchObject()->getLastSolveTime()));
signalSolved(QString::fromLatin1("<font color='red'>%1</font>").arg(tr("Unsolved (%1 sec)").arg(getSketchObject()->getLastSolveTime())));
}
}
}