Salome HOME
Adjust unit tests for Boolean Fill
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Dumper.cpp
index a5073da9e1ec3a84d6581afb1e64b45f228ecd9e..20e8ff20f36c221f489705c00c7b8ca20b1eb388 100644 (file)
@@ -214,7 +214,8 @@ void ModelHighAPI_Dumper::saveResultNames(const FeaturePtr& theFeature)
   const std::list<ResultPtr>& aResults = theFeature->results();
   std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
   for (int i = 0; aResIt != aResults.end(); ++aResIt, ++i) {
-    std::string aDefaultName = ModelAPI_Tools::getDefaultName(*aResIt, i);
+    std::pair<std::string, bool> aName = ModelAPI_Tools::getDefaultName(*aResIt, i);
+    std::string aDefaultName = aName.first;
     std::string aResName = (*aResIt)->data()->name();
 
     bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName);
@@ -229,7 +230,8 @@ void ModelHighAPI_Dumper::saveResultNames(const FeaturePtr& theFeature)
       for (int j = 0; j < aNbSubs; ++j) {
         ResultPtr aSub = aCompSolid->subResult(j);
         std::string aSubName = aSub->data()->name();
-        aDefaultName = ModelAPI_Tools::getDefaultName(aSub, j);
+        aName = ModelAPI_Tools::getDefaultName(aSub, j);
+        aDefaultName = aName.first;
 
         bool isUserDefinedSubName = isUserDefined || aDefaultName != aSubName;
         myNames[aSub] = EntityName(aSubName,
@@ -279,6 +281,8 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_Document>& theD
       }
     }
   }
+  // dump folders if any
+  dumpPostponed(true);
   return isOk;
 }
 
@@ -325,6 +329,8 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_CompositeFeatur
   // decrease composite features stack
   --gCompositeStackDepth;
 
+  // dump folders if any
+  dumpPostponed(true);
   return isOk;
 }
 
@@ -364,7 +370,7 @@ bool ModelHighAPI_Dumper::processSubs(
   if (isDumpSetName)
     dumpEntitySetName();
   // dump folders if any
-  dumpPostponed();
+  dumpPostponed(true);
   return isOk;
 }
 
@@ -375,7 +381,7 @@ void ModelHighAPI_Dumper::postpone(const EntityPtr& theEntity)
   myPostponed.push_back(theEntity);
 }
 
-void ModelHighAPI_Dumper::dumpPostponed()
+void ModelHighAPI_Dumper::dumpPostponed(bool theDumpFolders)
 {
   if (myDumpPostponedInProgress)
     return;
@@ -390,8 +396,12 @@ void ModelHighAPI_Dumper::dumpPostponed()
   std::list<EntityPtr>::const_iterator anIt = aPostponedCopy.begin();
   for (; anIt != aPostponedCopy.end(); ++anIt) {
     FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(*anIt);
-    if (aFolder)
-      dumpFolder(aFolder);
+    if (aFolder) {
+      if (theDumpFolders)
+        dumpFolder(aFolder);
+      else
+        myPostponed.push_back(*anIt);
+    }
     else {
       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
       if (aFeature)