]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix coincidence between rotated/translated entity and any other (issue #1607)
authorazv <azv@opencascade.com>
Tue, 5 Jul 2016 11:25:22 +0000 (14:25 +0300)
committerazv <azv@opencascade.com>
Tue, 5 Jul 2016 11:25:22 +0000 (14:25 +0300)
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/SketchSolver_ConstraintMulti.cpp
src/SketchSolver/SketchSolver_ConstraintMulti.h
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Storage.cpp

index aa24b78f262f2ab30b554135ac3d1feddf5b5bfa..0e32b3b783a8ad1304644e46282fe70b1285a962 100644 (file)
@@ -79,7 +79,7 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve()
   // solve equations
   if (aResult == GCS::Success)
     aResult = (GCS::SolveStatus)myEquationSystem.solve(myParameters);
-  if (aResult == GCS::Success) {
+  if (aResult == GCS::Success || aResult == GCS::Converged) {
     // additionally check redundant constraints
     GCS::VEC_I aRedundantID;
     myEquationSystem.getRedundant(aRedundantID);
@@ -102,6 +102,8 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve()
     // Need to check if there are redundant constraints without these tangencies.
     if (!aRedundantID.empty())
       aResult = myTangent.empty() ? GCS::Failed : (GCS::SolveStatus)solveWithoutTangent();
+    else
+      aResult = GCS::Success;
   }
   Events_LongOp::end(this);
 
index 206e8c11e290745ca59b90ab2a3e44cb2faf67e3..3994f776fba6829726dac40b550651f04ea588da 100644 (file)
@@ -179,6 +179,13 @@ void SketchSolver_ConstraintMulti::adjustConstraint()
       // update feature in the storage if it is used by another constraints
       if (anEntity)
         myStorage->update(aFeature);
+      else { // update attributes, if they exist in the storage
+        for (aPtIt = aPoints.begin(); aPtIt != aPoints.end(); ++aPtIt) {
+          EntityWrapperPtr aPntEnt = myStorage->entity(*aPtIt);
+          if (aPntEnt)
+            myStorage->update(*aPtIt);
+        }
+      }
 
       if (!anEntity || !myStorage->isEventsBlocked())
         aFeature->data()->blockSendAttributeUpdated(false);
@@ -193,3 +200,19 @@ bool SketchSolver_ConstraintMulti::isUsed(FeaturePtr theFeature) const
   return myFeatures.find(theFeature) != myFeatures.end() ||
          SketchSolver_Constraint::isUsed(theFeature);
 }
+
+bool SketchSolver_ConstraintMulti::isUsed(AttributePtr theAttribute) const
+{
+  AttributePtr anAttribute = theAttribute;
+  AttributeRefAttrPtr aRefAttr =
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttribute);
+  if (aRefAttr) {
+    if (aRefAttr->isObject())
+      return isUsed(ModelAPI_Feature::feature(aRefAttr->object()));
+    else
+      anAttribute = aRefAttr->attr();
+  }
+
+  FeaturePtr anOwner = ModelAPI_Feature::feature(anAttribute->owner());
+  return myFeatures.find(anOwner) != myFeatures.end();
+}
index 6254c1f0054ac043ce564b948f80c8f291d86290..5dfc0c1a7a6446336e430fc6c34506e4f63efa7d 100644 (file)
@@ -39,6 +39,8 @@ public:
 
   /// \brief Check the feature is a source or a copy of Multi-constraint
   virtual bool isUsed(FeaturePtr theFeature) const;
+  /// \brief Check the attribute is used in Multi-constraint
+  virtual bool isUsed(AttributePtr theAttribute) const;
 
 protected:
   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
index 285a55cbb364cc0d79f1ea183d9aa87ce71680a8..7e744deb37707fc75fdee4774e58253ef110cdc0 100644 (file)
@@ -130,8 +130,21 @@ bool SketchSolver_Group::isInteract(FeaturePtr theFeature) const
   ConstraintConstraintMap::const_iterator anIt = myConstraints.begin();
   for (; !isInteracted && anIt != myConstraints.end(); ++anIt)
     if (anIt->first->getKind() == SketchPlugin_MultiRotation::ID() ||
-        anIt->first->getKind() == SketchPlugin_MultiTranslation::ID())
+        anIt->first->getKind() == SketchPlugin_MultiTranslation::ID()) {
       isInteracted = anIt->second->isUsed(theFeature);
+      if (isInteracted)
+        break;
+      // if theFeature is a constraint, check its attributes
+      ConstraintPtr aConstraint = std::dynamic_pointer_cast<SketchPlugin_Constraint>(theFeature);
+      if (!aConstraint)
+        continue;
+      for (int i = 0; i < 4 && !isInteracted; ++i) {
+        AttributeRefAttrPtr aRefAttr = aConstraint->refattr(aConstraint->ATTRIBUTE(i));
+        if (!aRefAttr)
+          continue;
+        isInteracted = anIt->second->isUsed(aRefAttr);
+      }
+    }
   return isInteracted;
 }
 
@@ -374,8 +387,12 @@ bool SketchSolver_Group::resolveConstraints()
       return false;
     }
     if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) {  // solution succeeded, store results into correspondent attributes
+      myStorage->setNeedToResolve(false);
       myStorage->refresh();
       updateMultiConstraints(myConstraints);
+      if (myStorage->isNeedToResolve()) // multi-constraints updated some parameters, need to store them
+        myStorage->refresh();
+
       if (myPrevResult != STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
         getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue("");
         std::set<ObjectPtr> aConflicting = myConflictingConstraints;
index 415f342b94b30b9c8b17a93e7669f76bb57fb406..6eab8dadd7dc84938e9eb704f6f12556ad87909d 100644 (file)
@@ -254,7 +254,7 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG
     GroupID aGroup = theGroup != GID_UNKNOWN ? theGroup : myGroupID;
     // Check attribute of external features
     std::shared_ptr<SketchPlugin_Feature> aSketchFeature = 
-        std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
+        std::dynamic_pointer_cast<SketchPlugin_Feature>(anAttribute->owner());
     if (aSketchFeature && (aSketchFeature->isExternal() || isCopyInMulti(aSketchFeature, myConstraintMap)))
       aGroup = GID_OUTOFGROUP;
     aRelated = aBuilder->createAttribute(anAttribute, aGroup);