From: azv Date: Fri, 21 Apr 2017 11:38:46 +0000 (+0300) Subject: Issue #2139: Lines attached to Extern lines can be moved X-Git-Tag: V_2.7.1~49 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=db767e51bfd7c4818abcdffbedb3dd78017b8463;p=modules%2Fshaper.git Issue #2139: Lines attached to Extern lines can be moved Check the feature is a projection before converting it to the data structure applicable for the solver. --- diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index b68c6aae5..64d9c7fb5 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -131,22 +131,22 @@ static bool updateValues(AttributePtr& theAttribute, EntityWrapperPtr& theEntity return isUpdated; } -static bool isCopyInMulti(std::shared_ptr theFeature) +static bool hasReference(std::shared_ptr theFeature, + const std::string& theFeatureKind) { - if (!theFeature) - return false; - - bool aResult = theFeature->isCopy(); - if (aResult) { - const std::set& aRefs = theFeature->data()->refsToMe(); - for (std::set::const_iterator aRefIt = aRefs.begin(); - aRefIt != aRefs.end() && aResult; ++aRefIt) { - FeaturePtr anOwner = ModelAPI_Feature::feature((*aRefIt)->owner()); - if (anOwner->getKind() == SketchPlugin_Projection::ID()) - aResult = false; - } + const std::set& aRefs = theFeature->data()->refsToMe(); + for (std::set::const_iterator aRefIt = aRefs.begin(); + aRefIt != aRefs.end(); ++aRefIt) { + FeaturePtr anOwner = ModelAPI_Feature::feature((*aRefIt)->owner()); + if (anOwner->getKind() == theFeatureKind) + return true; } - return aResult; + return false; +} + +static bool isCopyFeature(std::shared_ptr theFeature) +{ + return theFeature && theFeature->isCopy(); } bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce) @@ -159,13 +159,16 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce) else { // Feature is not exist, create it std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(theFeature); - bool isCopy = isCopyInMulti(aSketchFeature); + bool isCopy = isCopyFeature(aSketchFeature); + bool isProjReferred = hasReference(aSketchFeature, SketchPlugin_Projection::ID()); // the feature is a copy in "Multi" constraint and does not used in other constraints - if (!theForce && isCopy && myFeatureMap.find(theFeature) == myFeatureMap.end()) + if (!theForce && (isCopy && !isProjReferred) && + myFeatureMap.find(theFeature) == myFeatureMap.end()) return false; // external feature processing - bool isExternal = (aSketchFeature && (aSketchFeature->isExternal() || isCopy)); + bool isExternal = + (aSketchFeature && (aSketchFeature->isExternal() || isCopy || isProjReferred)); PlaneGCSSolver_FeatureBuilder aBuilder(isExternal ? 0 : this); diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index bf0746fdb..cee34791d 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -169,6 +169,7 @@ bool SketchSolver_Group::resolveConstraints() aResult = mySketchSolver->solve(); if (aResult == PlaneGCSSolver_Solver::STATUS_FAILED && !myTempConstraints.empty()) { + mySketchSolver->undo(); removeTemporaryConstraints(); aResult = mySketchSolver->solve(); }