Salome HOME
Fix the problem with updating of an arc by moving a line which has coincident point...
authorazv <azv@opencascade.com>
Fri, 10 Apr 2015 10:19:45 +0000 (13:19 +0300)
committerazv <azv@opencascade.com>
Fri, 10 Apr 2015 10:20:38 +0000 (13:20 +0300)
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_Constraint.h
src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp
src/SketchSolver/SketchSolver_ConstraintCoincidence.h
src/SketchSolver/SketchSolver_Group.cpp

index 946ee0edee685fc23f5f0ea0127873c270387591..2a2c85f383839a78c2844797a789d5f8edf6dd41 100644 (file)
@@ -62,6 +62,12 @@ void SketchSolver_Constraint::setGroup(SketchSolver_Group* theGroup)
   process();
 }
 
+void SketchSolver_Constraint::addFeature(FeaturePtr theFeature)
+{
+  int aType;
+  changeEntity(theFeature, aType);
+}
+
 
 void SketchSolver_Constraint::process()
 {
@@ -527,7 +533,7 @@ void SketchSolver_Constraint::refresh()
         }
         if (fabs(aPoint2D->x() - aXY[0]) > tolerance ||
             fabs(aPoint2D->y() - aXY[1]) > tolerance)
-        aPoint2D->setValue(aXY[0], aXY[1]);
+          aPoint2D->setValue(aXY[0], aXY[1]);
       } else {
         // Scalar value (used for the distance entities)
         AttributeDoublePtr aScalar =
index 134263412da5574997e456bb728db825191de3ef..b6ff8f55bdca282594442ec350b5e550d3bb3464 100644 (file)
@@ -66,6 +66,9 @@ public:
   /// \brief Return identifier of SolveSpace entity relating to the attribute
   Slvs_hEntity getId(AttributePtr theAttribute) const;
 
+  /// \brief Adds a feature to constraint and create its analogue in SolveSpace
+  void addFeature(FeaturePtr theFeature);
+
   /// \brief Shows error message
   const std::string& error() const
   { return myErrorMsg; }
index 2ae6bf381b4922a07398f41495e7f3254fc3fd12..bfa65c19ec3f50ccf8afdd0621f378d76f86df67 100644 (file)
@@ -28,13 +28,9 @@ std::list<ConstraintPtr> SketchSolver_ConstraintCoincidence::constraints() const
 bool SketchSolver_ConstraintCoincidence::isCoincide(
     std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint) const
 {
-  std::map<FeaturePtr, Slvs_hEntity>::const_iterator aFeatIter = myFeatureMap.begin();
-  for (; aFeatIter != myFeatureMap.end(); aFeatIter++)
-    if (theConstraint->myFeatureMap.find(aFeatIter->first) != theConstraint->myFeatureMap.end())
-      return true;
-  std::map<AttributePtr, Slvs_hEntity>::const_iterator anAttrIter = myAttributeMap.begin();
-  for (; anAttrIter != myAttributeMap.end(); anAttrIter++)
-    if (theConstraint->myAttributeMap.find(anAttrIter->first) != theConstraint->myAttributeMap.end())
+  std::set<AttributePtr>::const_iterator anAttrIter = theConstraint->myCoincidentPoints.begin();
+  for (; anAttrIter != theConstraint->myCoincidentPoints.end(); anAttrIter++)
+    if (myCoincidentPoints.find(*anAttrIter) != myCoincidentPoints.end())
       return true;
   return false;
 }
@@ -96,6 +92,7 @@ void SketchSolver_ConstraintCoincidence::addConstraint(ConstraintPtr theConstrai
     if (anEntityID == SLVS_E_UNKNOWN)
       anEntityID = changeEntity(aRefAttr->attr(), aType);
     anEntities.push_back(anEntityID);
+    myCoincidentPoints.insert(aRefAttr->attr());
   }
 
   Slvs_Constraint aBaseCoincidence = myStorage->getConstraint(mySlvsConstraints.front());
@@ -176,6 +173,7 @@ bool SketchSolver_ConstraintCoincidence::remove(ConstraintPtr theConstraint)
   while (anAttrIter != myAttributeMap.end()) {
     if (anEntRemoved.find(anAttrIter->second) != anEntRemoved.end()) {
       std::map<AttributePtr, Slvs_hEntity>::iterator aTempIt = anAttrIter++;
+      myCoincidentPoints.erase(aTempIt->first);
       myAttributeMap.erase(aTempIt);
       continue;
     }
index f726020c766e3e76bb1112bd8a1288523e152541..e8cbb8e402759896ac983a6bc8221e20ceef874c 100644 (file)
@@ -50,6 +50,7 @@ private:
 
 private:
   std::map<Slvs_hConstraint, ConstraintPtr> myExtraCoincidence; ///< multiple coincidence of points
+  std::set<AttributePtr> myCoincidentPoints; ///< list of points under the Coincidence constraint
 };
 
 #endif
index 5a6e9802a453cb959a3c9f6af4ea9e4e6d60d3db..3c5832cdb793c7155a872ba79dce491c84416a0e 100644 (file)
@@ -258,6 +258,10 @@ bool SketchSolver_Group::updateFeature(std::shared_ptr<SketchPlugin_Feature> the
   std::set<ConstraintPtr>::iterator aCIter = aConstraints.begin();
   for (; aCIter != aConstraints.end(); aCIter++) {
     ConstraintConstraintMap::iterator aSolConIter = myConstraints.find(*aCIter);
+    if (aSolConIter == myConstraints.end())
+      continue;
+    myFeatureStorage->changeFeature(theFeature, aSolConIter->first);
+    aSolConIter->second->addFeature(theFeature);
     aSolConIter->second->update();
   }
   return true;