]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
Salome HOME
Merge branch 'Pre_2.8.0_development'
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_Solver.cpp
index 0c1584873293aa8b5ffe609da08dca24f87d31f0..9c4cad57d2a7488cc3fba558c3f5ab04b63cbd6a 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:    PlaneGCSSolver_Solver.cpp
-// Created: 14 Dec 2014
-// Author:  Artem ZHIDKOV
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include <PlaneGCSSolver_Solver.h>
 #include <Events_LongOp.h>
@@ -38,7 +52,9 @@ void PlaneGCSSolver_Solver::addConstraint(GCSConstraintPtr theConstraint)
 {
   myEquationSystem->addConstraint(theConstraint.get());
   myConstraints[theConstraint->getTag()].insert(theConstraint);
-  myDOF = -1;
+  if (theConstraint->getTag() >= 0)
+    myDOF = -1;
+  myInitilized = false;
 }
 
 void PlaneGCSSolver_Solver::removeConstraint(ConstraintID theID)
@@ -49,8 +65,10 @@ void PlaneGCSSolver_Solver::removeConstraint(ConstraintID theID)
     myDOF = (int)myParameters.size();
   } else {
     myEquationSystem->clearByTag(theID);
-    myDOF = -1;
+    if (theID >= 0)
+      myDOF = -1;
   }
+  myInitilized = false;
 }
 
 double* PlaneGCSSolver_Solver::createParameter()
@@ -64,6 +82,22 @@ double* PlaneGCSSolver_Solver::createParameter()
   return aResult;
 }
 
+void PlaneGCSSolver_Solver::addParameters(const GCS::SET_pD& theParams)
+{
+  GCS::SET_pD aParams(theParams);
+  // leave new parameters only
+  GCS::VEC_pD::iterator anIt = myParameters.begin();
+  for (; anIt != myParameters.end(); ++anIt)
+    if (aParams.find(*anIt) != aParams.end())
+      aParams.erase(*anIt);
+
+  myParameters.insert(myParameters.end(), aParams.begin(), aParams.end());
+  if (myConstraints.empty() && myDOF >=0)
+    myDOF += (int)aParams.size(); // calculate DoF by hand only if there is no constraints yet
+  else
+    myDiagnoseBeforeSolve = true;
+}
+
 void PlaneGCSSolver_Solver::removeParameters(const GCS::SET_pD& theParams)
 {
   for (int i = (int)myParameters.size() - 1; i >= 0; --i)
@@ -71,6 +105,8 @@ void PlaneGCSSolver_Solver::removeParameters(const GCS::SET_pD& theParams)
       myParameters.erase(myParameters.begin() + i);
       --myDOF;
     }
+  if (!myConstraints.empty())
+    myDiagnoseBeforeSolve = true;
 }
 
 void PlaneGCSSolver_Solver::initialize()