X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Folder.cpp;h=3640677a3a0b12de0009c615a7e44f95c51acd0a;hb=f03c02cd62fe508c65818d31fdf9dcf69f8cbf35;hp=a4402a5e623cc1413f9ab9571b30d0739b005c47;hpb=afcb6562f38474c4bfcbdd8269a377a697c85934;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Folder.cpp b/src/ModelHighAPI/ModelHighAPI_Folder.cpp index a4402a5e6..3640677a3 100644 --- a/src/ModelHighAPI/ModelHighAPI_Folder.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Folder.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,15 +12,15 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "ModelHighAPI_Folder.h" #include #include +#include #include #include @@ -58,22 +58,35 @@ bool ModelHighAPI_Folder::initialize() return true; } +void ModelHighAPI_Folder::setName(const std::string& theName) +{ + if (myFolder && myFolder->data() && myFolder->data()->isValid()) + myFolder->data()->setName(theName); +} + +std::string ModelHighAPI_Folder::name() const +{ + return myFolder->data()->name(); +} + void ModelHighAPI_Folder::dump(ModelHighAPI_Dumper& theDumper) const { const std::string& aDocName = theDumper.name(myFolder->document()); - AttributeReferencePtr aStartRef = myFolder->reference(ModelAPI_Folder::FIRST_FEATURE_ID()); - AttributeReferencePtr aEndRef = myFolder->reference(ModelAPI_Folder::LAST_FEATURE_ID()); + AttributeReferencePtr aStartRef = firstFeature(); + AttributeReferencePtr aEndRef = lastFeature(); - // Dump folder if it is empty or when its features have been already dumped. - // Otherwise, just store the name of the folder. + // do not dump empty folders if (!aEndRef->value()) - theDumper << myFolder << " = model.addFolder(" << aDocName << ")" << std::endl; - else if (theDumper.isDumped(aEndRef->value())) + return; + + // Dump folder when its features have been already dumped. + // Otherwise, store the folder postponed. + if (theDumper.isDumped(EntityPtr(aEndRef->value()))) theDumper << myFolder << " = model.addFolder(" << aDocName << ", " << aStartRef << ", " << aEndRef << ")" << std::endl; else - theDumper.name(myFolder); + theDumper.postpone(myFolder); } //-------------------------------------------------------------------------------------- @@ -91,10 +104,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)); }