Salome HOME
Issue #2394: Incorrect selected subsolids in "union" after modifying the geometry...
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Dumper.cpp
index ef0aee3c2ad356717cd8227c5d3415de233f3306..3cc97bdd22620f147b4173bb5cb71d8b30360a44 100644 (file)
@@ -329,8 +329,6 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_CompositeFeatur
   // decrease composite features stack
   --gCompositeStackDepth;
 
-  // dump folders if any
-  dumpPostponed(true);
   return isOk;
 }
 
@@ -369,8 +367,6 @@ bool ModelHighAPI_Dumper::processSubs(
   // dump "setName" for composite feature
   if (isDumpSetName)
     dumpEntitySetName();
-  // dump folders if any
-  dumpPostponed(true);
   return isOk;
 }
 
@@ -440,7 +436,8 @@ bool ModelHighAPI_Dumper::exportTo(const std::string& theFileName)
   if (!aFile.is_open())
     return false;
 
-  // standard header
+  // standard header (encoding + imported modules)
+  aFile << "# -*- coding: utf-8 -*-" << std::endl << std::endl;
   for (ModulesMap::const_iterator aModIt = myModules.begin();
        aModIt != myModules.end(); ++aModIt) {
     aFile << "from " << aModIt->first << " import ";
@@ -765,6 +762,12 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const FolderPtr& theFolder)
 {
   myDumpBuffer << name(theFolder);
+
+  // add dumped folder to a stack
+  if (!myNames[theFolder].myIsDumped &&
+     (myEntitiesStack.empty() || myEntitiesStack.top().myEntity != theFolder))
+    myEntitiesStack.push(LastDumpedEntity(theFolder, !myNames[theFolder].myIsDefault));
+
   return *this;
 }