]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fit incorrect movement of a line which boundary coincident to a point from another...
authorazv <azv@opencascade.com>
Thu, 9 Apr 2015 08:53:55 +0000 (11:53 +0300)
committerazv <azv@opencascade.com>
Thu, 9 Apr 2015 08:53:55 +0000 (11:53 +0300)
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_Constraint.h
src/SketchSolver/SketchSolver_ConstraintRigid.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h
src/SketchSolver/SketchSolver_Storage.cpp
src/SketchSolver/SketchSolver_Storage.h

index 1d2abb3547d3e51a4cec0234fcf0eb2c242176be..36bde98f820d2a17ad264f40cf414f4b4a3a3cda 100644 (file)
@@ -674,3 +674,10 @@ void SketchSolver_Constraint::calculateMiddlePoint(
   }
 }
 
+void SketchSolver_Constraint::makeTemporary() const
+{
+  std::vector<Slvs_hConstraint>::const_iterator anIt = mySlvsConstraints.begin();
+  for (; anIt != mySlvsConstraints.end(); anIt++)
+    myStorage->addTemporaryConstraint(*anIt);
+}
+
index 6cfe355f8aa159338b4e2d1b8a3c68a6beeafe92..134263412da5574997e456bb728db825191de3ef 100644 (file)
@@ -51,6 +51,9 @@ public:
   /// \brief Returns the type of constraint
   virtual int getType() const = 0;
 
+  /// \brief The constraint is made temoparary
+  void makeTemporary() const;
+
   /// \brief Checks the constraint is used by current object
   virtual bool hasConstraint(ConstraintPtr theConstraint) const
   { return theConstraint == myBaseConstraint; }
index 6c1875ccb062394d2df1312fad8271c1aeb43626..39e6f93eeb2be2bb1fac7759b1c42ecd8693d041 100644 (file)
@@ -52,7 +52,8 @@ void SketchSolver_ConstraintRigid::process()
     if (*anEntIter == SLVS_E_UNKNOWN)
       continue;
     Slvs_hConstraint aConstrID = myStorage->isPointFixed(*anEntIter);
-    bool isForceUpdate = (aConstrID != SLVS_E_UNKNOWN && !myBaseConstraint);
+    bool isForceUpdate = (aConstrID != SLVS_E_UNKNOWN && !myBaseConstraint &&
+                          myStorage->isTemporary(aConstrID));
     if (isEmpty && !isForceUpdate) { // create new constraint
       if (aConstrID != SLVS_E_UNKNOWN)
         continue; // the coincident point is already fixed
@@ -61,7 +62,7 @@ void SketchSolver_ConstraintRigid::process()
       aConstraint.h = myStorage->addConstraint(aConstraint);
       mySlvsConstraints.push_back(aConstraint.h);
       if (!myBaseConstraint)
-        myStorage->addTemporaryConstraint(aConstraint.h);
+        myStorage->addConstraintWhereDragged(aConstraint.h);
     } else { // update already existent constraint
       if (aConstrID == SLVS_E_UNKNOWN || myBaseConstraint)
         aConstrID = *aConstrIter;
@@ -69,7 +70,7 @@ void SketchSolver_ConstraintRigid::process()
       aConstraint.ptA = *anEntIter;
       myStorage->addConstraint(aConstraint);
       if (!myBaseConstraint)
-        myStorage->addTemporaryConstraint(aConstraint.h);
+        myStorage->addConstraintWhereDragged(aConstraint.h);
       if (!isEmpty) {
         aConstrIter++;
         isEmpty = aConstrIter == mySlvsConstraints.end();
@@ -86,7 +87,7 @@ void SketchSolver_ConstraintRigid::process()
     aConstraint.h = myStorage->addConstraint(aConstraint);
     mySlvsConstraints.push_back(aConstraint.h);
     if (!myBaseConstraint)
-      myStorage->addTemporaryConstraint(aConstraint.h);
+      myStorage->addConstraintWhereDragged(aConstraint.h);
   }
 }
 
@@ -226,7 +227,7 @@ void SketchSolver_ConstraintRigid::fixArc(const Slvs_Entity& theArc)
     aConstraint.h = myStorage->addConstraint(aConstraint);
     mySlvsConstraints.push_back(aConstraint.h);
     if (!myBaseConstraint)
-      myStorage->addTemporaryConstraint(aConstraint.h);
+      myStorage->addConstraintWhereDragged(aConstraint.h);
   }
 
   // Fix radius of the arc
@@ -242,7 +243,7 @@ void SketchSolver_ConstraintRigid::fixArc(const Slvs_Entity& theArc)
     aConstraint.h = myStorage->addConstraint(aConstraint);
     mySlvsConstraints.push_back(aConstraint.h);
     if (!myBaseConstraint)
-      myStorage->addTemporaryConstraint(aConstraint.h);
+      myStorage->addConstraintWhereDragged(aConstraint.h);
   }
 }
 
index ca39f6e2dd8dec896a863b41ff1b2b6922e46c7e..7fdc32a4c5e74b5c2c1ee514339fd2d28f60e298 100644 (file)
@@ -231,7 +231,7 @@ bool SketchSolver_Group::changeConstraint(
         continue;
       aConstraint->setGroup(this);
       aConstraint->setStorage(myStorage);
-      myTempConstraints.insert(aConstraint);
+      setTemporary(aConstraint);
     }
   }
   // Fix base features for mirror
@@ -273,7 +273,7 @@ void SketchSolver_Group::moveFeature(std::shared_ptr<SketchPlugin_Feature> theFe
     return;
   aConstraint->setGroup(this);
   aConstraint->setStorage(myStorage);
-  myTempConstraints.insert(aConstraint);
+  setTemporary(aConstraint);
 }
 
 // ============================================================================
@@ -295,7 +295,7 @@ void SketchSolver_Group::fixFeaturesList(AttributeRefListPtr theList)
       continue;
     aConstraint->setGroup(this);
     aConstraint->setStorage(myStorage);
-    myTempConstraints.insert(aConstraint);
+    setTemporary(aConstraint);
   }
 }
 
@@ -523,6 +523,7 @@ bool SketchSolver_Group::isConsistent()
 void SketchSolver_Group::removeTemporaryConstraints()
 {
   myTempConstraints.clear();
+  myStorage->removeTemporaryConstraints();
   // Clean lists of removed entities in the storage
   std::set<Slvs_hParam> aRemPar;
   std::set<Slvs_hEntity> aRemEnt;
@@ -562,3 +563,14 @@ bool SketchSolver_Group::isComplexConstraint(FeaturePtr theConstraint)
          theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID();
 }
 
+// ============================================================================
+//  Function: setTemporary
+//  Class:    SketchSolver_Group
+//  Purpose:  append given constraint to th group of temporary constraints
+// ============================================================================
+void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
+{
+  theConstraint->makeTemporary();
+  myTempConstraints.insert(theConstraint);
+}
+
index 534d48051b4ee4dac9185f58af6fdc0717ebfa0a..79f5f9fe04350c2ec7f5f4c7d0bbe9f3ee4342aa 100644 (file)
@@ -154,6 +154,9 @@ private:
   /// \brief Apply temporary rigid constraints for the list of features
   void fixFeaturesList(AttributeRefListPtr theList);
 
+  /// \brief Append given constraint to th group of temporary constraints
+  void setTemporary(SolverConstraintPtr theConstraint);
+
 private:
   Slvs_hGroup myID; ///< Index of the group
   Slvs_hEntity myWorkplaneID; ///< Index of workplane, the group is based on
index d4a5171322ad5701bd990264cbe94c8185c8c901..40d1d281f55e1c7afd4f5c8808720c2143833162 100644 (file)
@@ -318,7 +318,7 @@ std::list<Slvs_Constraint> SketchSolver_Storage::getConstraintsByType(int theCon
 }
 
 
-void SketchSolver_Storage::addTemporaryConstraint(const Slvs_hConstraint& theConstraintID)
+void SketchSolver_Storage::addConstraintWhereDragged(const Slvs_hConstraint& theConstraintID)
 {
   if (myFixed != SLVS_E_UNKNOWN)
     return; // the point is already fixed
@@ -327,6 +327,22 @@ void SketchSolver_Storage::addTemporaryConstraint(const Slvs_hConstraint& theCon
     myFixed = theConstraintID;
 }
 
+void SketchSolver_Storage::addTemporaryConstraint(const Slvs_hConstraint& theConstraintID)
+{
+  myTemporaryConstraints.insert(theConstraintID);
+}
+
+void SketchSolver_Storage::removeTemporaryConstraints()
+{
+  myTemporaryConstraints.clear();
+}
+
+bool SketchSolver_Storage::isTemporary(const Slvs_hConstraint& theConstraintID) const
+{
+  return myTemporaryConstraints.find(theConstraintID) != myTemporaryConstraints.end();
+}
+
+
 void SketchSolver_Storage::getRemoved(
     std::set<Slvs_hParam>& theParameters,
     std::set<Slvs_hEntity>& theEntities,
index cf04f47ab4c89112e1f9117b2a9b3d23ed73b5e7..a95d83c72c032a9b7bda639641a02fadf27e8c27 100644 (file)
@@ -87,8 +87,15 @@ public:
   /// \brief Returns list of constraints of specified type
   std::list<Slvs_Constraint> getConstraintsByType(int theConstraintType) const;
 
-  /// \brief Attach temporary constraint to this storage. It need to make precise calculations
+  /// \brief Attach constraint SLVS_C_WHERE_DRAGGED to this storage. It need to make precise calculations
+  void addConstraintWhereDragged(const Slvs_hConstraint& theConstraintID);
+
+  /// \brief Add transient constraint
   void addTemporaryConstraint(const Slvs_hConstraint& theConstraintID);
+  /// \brief Remove all transient constraints
+  void removeTemporaryConstraints();
+  /// \brief Checks the constraint is temporary
+  bool isTemporary(const Slvs_hConstraint& theConstraintID) const;
 
   /// \brief Shows the sketch should be resolved
   bool isNeedToResolve() const
@@ -129,6 +136,7 @@ private:
 
   bool myNeedToResolve; ///< parameters are changed and group needs to be resolved
 
+  std::set<Slvs_hConstraint> myTemporaryConstraints; ///< list of transient constraints
   std::set<Slvs_hParam> myRemovedParameters; ///< list of just removed parameters (cleared when returning to applicant)
   std::set<Slvs_hEntity> myRemovedEntities; ///< list of just removed entities (cleared when returning to applicant)
   std::set<Slvs_hConstraint> myRemovedConstraints; ///< list of just removed constraints (cleared when returning to applicant)