X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Document.cpp;h=c4fb2e7aaa8c1003d46b2782231fad0ed83f5ae3;hb=3704e9a9bdb395cfe86e54ac53ef0ac91d8350bd;hp=deff00477196890fdcfa8334b475ae4a4007e9b6;hpb=3874b57fe5aba25ff5aee2a07654fc23c1ee8eb0;p=modules%2Fshaper.git diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index deff00477..c4fb2e7aa 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #ifndef WIN32 @@ -48,6 +50,11 @@ static const int TAG_HISTORY = 3; // tag of the history sub-tree (python dump) static const int TAG_FEATURE_ARGUMENTS = 1; ///< where the arguments are located static const int TAG_FEATURE_RESULTS = 2; ///< where the results are located +/// +/// 0:1:2 - where features are located +/// 0:1:2:N:1 - data of the feature N +/// 0:1:2:N:2:K:1 - data of the K result of the feature N + Model_Document::Model_Document(const std::string theID, const std::string theKind) : myID(theID), myKind(theKind), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format @@ -161,6 +168,7 @@ bool Model_Document::load(const char* theFileName) bool Model_Document::save(const char* theFileName, std::list& theResults) { // create a directory in the root document if it is not yet exist + Handle(Model_Application) anApp = Model_Application::getApplication(); if (this == Model_Session::get()->moduleDocument().get()) { #ifdef WIN32 CreateDirectory(theFileName, NULL); @@ -172,7 +180,7 @@ bool Model_Document::save(const char* theFileName, std::list& theRe TCollection_ExtendedString aPath(DocFileName(theFileName, myID)); PCDM_StoreStatus aStatus; try { - aStatus = Model_Application::getApplication()->SaveAs(myDoc, aPath); + aStatus = anApp->SaveAs(myDoc, aPath); } catch (Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Events_Error::send( @@ -201,6 +209,32 @@ bool Model_Document::save(const char* theFileName, std::list& theRe for (; aSubIter != mySubs.end() && isDone; aSubIter++) { isDone = subDoc(*aSubIter)->save(theFileName, theResults); } + if (isDone) { // also try to copy the not-activated sub-documents + // they are not in mySubs but as ResultParts + int aPartsNum = size(ModelAPI_ResultPart::group()); + for(int aPart = 0; aPart < aPartsNum; aPart++) { + ResultPartPtr aPartRes = std::dynamic_pointer_cast + (object(ModelAPI_ResultPart::group(), aPart)); + if (aPartRes) { + std::string aDocName = aPartRes->data()->name(); + if (!aDocName.empty() && mySubs.find(aDocName) == mySubs.end()) { + // just copy file + TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName)); + OSD_Path aPath(aSubPath); + OSD_File aFile(aPath); + if (aFile.Exists()) { + TCollection_AsciiString aDestinationDir(DocFileName(theFileName, aDocName)); + OSD_Path aDestination(aDestinationDir); + aFile.Copy(aDestination); + theResults.push_back(aDestinationDir.ToCString()); + } else { + Events_Error::send( + std::string("Can not open file ") + aSubPath.ToCString() + " for saving"); + } + } + } + } + } } return isDone; } @@ -1061,3 +1095,16 @@ Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2) { return TDF_LabelMapHasher::IsEqual(theLab1, theLab2); } + +void Model_Document::addNamingName(const TDF_Label theLabel, std::string theName) +{ + myNamingNames[theName] = theLabel; +} + +TDF_Label Model_Document::findNamingName(std::string theName) +{ + std::map::iterator aFind = myNamingNames.find(theName); + if (aFind == myNamingNames.end()) + return TDF_Label(); // not found + return aFind->second; +}