]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Improve dumping folders to Python
authorazv <azv@opencascade.com>
Fri, 1 Dec 2017 11:44:18 +0000 (14:44 +0300)
committerazv <azv@opencascade.com>
Fri, 1 Dec 2017 11:44:18 +0000 (14:44 +0300)
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/ModelHighAPI/ModelHighAPI_Dumper.h
src/ModelHighAPI/ModelHighAPI_Folder.cpp

index 90b6655b7a03d76d15fc6873ca82e47b6ee17bfd..cf1c1f49a586a5b6a5f451635e0758e54097e5b8 100644 (file)
@@ -361,9 +361,20 @@ bool ModelHighAPI_Dumper::processSubs(
   // dump "setName" for composite feature
   if (isDumpSetName)
     dumpEntitySetName();
+  // dump folders if any
+  dumpFolders();
   return isOk;
 }
 
+void ModelHighAPI_Dumper::dumpFolders()
+{
+  std::set<FolderPtr>::const_iterator aFolderIt = myNotDumpedFolders.begin();
+  while (aFolderIt != myNotDumpedFolders.end()) {
+    FolderPtr aFolder = *aFolderIt++;
+    dumpFolder(aFolder);
+  }
+}
+
 void ModelHighAPI_Dumper::dumpSubFeatureNameAndColor(const std::string theSubFeatureGet,
                                                      const FeaturePtr& theSubFeature)
 {
@@ -498,7 +509,8 @@ bool ModelHighAPI_Dumper::isDumped(const EntityPtr& theEntity) const
 {
   EntityNameMap::const_iterator aFound = myNames.find(theEntity);
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theEntity);
-  return aFound != myNames.end() || myFeaturesToSkip.find(aFeature) != myFeaturesToSkip.end();
+  return (aFound != myNames.end() && aFound->second.myIsDumped) ||
+         myFeaturesToSkip.find(aFeature) != myFeaturesToSkip.end();
 }
 
 bool ModelHighAPI_Dumper::isDefaultColor(const ResultPtr& theResult) const
@@ -1019,11 +1031,7 @@ ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
   theDumper.myFullDump << aBufCopy;
 
   // now, store all not dumped folders
-  std::set<FolderPtr>::const_iterator aFolderIt = theDumper.myNotDumpedFolders.begin();
-  while (aFolderIt != theDumper.myNotDumpedFolders.end()) {
-    FolderPtr aFolder = *aFolderIt++;
-    theDumper.dumpFolder(aFolder);
-  }
+  theDumper.dumpFolders();
 
   return theDumper;
 }
index 5bba141688bab86cda0cb74df8ce2c783fc4a2cd..e029335983ea3c6e71ef5e769b3c6ba73a3ec85f 100644 (file)
@@ -289,6 +289,9 @@ private:
   /// Check the result feature has default transparency
   bool isDefaultTransparency(const ResultPtr& theResult) const;
 
+  /// Dump stored folders if possible
+  void dumpFolders();
+
 private:
   struct EntityName {
     std::string myCurrentName; ///< default name of current feature
index a4402a5e623cc1413f9ab9571b30d0739b005c47..047881482caca1714dc5491c7345d2bd4170452e 100644 (file)
@@ -21,6 +21,7 @@
 #include "ModelHighAPI_Folder.h"
 #include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Reference.h>
+#include <ModelHighAPI_Tools.h>
 
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_Document.h>
@@ -91,10 +92,10 @@ std::shared_ptr<ModelHighAPI_Folder> addFolder(const std::shared_ptr<ModelAPI_Do
   std::shared_ptr<ModelAPI_Folder> aFolder = theDoc->addFolder(theFirstFeature.feature());
 
   AttributeReferencePtr aFirstFeatAttr = aFolder->reference(ModelAPI_Folder::FIRST_FEATURE_ID());
-  theFirstFeature.fillAttribute(aFirstFeatAttr);
+  fillAttribute(theFirstFeature.feature(), aFirstFeatAttr);
 
   AttributeReferencePtr aLastFeatAttr = aFolder->reference(ModelAPI_Folder::LAST_FEATURE_ID());
-  theLastFeature.fillAttribute(aLastFeatAttr);
+  fillAttribute(theLastFeature.feature(), aLastFeatAttr);
 
   return std::shared_ptr<ModelHighAPI_Folder>(new ModelHighAPI_Folder(aFolder));
 }