From: azv Date: Tue, 5 Jul 2016 11:25:22 +0000 (+0300) Subject: Fix coincidence between rotated/translated entity and any other (issue #1607) X-Git-Tag: V_2.5.0~240 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7fc47bce8911891f594ae0f0039cba632076a19f;p=modules%2Fshaper.git Fix coincidence between rotated/translated entity and any other (issue #1607) --- diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp index aa24b78f2..0e32b3b78 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp @@ -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); diff --git a/src/SketchSolver/SketchSolver_ConstraintMulti.cpp b/src/SketchSolver/SketchSolver_ConstraintMulti.cpp index 206e8c11e..3994f776f 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMulti.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMulti.cpp @@ -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(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(); +} diff --git a/src/SketchSolver/SketchSolver_ConstraintMulti.h b/src/SketchSolver/SketchSolver_ConstraintMulti.h index 6254c1f00..5dfc0c1a7 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMulti.h +++ b/src/SketchSolver/SketchSolver_ConstraintMulti.h @@ -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 diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 285a55cbb..7e744deb3 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -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(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 aConflicting = myConflictingConstraints; diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 415f342b9..6eab8dadd 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -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 aSketchFeature = - std::dynamic_pointer_cast(theAttribute->owner()); + std::dynamic_pointer_cast(anAttribute->owner()); if (aSketchFeature && (aSketchFeature->isExternal() || isCopyInMulti(aSketchFeature, myConstraintMap))) aGroup = GID_OUTOFGROUP; aRelated = aBuilder->createAttribute(anAttribute, aGroup);