From f52f3839b7024daa1b4a4a418baa5178577c3ac3 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 18 Mar 2010 14:30:09 +0000 Subject: [PATCH] Mantis issue 0020768: Some Dump with RestoreSubShapes not loadable. Fix 2. --- src/GEOM/GEOM_Engine.cxx | 77 +++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index e6da3ad15..55c452288 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -116,7 +116,7 @@ bool ProcessFunction(Handle(GEOM_Function)& theFunction, std::set& theIgnoreObjs, bool& theIsDumpCollected); -void ReplaceVariables(TCollection_AsciiString& theCommand, +void ReplaceVariables(TCollection_AsciiString& theCommand, const TVariablesList& theVariables); Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theString); @@ -125,7 +125,9 @@ void ReplaceEntriesByNames (TCollection_AsciiString& theScript, Resource_DataMapOfAsciiStringAsciiString& theObjectNames, const bool theIsPublished, Resource_DataMapOfAsciiStringAsciiString& theEntryToBadName, - TColStd_SequenceOfAsciiString& theObjListToPublish); + TColStd_SequenceOfAsciiString& theObjListToPublish, + Standard_Integer& objectCounter, + Resource_DataMapOfAsciiStringAsciiString& aNameToEntry); void AddObjectColors (int theDocID, TCollection_AsciiString& theScript, @@ -401,7 +403,7 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject) int aDocID = theObject->GetDocID(); if(!_mapIDDocument.IsBound(aDocID)) return false; // document is closed... - + //Remove an object from the map of available objects TCollection_AsciiString anID = BuildIDFromObject(theObject); if (_objects.IsBound(anID)) _objects.UnBind(anID); @@ -565,7 +567,7 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, // collect objects entries to be published TColStd_SequenceOfAsciiString aObjListToPublish; - + // iterates on functions till critical (that requiers publication of objects) Handle(TDataStd_TreeNode) aNode, aRoot; Handle(GEOM_Function) aFunction; @@ -575,6 +577,10 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, TCollection_AsciiString aFuncScript; Resource_DataMapOfAsciiStringAsciiString anEntryToBadName; + // Mantis issue 0020768 + Standard_Integer objectCounter = 0; + Resource_DataMapOfAsciiStringAsciiString aNameToEntry; + if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) { TDataStd_ChildNodeIterator Itr(aRoot); for (; Itr.More(); Itr.Next()) { @@ -596,8 +602,9 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, if (isDumpCollected ) { // Replace entries by the names ReplaceEntriesByNames( aFuncScript, theObjectNames, - isPublished, anEntryToBadName, aObjListToPublish ); - + isPublished, anEntryToBadName, aObjListToPublish, + objectCounter, aNameToEntry ); + // publish collected objects std::map< int, std::string > anEntryToCommandMap; // sort publishing commands by object entry int i = 1, n = aObjListToPublish.Length(); @@ -614,7 +621,7 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, std::map< int, std::string >::iterator anEntryToCommand = anEntryToCommandMap.begin(); for ( ; anEntryToCommand != anEntryToCommandMap.end(); ++anEntryToCommand ) aFuncScript += (char*)anEntryToCommand->second.c_str(); - + // PTv, 0020001 add result objects from RestoreSubShapes into ignore list, // because they will be published during command execution int indx = anAfterScript.Search( "RestoreSubShapes" ); @@ -641,8 +648,9 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, // Replace entries by the names aObjListToPublish.Clear(); ReplaceEntriesByNames( aFuncScript, theObjectNames, - isPublished, anEntryToBadName, aObjListToPublish ); - + isPublished, anEntryToBadName, aObjListToPublish, + objectCounter, aNameToEntry ); + aScript += aFuncScript; // ouv : NPAL12872 @@ -732,7 +740,7 @@ Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const #define TEXTURE_LABEL_HEIGHT 4 #define TEXTURE_LABEL_DATA 5 -int GEOM_Engine::addTexture(int theDocID, int theWidth, int theHeight, +int GEOM_Engine::addTexture(int theDocID, int theWidth, int theHeight, const Handle(TDataStd_HArray1OfByte)& theTexture, const TCollection_AsciiString& theFileName) { @@ -770,7 +778,7 @@ int GEOM_Engine::addTexture(int theDocID, int theWidth, int theHeight, TDataStd_Integer::Set(aChild.FindChild(TEXTURE_LABEL_HEIGHT), theHeight); Handle(TDataStd_ByteArray) anAttr = - TDataStd_ByteArray::Set(aChild.FindChild(TEXTURE_LABEL_DATA), + TDataStd_ByteArray::Set(aChild.FindChild(TEXTURE_LABEL_DATA), theTexture.IsNull() ? 0 : theTexture->Lower(), theTexture.IsNull() ? 0 : theTexture->Upper()); anAttr->ChangeArray(theTexture); @@ -794,7 +802,7 @@ Handle(TDataStd_HArray1OfByte) GEOM_Engine::getTexture(int theDocID, int theText if (aTextureLabel.IsAttribute( GetTextureGUID())) { TDF_Label anIDLabel = aTextureLabel.FindChild(TEXTURE_LABEL_ID, Standard_False); Handle(TDataStd_Integer) anIdAttr; - if(!anIDLabel.IsNull() && anIDLabel.FindAttribute(TDataStd_Integer::GetID(), anIdAttr) && + if(!anIDLabel.IsNull() && anIDLabel.FindAttribute(TDataStd_Integer::GetID(), anIdAttr) && anIdAttr->Get() == theTextureID) { TDF_Label aFileLabel = aTextureLabel.FindChild(TEXTURE_LABEL_FILE, Standard_False); TDF_Label aWidthLabel = aTextureLabel.FindChild(TEXTURE_LABEL_WIDTH, Standard_False); @@ -975,11 +983,11 @@ Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theStrin //============================================================================= /*! - * ReplaceVariables: Replace parameters of the function by variales from + * ReplaceVariables: Replace parameters of the function by variales from * Notebook if need */ //============================================================================= -void ReplaceVariables(TCollection_AsciiString& theCommand, +void ReplaceVariables(TCollection_AsciiString& theCommand, const TVariablesList& theVariables) { if (MYDEBUG) @@ -1038,7 +1046,7 @@ void ReplaceVariables(TCollection_AsciiString& theCommand, if(MYDEBUG) cout<<"Sub-entry : '" < 0 ) aEndPos = aCommand.Location(aFirstParam, COMMA, 1, aCommand.Length()); else - aEndPos = aCommand.Location(C_BRACKET, 1, aCommand.Length()); + aEndPos = aCommand.Location(C_BRACKET, 1, aCommand.Length()); } //Replace last parameter (bettwen ',' character and ')' character) else if(i == aTotalNbParams) @@ -1105,14 +1113,14 @@ void ReplaceVariables(TCollection_AsciiString& theCommand, if ( aStartPos == aEndPos ) continue; // PAL20889: for "[]" - if(MYDEBUG) + if(MYDEBUG) cout<<"aStartPos = "<= aVariables.size()) @@ -1167,27 +1175,27 @@ void ReplaceVariables(TCollection_AsciiString& theCommand, aReplacedParameter.InsertAfter(aReplacedParameter.Length(),"'"); } - if(MYDEBUG) + if(MYDEBUG) cout<<"aSection before : "<Length(), objectCounter = 0, aStart = 1, aScriptLength = theScript.Length(); - Resource_DataMapOfAsciiStringAsciiString aNameToEntry; + //Standard_Integer objectCounter = 0; + Standard_Integer aLen = aSeq->Length(), aStart = 1, aScriptLength = theScript.Length(); + //Resource_DataMapOfAsciiStringAsciiString aNameToEntry; //Replace entries by the names TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("geomObj_"), @@ -1345,7 +1356,7 @@ void AddObjectColors (int theDocID, aCommand += aName + ".SetColor(SALOMEDS.Color(" + aColor.R + "," + aColor.G + "," + aColor.B + "))"; theScript += aCommand.ToCString(); } - + Aspect_TypeOfMarker aMarkerType = obj->GetMarkerType(); if (aMarkerType >= Aspect_TOM_POINT && aMarkerType < Aspect_TOM_USERDEFINED) { TCollection_AsciiString aCommand( "\n\t" ); @@ -1423,7 +1434,7 @@ void AddTextures (int theDocID, TCollection_AsciiString& theScript) if (allTextures.size() > 0) { theScript += "\n\ttexture_map = {}\n"; - + for (it = allTextures.begin(); it != allTextures.end(); ++it) { if (*it <= 0) continue; Standard_Integer aWidth, aHeight; @@ -1531,7 +1542,7 @@ TState ObjectStates::GetCurrectState() const //================================================================================ /*! - * \brief Add new object state + * \brief Add new object state * \param theState - Object state (vector of notebook variable) */ //================================================================================ -- 2.39.2