From: azv Date: Fri, 1 Dec 2017 11:44:18 +0000 (+0300) Subject: Improve dumping folders to Python X-Git-Tag: V_2.10.0RC~123^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0e74bf1f4c46e3642940531f99f07c84f8c1fbe6;p=modules%2Fshaper.git Improve dumping folders to Python --- diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 90b6655b7..cf1c1f49a 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -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::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(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::const_iterator aFolderIt = theDumper.myNotDumpedFolders.begin(); - while (aFolderIt != theDumper.myNotDumpedFolders.end()) { - FolderPtr aFolder = *aFolderIt++; - theDumper.dumpFolder(aFolder); - } + theDumper.dumpFolders(); return theDumper; } diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.h b/src/ModelHighAPI/ModelHighAPI_Dumper.h index 5bba14168..e02933598 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.h +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.h @@ -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 diff --git a/src/ModelHighAPI/ModelHighAPI_Folder.cpp b/src/ModelHighAPI/ModelHighAPI_Folder.cpp index a4402a5e6..047881482 100644 --- a/src/ModelHighAPI/ModelHighAPI_Folder.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Folder.cpp @@ -21,6 +21,7 @@ #include "ModelHighAPI_Folder.h" #include #include +#include #include #include @@ -91,10 +92,10 @@ std::shared_ptr addFolder(const std::shared_ptr 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(new ModelHighAPI_Folder(aFolder)); }