X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGEOM%2FGEOM_Engine.cxx;h=e89d43ec18e44fbf5b1963d4f142c243fbb0e7f3;hb=25a3dc91508bb59688142bc616b10facc61dfc3d;hp=d8ad0eb92f1a2512a81d6ecf1c4748879db98cbe;hpb=001d93f1ef3a53aa9df53b3589a0c72849b22a4e;p=modules%2Fgeom.git diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index d8ad0eb92..e89d43ec1 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -37,6 +37,7 @@ #include "utilities.h" #include +#include #include #include @@ -62,7 +63,9 @@ #include +#if OCC_VERSION_LARGE < 0x07050000 #include +#endif #include #include @@ -82,6 +85,7 @@ #ifdef _DEBUG_ static int MYDEBUG = 0; +using namespace std; #else static int MYDEBUG = 0; #endif @@ -113,7 +117,7 @@ bool ProcessFunction(Handle(GEOM_Function)& theFunction, TCollection_AsciiString& theScript, TCollection_AsciiString& theAfterScript, const TVariablesList& theVariables, - const bool theIsPublished, + const bool /*theIsPublished*/, TDF_LabelMap& theProcessed, std::set& theIgnoreObjs, bool& theIsDumpCollected); @@ -434,6 +438,10 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject) if(!_document) return false; // document is closed... + TDF_Label aLabel = theObject->GetEntry(); + if ( aLabel == aLabel.Root() ) + return false; // already removed object + //Remove an object from the map of available objects TCollection_AsciiString anID = BuildIDFromObject(theObject); if (_objects.IsBound(anID)) { @@ -462,7 +470,6 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject) aNode->Remove(); } - TDF_Label aLabel = theObject->GetEntry(); aLabel.ForgetAllAttributes(Standard_True); // Remember the label to reuse it then @@ -509,9 +516,13 @@ bool GEOM_Engine::Save(const char* theFileName) { if(!_document) return false; - _OCAFApp->SaveAs(_document, theFileName); +#if defined(WIN32) && defined(UNICODE) + std::wstring aFileName = Kernel_Utils::utf8_decode_s(theFileName); +#else + std::string aFileName = theFileName; +#endif - return true; + return _OCAFApp->SaveAs( _document, aFileName.c_str() ) == PCDM_SS_OK; } //============================================================================= @@ -521,8 +532,13 @@ bool GEOM_Engine::Save(const char* theFileName) //============================================================================= bool GEOM_Engine::Load(const char* theFileName) { +#if defined(WIN32) && defined(UNICODE) + std::wstring aFileName = Kernel_Utils::utf8_decode_s(theFileName); +#else + std::string aFileName = theFileName; +#endif Handle(TDocStd_Document) aDoc; - if (_OCAFApp->Open(theFileName, aDoc) != PCDM_RS_OK) { + if (_OCAFApp->Open(aFileName.c_str(), aDoc) != PCDM_RS_OK) { return false; } @@ -1265,7 +1281,7 @@ Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theStrin if(c == 58) isFound = Standard_True; } - if(isFound && arr[j-2] != 58) { // last char should be a diggit + if(isFound && arr[j-2] != 58) { // last char should be a digit aSeq->Append(i+1); // +1 because AsciiString starts from 1 aSeq->Append(j-1); } @@ -1287,13 +1303,13 @@ void ReplaceVariables(TCollection_AsciiString& theCommand, const TVariablesList& theVariables) { if (MYDEBUG) - cout<<"Command : "<GetCurrectState(); if(MYDEBUG) { - cout<<"Variables from SObject:"<= aVariables.size()) continue; @@ -1478,27 +1496,27 @@ void ReplaceVariables(TCollection_AsciiString& theCommand, } if(MYDEBUG) - cout<<"aSection before : "<healPyName( data._pyName, anEntry, aNameToEntry); @@ -1818,6 +1836,8 @@ TCollection_AsciiString GetPublishCommands if (!thePublished.count(theTag)) { // This object is not published yet. + thePublished.insert(theTag); + std::map< int, TCollection_AsciiString >::const_iterator anIt = theEntryToCmdMap.find(theTag); @@ -1826,7 +1846,7 @@ TCollection_AsciiString GetPublishCommands TIntToListIntMap::const_iterator aRefIt = theMapRefs.find(theTag); if (aRefIt != theMapRefs.end()) { - // Recursively publish all references. + // Recursively publish all references. std::list< int >::const_iterator aRefTagIt = aRefIt->second.begin(); for(; aRefTagIt != aRefIt->second.end(); ++aRefTagIt) { @@ -1840,8 +1860,6 @@ TCollection_AsciiString GetPublishCommands // Add the object command. aResult += anIt->second; } - - thePublished.insert(theTag); } return aResult; @@ -1911,7 +1929,7 @@ ObjectStates::~ObjectStates() //================================================================================ TState ObjectStates::GetCurrectState() const { - if(_states.size() > _dumpstate) + if((int)_states.size() > _dumpstate) return _states[_dumpstate]; return TState(); }