From: mpv Date: Wed, 4 May 2016 11:09:38 +0000 (+0300) Subject: Fix for the issue 1479 X-Git-Tag: V_2.3.0~42 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=81d5849f5508f0e2ffba0e41c465517c8c5fcce4;p=modules%2Fshaper.git Fix for the issue 1479 --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 1bb1fd147..4dfabe551 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -496,8 +496,7 @@ std::set usedParameters(const AttributePoint2DPtr& theAttribute) return anUsedParameters; } -std::list findVariables(const std::set& theParameters, - const FeaturePtr& theParam) +std::list findVariables(const std::set& theParameters) { std::list aResult; std::set::const_iterator aParamIt = theParameters.cbegin(); @@ -505,7 +504,8 @@ std::list findVariables(const std::set& thePara const std::string& aName = *aParamIt; double aValue; ResultParameterPtr aParam; - if (ModelAPI_Tools::findVariable(theParam, aName, aValue, aParam)) + // theSearcher is not needed here: in expressions of features the parameters history is not needed + if (ModelAPI_Tools::findVariable(FeaturePtr(), aName, aValue, aParam)) aResult.push_back(aParam); } return aResult; @@ -565,25 +565,25 @@ void Model_Data::referencesToObjects( AttributeIntegerPtr anAttribute = std::dynamic_pointer_cast(anAttr->second); std::set anUsedParameters = anAttribute->usedParameters(); - std::list aParameters = findVariables(anUsedParameters, aMyFeature); + std::list aParameters = findVariables(anUsedParameters); aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end()); } else if (aType == ModelAPI_AttributeDouble::typeId()) { // double attribute AttributeDoublePtr anAttribute = std::dynamic_pointer_cast(anAttr->second); std::set anUsedParameters = anAttribute->usedParameters(); - std::list aParameters = findVariables(anUsedParameters, aMyFeature); + std::list aParameters = findVariables(anUsedParameters); aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end()); } else if (aType == GeomDataAPI_Point::typeId()) { // point attribute AttributePointPtr anAttribute = std::dynamic_pointer_cast(anAttr->second); std::set anUsedParameters = usedParameters(anAttribute); - std::list aParameters = findVariables(anUsedParameters, aMyFeature); + std::list aParameters = findVariables(anUsedParameters); aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end()); } else if (aType == GeomDataAPI_Point2D::typeId()) { // point attribute AttributePoint2DPtr anAttribute = std::dynamic_pointer_cast(anAttr->second); std::set anUsedParameters = usedParameters(anAttribute); - std::list aParameters = findVariables(anUsedParameters, aMyFeature); + std::list aParameters = findVariables(anUsedParameters); aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end()); } else continue; // nothing to do, not reference diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index acec054da..20073da7c 100755 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -115,7 +115,9 @@ bool findVariable(FeaturePtr theSearcher, const std::string& theName, double& ou if (aDocument != aRootDocument) { ResultPtr aPartResult = findPartResult(aRootDocument, aDocument); if (aPartResult.get()) { - FeaturePtr aPartFeature = aRootDocument->feature(aPartResult); + FeaturePtr aPartFeature; + if (theSearcher.get()) // only if the relative search is needed + aPartFeature = aRootDocument->feature(aPartResult); if (findVariable(aRootDocument, aPartFeature, theName, outValue, theParam)) return true; } diff --git a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp index 8f91a78c2..624b92319 100644 --- a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp +++ b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp @@ -105,7 +105,10 @@ double ParametersPlugin_EvalListener::evaluate(FeaturePtr theParameter, double aValue; ResultParameterPtr aParamRes; // If variable does not exist python interpreter will generate an error. It is OK. - if (!ModelAPI_Tools::findVariable(theParameter, *it, aValue, aParamRes, theParameter->document())) + // But due to the issue 1479 it should not check the history position of parameters relatively + // to feature that contains expression + if (!ModelAPI_Tools::findVariable(/*theParameter*/ FeaturePtr(), + *it, aValue, aParamRes, theParameter->document())) continue; aContext.push_back(*it + "=" + toStdString(aValue));