From: azv Date: Thu, 30 Mar 2017 09:11:10 +0000 (+0300) Subject: Correct DoF calculation X-Git-Tag: V_2.7.0~130 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae86330710c2a0f8d6b82ddb53fcba1707ecf9e4;p=modules%2Fshaper.git Correct DoF calculation --- diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp index 6681f2072..8d15b1680 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp @@ -10,6 +10,7 @@ PlaneGCSSolver_Solver::PlaneGCSSolver_Solver() : myEquationSystem(new GCS::System), + myDiagnoseBeforeSolve(false), myConfCollected(false), myDOF(0) { @@ -54,6 +55,8 @@ double* PlaneGCSSolver_Solver::createParameter() myParameters.push_back(aResult); if (myConstraints.empty() && myDOF >= 0) ++myDOF; // calculate DoF by hand if and only if there is no constraints yet + else + myDiagnoseBeforeSolve = true; return aResult; } @@ -78,6 +81,8 @@ PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Solver::solve() return STATUS_INCONSISTENT; Events_LongOp::start(this); + if (myDiagnoseBeforeSolve) + diagnose(); // solve equations GCS::SolveStatus aResult = (GCS::SolveStatus)myEquationSystem->solve(myParameters); Events_LongOp::end(this); @@ -130,7 +135,7 @@ void PlaneGCSSolver_Solver::collectConflicting() int PlaneGCSSolver_Solver::dof() { if (myDOF < 0 && !myConstraints.empty()) - solve(); + diagnose(); return myDOF; } @@ -138,4 +143,5 @@ void PlaneGCSSolver_Solver::diagnose() { myEquationSystem->declareUnknowns(myParameters); myDOF = myEquationSystem->diagnose(); + myDiagnoseBeforeSolve = false; } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h index 9ac6212f7..a5a411dfa 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h @@ -68,9 +68,9 @@ private: ConstraintMap myConstraints; ///< list of constraints std::shared_ptr myEquationSystem; ///< set of equations for solving in FreeGCS + bool myDiagnoseBeforeSolve; ///< is the diagnostic necessary GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints - /// specifies the conflicting constraints are already collected bool myConfCollected;