Salome HOME
Correct DoF calculation
authorazv <azv@opencascade.com>
Thu, 30 Mar 2017 09:11:10 +0000 (12:11 +0300)
committerazv <azv@opencascade.com>
Thu, 30 Mar 2017 09:15:47 +0000 (12:15 +0300)
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h

index 6681f2072f96824fc9d80764f2f4dd0aab2e2848..8d15b1680db393022809a9e08e96ea1495e2d321 100644 (file)
@@ -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;
 }
index 9ac6212f76b73b10c133a529be659d29435e51d1..a5a411dfa4fb4e366a03cd6fb6df21e66fd34e85 100644 (file)
@@ -68,9 +68,9 @@ private:
   ConstraintMap                myConstraints;    ///< list of constraints
 
   std::shared_ptr<GCS::System> 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;