Salome HOME
Issue #20456: Another dump study fails
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Tue, 22 Dec 2020 05:59:54 +0000 (08:59 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Tue, 22 Dec 2020 05:59:54 +0000 (08:59 +0300)
Fix regressions in 'test.models'.

src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModelHighAPI/ModelHighAPI_Dumper.cpp

index 8c03b9ab3007f957e04ad704c09954659464e79d..c5985e310984f62d253f2ccac65e939a81a72bc0 100644 (file)
@@ -617,7 +617,8 @@ void getConcealedResults(const FeaturePtr& theFeature,
 }
 
 std::pair<std::wstring, bool> getDefaultName(const std::shared_ptr<ModelAPI_Result>& theResult,
-                                            const bool theInherited)
+                                             const bool theInherited,
+                                             const bool theRecursive)
 {
   typedef std::list< std::pair < std::string, std::list<ObjectPtr> > > ListOfReferences;
 
@@ -707,7 +708,7 @@ std::pair<std::wstring, bool> getDefaultName(const std::shared_ptr<ModelAPI_Resu
       // return name of reference result only if it has been renamed by the user,
       // in other case compose a default name
       if (anObjRes->data()->hasUserDefinedName() ||
-          anObjRes->data()->name() != getDefaultName(anObjRes).first) {
+          (theRecursive && anObjRes->data()->name() != getDefaultName(anObjRes).first)) {
         std::wstringstream aName;
         aName << anObjRes->data()->name();
         std::map<ResultPtr, int>::iterator aFound = aNbRefToObject.find(anObjRes);
index 5fd96b9177157036ded985c774a4c140491f9535..ab4633d98426bd51ea20bf6359a326a52ba27fb7 100644 (file)
@@ -198,9 +198,12 @@ MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr<ModelAPI_Feature>
 /*! Return the default name of the result according the features it depends or name of the feature.
  *  Return also whether the name is get from the concealing result of parent object
  *  (means that concealing result has user-defined name).
+ * \param[in] theRecursive  recursively check the concealed results if they have user-defined names
  */
 MODELAPI_EXPORT std::pair<std::wstring, bool> getDefaultName(
-  const std::shared_ptr<ModelAPI_Result>& theResult, const bool theInherited = true);
+  const std::shared_ptr<ModelAPI_Result>& theResult,
+  const bool theInherited = true,
+  const bool theRecursive = false);
 
 /*! Collect all parents for the given feature, including the Part
  */
index cb2323165a7bb9ca24b33b025f69f80418ee284c..33d8cb39a69f0b712c1698e250e5d1ac14540f80 100644 (file)
@@ -687,7 +687,7 @@ void ModelHighAPI_Dumper::saveResultNames(const FeaturePtr& theFeature)
   std::list<ResultPtr> allRes;
   ModelAPI_Tools::allResults(theFeature, allRes);
   for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
-    std::pair<std::wstring, bool> aName = ModelAPI_Tools::getDefaultName(*aRes);
+    std::pair<std::wstring, bool> aName = ModelAPI_Tools::getDefaultName(*aRes, true, true);
     std::string aDefaultName = Locale::Convert::toString(aName.first);
     std::string aResName = Locale::Convert::toString((*aRes)->data()->name());
     bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName);