]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Correct DoF calculation when adding new entity into fully constrained sketch
authorazv <azv@opencascade.com>
Thu, 30 Mar 2017 08:03:04 +0000 (11:03 +0300)
committerazv <azv@opencascade.com>
Thu, 30 Mar 2017 08:06:31 +0000 (11:06 +0300)
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/SketchSolver_ConstraintFixed.cpp
src/SketchSolver/SketchSolver_Group.cpp

index 2be2d62b5ac9bc0472d6ecc262b4f4d06c8c9037..6681f2072f96824fc9d80764f2f4dd0aab2e2848 100644 (file)
@@ -52,8 +52,8 @@ double* PlaneGCSSolver_Solver::createParameter()
 {
   double* aResult = new double(0);
   myParameters.push_back(aResult);
-  if (myDOF >= 0)
-    ++myDOF;
+  if (myConstraints.empty() && myDOF >= 0)
+    ++myDOF; // calculate DoF by hand if and only if there is no constraints yet
   return aResult;
 }
 
@@ -133,3 +133,9 @@ int PlaneGCSSolver_Solver::dof()
     solve();
   return myDOF;
 }
+
+void PlaneGCSSolver_Solver::diagnose()
+{
+  myEquationSystem->declareUnknowns(myParameters);
+  myDOF = myEquationSystem->diagnose();
+}
index 4da9e60dc5aa116ed4db176f28dc0b1d6f52b323..9ac6212f76b73b10c133a529be659d29435e51d1 100644 (file)
@@ -52,6 +52,9 @@ public:
   /// \brief Check the constraint is conflicted with others
   bool isConflicting(const ConstraintID& theConstraint) const;
 
+  /// \brief Check conflicting/redundant constraints and DoF
+  void diagnose();
+
   /// \brief Degrees of freedom
   int dof();
 
index 472f4add7ccb80c7e4041f1171191d00e225c9ca..69b62e970495f766f060e2f8efe5567b2860e54d 100644 (file)
@@ -57,6 +57,10 @@ void PlaneGCSSolver_Storage::addTemporaryConstraint(
   if (myConstraintMap.empty())
     return; // no need to process temporary constraints if there is no active constraint
 
+  // before adding movement constraint to solver, re-check its DOF
+  if (mySketchSolver->dof() == 0)
+    mySketchSolver->diagnose();
+
   theSolverConstraint->setId(CID_MOVEMENT);
   constraintsToSolver(theSolverConstraint, mySketchSolver);
 }
index 41ba5d46b5622a7abd141024db70631cb9d23c60..721efb4a12d4d154c91e29584ed297c57911546d 100644 (file)
@@ -165,11 +165,14 @@ EntityWrapperPtr getChangedEntity(const FeaturePtr& theFeature,
   for (; aPIt != aPoints.end(); ++aPIt) {
     AttributePoint2DPtr aPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*aPIt);
     EntityWrapperPtr anEnt = theStorage->entity(*aPIt);
-    if (!anEnt)
-      continue;
-    PointWrapperPtr aPW = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anEnt);
-    if (!isSameCoordinates(aPnt, aPW))
-      aChangedPoints.push_back(anEnt);
+    if (anEnt) {
+      PointWrapperPtr aPW = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anEnt);
+      if (!isSameCoordinates(aPnt, aPW))
+        aChangedPoints.push_back(anEnt);
+    } else {
+      theStorage->update(*aPIt);
+      aChangedPoints.push_back(theStorage->entity(*aPIt));
+    }
   }
 
   EntityWrapperPtr aChanged;
index 26b960e2ab9f86102835c19d867f5366d8ad129e..fa98e284e79c2d4482bd83a15b4cf2e545e65647 100644 (file)
@@ -117,7 +117,8 @@ bool SketchSolver_Group::updateFeature(FeaturePtr theFeature)
 
 bool SketchSolver_Group::moveFeature(FeaturePtr theFeature)
 {
-  if (myDOF == 0) {
+  bool isFeatureExists = (myStorage->entity(theFeature).get() != 0);
+  if (myDOF == 0 && isFeatureExists) {
     // avoid moving elements of fully constrained sketch
     myStorage->refresh();
     return true;