From aaa5aa61bb2d64fa3da6f8c907070200c4575ba0 Mon Sep 17 00:00:00 2001 From: ptv Date: Wed, 10 Jun 2009 11:36:36 +0000 Subject: [PATCH] IMP 0020001 (replace set of GetInPlace commands by one RestoreSubShapes) --- idl/GEOM_Gen.idl | 20 +- src/GEOM/GEOM_Engine.cxx | 472 ++++++++++++++++++++++++++------------- src/GEOM_I/GEOM_Gen_i.cc | 466 ++++++++++++++++++++++++-------------- src/GEOM_I/GEOM_Gen_i.hh | 32 +-- 4 files changed, 643 insertions(+), 347 deletions(-) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index c554fd002..439e6f438 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2991,11 +2991,11 @@ module GEOM * considered as True, not regarding really passed value. * \return True in case of success, False otherwise. */ - boolean RestoreSubShapesO (in SALOMEDS::Study theStudy, - in GEOM_Object theObject, - in ListOfGO theArgs, - in find_shape_method theFindMethod, - in boolean theInheritFirstArg); + ListOfGO RestoreSubShapesO (in SALOMEDS::Study theStudy, + in GEOM_Object theObject, + in ListOfGO theArgs, + in find_shape_method theFindMethod, + in boolean theInheritFirstArg); /*! * Publish sub-shapes, standing for arguments and sub-shapes of arguments @@ -3003,11 +3003,11 @@ module GEOM * Work like the above method, but accepts study object theSObject instead of GEOM_Object. * \param theSObject study object, referencing GEOM object, arguments of which will be published */ - boolean RestoreSubShapesSO (in SALOMEDS::Study theStudy, - in SALOMEDS::SObject theSObject, - in ListOfGO theArgs, - in find_shape_method theFindMethod, - in boolean theInheritFirstArg); + ListOfGO RestoreSubShapesSO (in SALOMEDS::Study theStudy, + in SALOMEDS::SObject theSObject, + in ListOfGO theArgs, + in find_shape_method theFindMethod, + in boolean theInheritFirstArg); /*! * Methods to access interfaces for objects creation and transformation diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index a47aec8cd..2ec87cbcf 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -102,19 +102,38 @@ static Standard_Integer ExtractDocID(TCollection_AsciiString& theID) return aDocID.IntegerValue(); } -void ProcessFunction(Handle(GEOM_Function)& theFunction, +bool ProcessFunction(Handle(GEOM_Function)& theFunction, TCollection_AsciiString& theScript, + TCollection_AsciiString& theAfterScript, const TVariablesList& theVariables, + const bool theIsPublished, TDF_LabelMap& theProcessed, - std::set& theDumpedObjs); + std::set& theIgnoreObjs, + bool& theIsDumpCollected); void ReplaceVariables(TCollection_AsciiString& theCommand, const TVariablesList& theVariables); - - Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theString); +void ReplaceEntriesByNames (TCollection_AsciiString& theScript, + Resource_DataMapOfAsciiStringAsciiString& theObjectNames, + const bool theIsPublished, + Resource_DataMapOfAsciiStringAsciiString& theEntryToBadName, + TColStd_SequenceOfAsciiString& theObjListToPublish); + +void AddObjectColors (const Handle(TDocStd_Document)& theDoc, + TCollection_AsciiString& theScript, + const Resource_DataMapOfAsciiStringAsciiString& theObjectNames); + +void PublishObject (const TCollection_AsciiString& theEntry, + const TCollection_AsciiString& theName, + const Resource_DataMapOfAsciiStringAsciiString& theObjectNames, + const Resource_DataMapOfAsciiStringAsciiString& theEntry2StEntry, + const Resource_DataMapOfAsciiStringAsciiString& theStEntry2Entry, + const Resource_DataMapOfAsciiStringAsciiString& theEntryToBadName, + std::map< int, std::string >& theEntryToCommandMap, + std::set& theMapOfPublished); //============================================================================= /*! @@ -477,24 +496,6 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, Standard_Integer posToInsertGlobalVars = aScript.Length() + 1; - Handle(TDataStd_TreeNode) aNode, aRoot; - Handle(GEOM_Function) aFunction; - TDF_LabelMap aCheckedFuncMap; - std::set anIgnoreObjMap; - - if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) { - TDataStd_ChildNodeIterator Itr(aRoot); - for (; Itr.More(); Itr.Next()) { - aNode = Itr.Value(); - aFunction = GEOM_Function::GetFunction(aNode->Label()); - if (aFunction.IsNull()) { - MESSAGE ( "Null function !!!!" ); - continue; - } - ProcessFunction(aFunction, aScript, theVariables, aCheckedFuncMap, anIgnoreObjMap); - } - } - Resource_DataMapOfAsciiStringAsciiString aEntry2StEntry, aStEntry2Entry; Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString anEntryToNameIt; // build maps entry <-> studyEntry @@ -516,97 +517,90 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, } } - Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript); - Standard_Integer aLen = aSeq->Length(), objectCounter = 0, aStart = 1, aScriptLength = aScript.Length(); - Resource_DataMapOfAsciiStringAsciiString aNameToEntry, anEntryToBadName; + // 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; + TDF_LabelMap aCheckedFuncMap; + std::set anIgnoreObjMap; - //Replace entries by the names - TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("geomObj_"), - allowedChars ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_"); - if (aLen == 0) anUpdatedScript = aScript; + TCollection_AsciiString aFuncScript; + Resource_DataMapOfAsciiStringAsciiString anEntryToBadName; - for (Standard_Integer i = 1; i <= aLen; i+=2) { - anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i)-1); - anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i+1)); - if (theObjectNames.IsBound(anEntry)) { - aName = theObjectNames.Find(anEntry); - // check validity of aName - bool isValidName = true; - if ( aName.IsIntegerValue() ) { // aName must not start with a digit - aName.Insert( 1, 'a' ); - isValidName = false; + if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) { + TDataStd_ChildNodeIterator Itr(aRoot); + for (; Itr.More(); Itr.Next()) { + aNode = Itr.Value(); + aFunction = GEOM_Function::GetFunction(aNode->Label()); + if (aFunction.IsNull()) { + MESSAGE ( "Null function !!!!" ); + continue; } - int p, p2=1; // replace not allowed chars - while ((p = aName.FirstLocationNotInSet(allowedChars, p2, aName.Length()))) { - aName.SetValue(p, '_'); - p2=p; - isValidName = false; - } - if ( aNameToEntry.IsBound( aName ) && anEntry != aNameToEntry( aName )) - { // diff objects have same name - make a new name by appending a digit - TCollection_AsciiString aName2; - Standard_Integer i = 0; - do { - aName2 = aName + "_" + ++i; - } while ( aNameToEntry.IsBound( aName2 ) && anEntry != aNameToEntry( aName2 )); - aName = aName2; - isValidName = false; - } - if ( !isValidName ) { - if ( isPublished ) - anEntryToBadName.Bind( anEntry, theObjectNames.Find(anEntry) ); - theObjectNames( anEntry ) = aName; + bool isDumpCollected = false; + TCollection_AsciiString aCurScript, anAfterScript; + if (!ProcessFunction(aFunction, aCurScript, anAfterScript, theVariables, + isPublished, aCheckedFuncMap, anIgnoreObjMap, + isDumpCollected )) + continue; + // add function description before dump + if (!aCurScript.IsEmpty()) + aFuncScript += aCurScript; + if (isDumpCollected ) { + // Replace entries by the names + ReplaceEntriesByNames( aFuncScript, theObjectNames, + isPublished, anEntryToBadName, aObjListToPublish ); + + // publish collected objects + std::map< int, std::string > anEntryToCommandMap; // sort publishing commands by object entry + int i = 1, n = aObjListToPublish.Length(); + for ( ; i <= n; i++ ) + { + const TCollection_AsciiString& aEntry = aObjListToPublish.Value(i); + if (!theObjectNames.IsBound( aEntry )) + continue; + PublishObject( aEntry, theObjectNames.Find(aEntry), + theObjectNames, aEntry2StEntry, aStEntry2Entry, + anEntryToBadName, anEntryToCommandMap, anIgnoreObjMap ); + } + // add publishing commands to the script + 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" ); + if ( indx != -1 ) { + TCollection_AsciiString aSubStr = anAfterScript.SubString(1, indx); + Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aSubStr); + i = 1, n = aSeq->Length(); + for ( ; i <= n; i+=2) { + TCollection_AsciiString anEntry = + aSubStr.SubString(aSeq->Value(i), aSeq->Value(i+1)); + if (!anIgnoreObjMap.count(anEntry.ToCString())) + anIgnoreObjMap.insert(anEntry.ToCString()); + } + } + + aObjListToPublish.Clear(); + aScript += aFuncScript; + aFuncScript.Clear(); } + aFuncScript += anAfterScript; } - else { - do { - aName = aBaseName + TCollection_AsciiString(++objectCounter); - } while(aNameToEntry.IsBound(aName)); - theObjectNames.Bind(anEntry, aName); - } - aNameToEntry.Bind(aName, anEntry); // to detect same name of diff objects - - anUpdatedScript += aName; - aStart = aSeq->Value(i+1) + 1; } - //Add final part of the script - if (aLen && aSeq->Value(aLen) < aScriptLength) - anUpdatedScript += aScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865 + // Replace entries by the names + aObjListToPublish.Clear(); + ReplaceEntriesByNames( aFuncScript, theObjectNames, + isPublished, anEntryToBadName, aObjListToPublish ); + + aScript += aFuncScript; // ouv : NPAL12872 - for (anEntryToNameIt.Initialize( theObjectNames ); - anEntryToNameIt.More(); - anEntryToNameIt.Next()) - { - const TCollection_AsciiString& aEntry = anEntryToNameIt.Key(); - const TCollection_AsciiString& aName = anEntryToNameIt.Value(); - - TDF_Label L; - TDF_Tool::Label( aDoc->GetData(), aEntry, L ); - if ( L.IsNull() ) - continue; - - Handle(GEOM_Object) obj = GEOM_Object::GetObject( L ); - if ( obj.IsNull() ) - continue; - - bool anAutoColor = obj->GetAutoColor(); - if ( anAutoColor ) - { - TCollection_AsciiString aCommand( "\n\t" ); - aCommand += aName + ".SetAutoColor(1)"; - anUpdatedScript += aCommand.ToCString(); - } - - SALOMEDS::Color aColor = obj->GetColor(); - if ( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 ) - { - TCollection_AsciiString aCommand( "\n\t" ); - aCommand += aName + ".SetColor(SALOMEDS.Color(" + aColor.R + "," + aColor.G + "," + aColor.B + "))"; - anUpdatedScript += aCommand.ToCString(); - } - } + AddObjectColors( aDoc, aScript, theObjectNames ); // Make script to publish in study if ( isPublished ) @@ -617,47 +611,21 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, anEntryToNameIt.Next()) { const TCollection_AsciiString& aEntry = anEntryToNameIt.Key(); - const TCollection_AsciiString& aName = anEntryToNameIt.Value(); if (anIgnoreObjMap.count(aEntry.ToCString())) continue; // should not be dumped - if ( !aEntry2StEntry.IsBound( aEntry )) - continue; // was not published - TCollection_AsciiString aCommand("\n\tgeompy."), aFatherEntry; - - // find a father entry - const TCollection_AsciiString& aStudyEntry = aEntry2StEntry( aEntry ); - TCollection_AsciiString aFatherStudyEntry = - aStudyEntry.SubString( 1, aStudyEntry.SearchFromEnd(":") - 1 ); - if ( aStEntry2Entry.IsBound( aFatherStudyEntry )) - aFatherEntry = aStEntry2Entry( aFatherStudyEntry ); - - // make a command - if ( !aFatherEntry.IsEmpty() && theObjectNames.IsBound( aFatherEntry )) { - aCommand += "addToStudyInFather( "; - aCommand += theObjectNames( aFatherEntry ) + ", "; - } - else - aCommand += "addToStudy( "; - if ( anEntryToBadName.IsBound( aEntry )) - aCommand += aName + ", \"" + anEntryToBadName( aEntry ) + "\" )"; - else - aCommand += aName + ", \"" + aName + "\" )"; - - // bind a command to the last digit of the entry - int tag = - aEntry.SubString( aEntry.SearchFromEnd(":")+1, aEntry.Length() ).IntegerValue(); - anEntryToCommandMap.insert( std::make_pair( tag, aCommand.ToCString() )); + const TCollection_AsciiString& aName = anEntryToNameIt.Value(); + PublishObject( aEntry, aName, theObjectNames, + aEntry2StEntry, aStEntry2Entry, + anEntryToBadName, anEntryToCommandMap, anIgnoreObjMap ); } - // add publishing commands to the script std::map< int, std::string >::iterator anEntryToCommand = anEntryToCommandMap.begin(); - for ( ; anEntryToCommand != anEntryToCommandMap.end(); ++anEntryToCommand ) { - anUpdatedScript += (char*)anEntryToCommand->second.c_str(); - } + for ( ; anEntryToCommand != anEntryToCommandMap.end(); ++anEntryToCommand ) + aScript += (char*)anEntryToCommand->second.c_str(); } - //anUpdatedScript += "\n\tpass\n"; - anUpdatedScript += "\n"; + //aScript += "\n\tpass\n"; + aScript += "\n"; aValidScript = true; // fill _studyEntry2NameMap and build globalVars @@ -676,10 +644,10 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, } if ( !globalVars.IsEmpty() ) { globalVars.Insert( 1, "\n\tglobal " ); - anUpdatedScript.Insert( posToInsertGlobalVars, globalVars ); + aScript.Insert( posToInsertGlobalVars, globalVars ); } - return anUpdatedScript; + return aScript; } //======================================================================= @@ -716,15 +684,25 @@ Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const //=========================================================================== // Internal functions //=========================================================================== -void ProcessFunction(Handle(GEOM_Function)& theFunction, - TCollection_AsciiString& theScript, - const TVariablesList& theVariables, - TDF_LabelMap& theProcessed, - std::set& theIgnoreObjs) -{ - if (theFunction.IsNull()) return; - if (theProcessed.Contains(theFunction->GetEntry())) return; +//============================================================================= +/*! + * ProcessFunction: Dump fucntion description into script + */ +//============================================================================= +bool ProcessFunction(Handle(GEOM_Function)& theFunction, + TCollection_AsciiString& theScript, + TCollection_AsciiString& theAfterScript, + const TVariablesList& theVariables, + const bool theIsPublished, + TDF_LabelMap& theProcessed, + std::set& theIgnoreObjs, + bool& theIsDumpCollected) +{ + theIsDumpCollected = false; + if (theFunction.IsNull()) return false; + + if (theProcessed.Contains(theFunction->GetEntry())) return false; // pass functions, that depends on nonexisting ones bool doNotProcess = false; @@ -761,20 +739,44 @@ void ProcessFunction(Handle(GEOM_Function)& theFunction, TCollection_AsciiString anObjEntry; TDF_Tool::Entry(theFunction->GetOwnerEntry(), anObjEntry); theIgnoreObjs.insert(anObjEntry.ToCString()); - return; + return false; } theProcessed.Add(theFunction->GetEntry()); TCollection_AsciiString aDescr = theFunction->GetDescription(); - if(aDescr.Length() == 0) return; + if(aDescr.Length() == 0) return false; //Check if its internal function which doesn't requires dumping - if(aDescr == "None") return; + if(aDescr == "None") return false; + + // 0020001 PTv, check for critical functions, which requier dump of objects + if (theIsPublished) + { + // currently, there is only one function "RestoreSubShapes", + // later this check could be replaced by iterations on list of such functions + if (aDescr.Search( "RestoreSubShapes" ) != -1) + theIsDumpCollected = true; + } //Replace parameter by notebook variables ReplaceVariables(aDescr,theVariables); - theScript += "\n\t"; - theScript += aDescr; + if ( theIsDumpCollected ) { + int i = 1; + bool isBefore = true; + TCollection_AsciiString aSubStr = aDescr.Token("\n\t", i++); + while (!aSubStr.IsEmpty()) { + if (isBefore && aSubStr.Search( "RestoreSubShapes" ) == -1) + theScript += TCollection_AsciiString("\n\t") + aSubStr; + else + theAfterScript += TCollection_AsciiString("\n\t") + aSubStr; + aSubStr = aDescr.Token("\n\t", i++); + } + } + else { + theScript += "\n\t"; + theScript += aDescr; + } + return true; } //============================================================================= @@ -1069,6 +1071,170 @@ void ReplaceVariables(TCollection_AsciiString& theCommand, cout<<"Command : "<Length(), objectCounter = 0, aStart = 1, aScriptLength = theScript.Length(); + Resource_DataMapOfAsciiStringAsciiString aNameToEntry; + + //Replace entries by the names + TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("geomObj_"), + allowedChars ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_"); + if (aLen == 0) anUpdatedScript = theScript; + + for (Standard_Integer i = 1; i <= aLen; i+=2) { + anUpdatedScript += theScript.SubString(aStart, aSeq->Value(i)-1); + anEntry = theScript.SubString(aSeq->Value(i), aSeq->Value(i+1)); + theObjListToPublish.Append( anEntry ); + if (theObjectNames.IsBound(anEntry)) { + aName = theObjectNames.Find(anEntry); + // check validity of aName + bool isValidName = true; + if ( aName.IsIntegerValue() ) { // aName must not start with a digit + aName.Insert( 1, 'a' ); + isValidName = false; + } + int p, p2=1; // replace not allowed chars + while ((p = aName.FirstLocationNotInSet(allowedChars, p2, aName.Length()))) { + aName.SetValue(p, '_'); + p2=p; + isValidName = false; + } + if ( aNameToEntry.IsBound( aName ) && anEntry != aNameToEntry( aName )) + { // diff objects have same name - make a new name by appending a digit + TCollection_AsciiString aName2; + Standard_Integer i = 0; + do { + aName2 = aName + "_" + ++i; + } while ( aNameToEntry.IsBound( aName2 ) && anEntry != aNameToEntry( aName2 )); + aName = aName2; + isValidName = false; + } + if ( !isValidName ) { + if ( theIsPublished ) + theEntryToBadName.Bind( anEntry, theObjectNames.Find(anEntry) ); + theObjectNames( anEntry ) = aName; + } + } + else { + do { + aName = aBaseName + TCollection_AsciiString(++objectCounter); + } while(aNameToEntry.IsBound(aName)); + theObjectNames.Bind(anEntry, aName); + } + aNameToEntry.Bind(aName, anEntry); // to detect same name of diff objects + + anUpdatedScript += aName; + aStart = aSeq->Value(i+1) + 1; + } + + //Add final part of the script + if (aLen && aSeq->Value(aLen) < aScriptLength) + anUpdatedScript += theScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865 + + theScript = anUpdatedScript; +} + +//============================================================================= +/*! + * AddObjectColors: Add color to objects + */ +//============================================================================= +void AddObjectColors (const Handle(TDocStd_Document)& theDoc, + TCollection_AsciiString& theScript, + const Resource_DataMapOfAsciiStringAsciiString& theObjectNames) +{ + Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString anEntryToNameIt; + for (anEntryToNameIt.Initialize( theObjectNames ); + anEntryToNameIt.More(); + anEntryToNameIt.Next()) + { + const TCollection_AsciiString& aEntry = anEntryToNameIt.Key(); + const TCollection_AsciiString& aName = anEntryToNameIt.Value(); + + TDF_Label L; + TDF_Tool::Label( theDoc->GetData(), aEntry, L ); + if ( L.IsNull() ) + continue; + + Handle(GEOM_Object) obj = GEOM_Object::GetObject( L ); + if ( obj.IsNull() ) + continue; + + bool anAutoColor = obj->GetAutoColor(); + if ( anAutoColor ) + { + TCollection_AsciiString aCommand( "\n\t" ); + aCommand += aName + ".SetAutoColor(1)"; + theScript += aCommand.ToCString(); + } + + SALOMEDS::Color aColor = obj->GetColor(); + if ( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 ) + { + TCollection_AsciiString aCommand( "\n\t" ); + aCommand += aName + ".SetColor(SALOMEDS.Color(" + aColor.R + "," + aColor.G + "," + aColor.B + "))"; + theScript += aCommand.ToCString(); + } + } +} + +//============================================================================= +/*! + * PublishObject: publish object in study script + */ +//============================================================================= +void PublishObject (const TCollection_AsciiString& theEntry, + const TCollection_AsciiString& theName, + const Resource_DataMapOfAsciiStringAsciiString& theObjectNames, + const Resource_DataMapOfAsciiStringAsciiString& theEntry2StEntry, + const Resource_DataMapOfAsciiStringAsciiString& theStEntry2Entry, + const Resource_DataMapOfAsciiStringAsciiString& theEntryToBadName, + std::map< int, std::string >& theEntryToCommandMap, + std::set& theMapOfPublished) +{ + if ( !theEntry2StEntry.IsBound( theEntry )) + return; // was not published + if ( theMapOfPublished.count(theEntry.ToCString()) ) + return; // aready published + theMapOfPublished.insert( theEntry.ToCString() ); + + TCollection_AsciiString aCommand("\n\tgeompy."), aFatherEntry; + + // find a father entry + const TCollection_AsciiString& aStudyEntry = theEntry2StEntry( theEntry ); + TCollection_AsciiString aFatherStudyEntry = + aStudyEntry.SubString( 1, aStudyEntry.SearchFromEnd(":") - 1 ); + if ( theStEntry2Entry.IsBound( aFatherStudyEntry )) + aFatherEntry = theStEntry2Entry( aFatherStudyEntry ); + + // make a command + if ( !aFatherEntry.IsEmpty() && theObjectNames.IsBound( aFatherEntry )) { + aCommand += "addToStudyInFather( "; + aCommand += theObjectNames( aFatherEntry ) + ", "; + } + else + aCommand += "addToStudy( "; + if ( theEntryToBadName.IsBound( theEntry )) + aCommand += theName + ", \"" + theEntryToBadName( theEntry ) + "\" )"; + else + aCommand += theName + ", \"" + theName + "\" )"; + + // bind a command to the last digit of the entry + int tag = + theEntry.SubString( theEntry.SearchFromEnd(":")+1, theEntry.Length() ).IntegerValue(); + theEntryToCommandMap.insert( std::make_pair( tag, aCommand.ToCString() )); +} + //================================================================================ /*! * \brief Constructor diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 2758bf025..512855280 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -28,6 +28,7 @@ #include "GEOM_Gen_i.hh" #include "GEOM_Object_i.hh" +#include #include //#include @@ -40,6 +41,7 @@ #include "GEOM_Object.hxx" #include "GEOM_Function.hxx" #include "GEOM_ISubShape.hxx" +#include #include "GEOMImpl_Types.hxx" #include "GEOMImpl_CopyDriver.hxx" @@ -750,22 +752,26 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, // purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments. // To be used from python scripts out of geompy.addToStudy (non-default usage) //============================================================================ -CORBA::Boolean GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, - GEOM::GEOM_Object_ptr theObject, - const GEOM::ListOfGO& theArgs, - GEOM::find_shape_method theFindMethod, - CORBA::Boolean theInheritFirstArg) +GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_ptr theObject, + const GEOM::ListOfGO& theArgs, + GEOM::find_shape_method theFindMethod, + CORBA::Boolean theInheritFirstArg) { + GEOM::ListOfGO_var aParts = new GEOM::ListOfGO; if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject)) - return false; + return aParts._retn(); - // find SObject in the study + // find SObject in the study if it is already published CORBA::String_var anIORo = _orb->object_to_string(theObject); SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(anIORo.in()); - if (CORBA::is_nil(aSO)) - return false; + //PTv, IMP 0020001, The salome object + // is not obligatory in case of invokation from script + // if (CORBA::is_nil(aSO)) + // return aParts._retn(); - return RestoreSubShapes(theStudy, theObject, aSO, theArgs, theFindMethod, theInheritFirstArg); + aParts = RestoreSubShapes(theStudy, theObject, aSO, theArgs, theFindMethod, theInheritFirstArg); + return aParts._retn(); } //============================================================================ @@ -773,18 +779,19 @@ CORBA::Boolean GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, // purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments. // To be used from GUI and from geompy.addToStudy //============================================================================ -CORBA::Boolean GEOM_Gen_i::RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy, +GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject, const GEOM::ListOfGO& theArgs, GEOM::find_shape_method theFindMethod, CORBA::Boolean theInheritFirstArg) { + GEOM::ListOfGO_var aParts = new GEOM::ListOfGO; if (CORBA::is_nil(theStudy) || CORBA::is_nil(theSObject)) - return false; + return aParts._retn(); SALOMEDS::GenericAttribute_var anAttr; if (!theSObject->FindAttribute(anAttr, "AttributeIOR")) - return false; + return aParts._retn(); SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); CORBA::String_var anIORso = anAttrIOR->Value(); @@ -792,9 +799,36 @@ CORBA::Boolean GEOM_Gen_i::RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy, // get Object from SObject GEOM::GEOM_Object_var anO = GEOM::GEOM_Object::_narrow(_orb->string_to_object(anIORso)); if (CORBA::is_nil(anO)) - return false; + return aParts._retn(); - return RestoreSubShapes(theStudy, anO, theSObject, theArgs, theFindMethod, theInheritFirstArg); + aParts = RestoreSubShapes(theStudy, anO, theSObject, theArgs, theFindMethod, theInheritFirstArg); + aParts._retn(); +} + +//============================================================================ +// function : addToListOfGO +// purpose : static local function +//============================================================================ +static void addToListOfGO( const GEOM::GEOM_Object_var& theObject, + GEOM::ListOfGO_var& theList ) +{ + const int oldLen = theList->length(); + theList->length(oldLen + 1); + theList[ oldLen ] = theObject; +} + +//============================================================================ +// function : addToListOfGO +// purpose : static local function +//============================================================================ +static void addToListOfGO( GEOM::ListOfGO_var& theSrcList, + GEOM::ListOfGO_var& theTrgList ) +{ + const int oldLen = theTrgList->length(); + const int srcLen = theSrcList->length(); + theTrgList->length(oldLen + srcLen); + for( int i = 0; i < srcLen; i++ ) + theTrgList[ oldLen + i ] = theSrcList[ i ]; } //============================================================================ @@ -802,15 +836,18 @@ CORBA::Boolean GEOM_Gen_i::RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy, // purpose : Private method. Works only if both theObject and theSObject // are defined, and does not check, if they correspond to each other. //============================================================================ -CORBA::Boolean GEOM_Gen_i::RestoreSubShapes (SALOMEDS::Study_ptr theStudy, +GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes (SALOMEDS::Study_ptr theStudy, GEOM::GEOM_Object_ptr theObject, SALOMEDS::SObject_ptr theSObject, const GEOM::ListOfGO& theArgs, GEOM::find_shape_method theFindMethod, CORBA::Boolean theInheritFirstArg) { - if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) || CORBA::is_nil(theSObject)) - return false; + GEOM::ListOfGO_var aParts = new GEOM::ListOfGO; + //PTv, IMP 0020001, The salome object + // is not obligatory in case of invokation from script + if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) /*|| CORBA::is_nil(theSObject)*/) + return aParts._retn(); // Arguments to be published GEOM::ListOfGO_var aList; @@ -834,7 +871,7 @@ CORBA::Boolean GEOM_Gen_i::RestoreSubShapes (SALOMEDS::Study_ptr theStudy, } if (aLength < 1) - return false; + return aParts._retn(); if (theInheritFirstArg || (nbArgsActual == 1)) { // Do not publish argument's reflection, @@ -844,139 +881,214 @@ CORBA::Boolean GEOM_Gen_i::RestoreSubShapes (SALOMEDS::Study_ptr theStudy, CORBA::String_var anIOR = _orb->object_to_string(anArgO); SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in()); - GEOM::ListOfGO_var aParts = - RestoreSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject, theFindMethod); + aParts = RestoreSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject, theFindMethod); // set the color of the transformed shape to the color of initial shape theObject->SetColor(aList[0]->GetColor()); - - return (aParts->length() > 0); } + else { + // Get interface, containing method, which we will use to reconstruct sub-shapes + GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId()); + GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId()); - // Get interface, containing method, which we will use to reconstruct sub-shapes - GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId()); - GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId()); + // Reconstruct arguments and tree of sub-shapes of the arguments + CORBA::String_var anIOR; + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + for (Standard_Integer i = 0; i < aLength; i++) + { + GEOM::GEOM_Object_var anArgO = aList[i]; + if (!CORBA::is_nil(anArgO)) { + anIOR = _orb->object_to_string(anArgO); + SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in()); + TCollection_AsciiString anArgName; + if (CORBA::is_nil(anArgSO)) { + anArgName = "arg_"; + anArgName += TCollection_AsciiString(i); + } + else { + anArgName = anArgSO->GetName(); + } - // Reconstruct arguments and tree of sub-shapes of the arguments - CORBA::String_var anIOR; - SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); - for (Standard_Integer i = 0; i < aLength; i++) - { - GEOM::GEOM_Object_var anArgO = aList[i]; - if (!CORBA::is_nil(anArgO)) { - anIOR = _orb->object_to_string(anArgO); - SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in()); - TCollection_AsciiString anArgName; - if (CORBA::is_nil(anArgSO)) { - anArgName = "arg_"; - anArgName += TCollection_AsciiString(i); + // Find a sub-shape of theObject in place of the argument + GEOM::GEOM_Object_var aSubO; + switch (theFindMethod) { + case GEOM::FSM_GetInPlace: + { + // Use GetInPlace + aSubO = aShapesOp->GetInPlace(theObject, anArgO); + } + break; + case GEOM::FSM_Transformed: + { + // transformation, cannot use GetInPlace, operate with indices + GEOM::ListOfLong_var anIDs = anArgO->GetSubShapeIndices(); + if (anIDs->length() > 1) { + // group + aSubO = aGroupOp->CreateGroup(theObject, aGroupOp->GetType(anArgO)); + if (!CORBA::is_nil(aSubO)) + aGroupOp->UnionIDs(aSubO, anIDs); + } + else { + // single sub-shape + aSubO = aShapesOp->GetSubShape(theObject, anIDs[0]); + } + } + break; + case GEOM::FSM_GetSame: + { + // Use GetSame + aSubO = aShapesOp->GetSame(theObject, anArgO); + } + break; + case GEOM::FSM_GetShapesOnShape: + { + // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids + aSubO = aShapesOp->GetShapesOnShapeAsCompound(anArgO, theObject, + (short)GEOM::SOLID, GEOM::ST_ONIN); + } + break; + case GEOM::FSM_GetInPlaceByHistory: + { + // Use GetInPlaceByHistory + aSubO = aShapesOp->GetInPlaceByHistory(theObject, anArgO); + } + break; + default: + {} + } + + if (!CORBA::is_nil(aSubO)) { + // add to parts list + addToListOfGO( aSubO, aParts ); + + // Publish the sub-shape + SALOMEDS::SObject_var aSubSO; + if (!CORBA::is_nil(theSObject)) { + TCollection_AsciiString aSubName ("from_"); + aSubName += anArgName; + aSubSO = aStudyBuilder->NewObject(theSObject); + aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString()); + // Restore color + aSubO->SetColor(anArgO->GetColor()); + } + + if (!CORBA::is_nil(anArgSO)) { + // Restore published sub-shapes of the argument + GEOM::ListOfGO_var aSubParts; + if (theFindMethod == GEOM::FSM_GetInPlaceByHistory) + // pass theObject, because only it has the history + aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, theObject, theFindMethod); + else + aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, aSubO, theFindMethod); + // add to parts list + addToListOfGO( aSubParts, aParts ); + } + } + else { // GetInPlace failed, try to build from published parts + if (!CORBA::is_nil(anArgSO)) { + SALOMEDS::SObject_var aSubSO; + if (!CORBA::is_nil(theSObject)) + aSubSO = aStudyBuilder->NewObject(theSObject); + + // Restore published sub-shapes of the argument + GEOM::ListOfGO_var aSubParts = + RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, theObject, theFindMethod); + + // add to parts list + addToListOfGO( aSubParts, aParts ); + + if (aSubParts->length() > 0) { + // try to build an argument from a set of its sub-shapes, + // that published and will be reconstructed + if (aSubParts->length() > 1) { + aSubO = aShapesOp->MakeCompound(aSubParts); + // add to parts list + addToListOfGO( aSubO, aParts ); + } + else { + aSubO = aSubParts[0]; + } + if (!CORBA::is_nil(aSubO) && !CORBA::is_nil(aSubSO)) { + // Publish the sub-shape + TCollection_AsciiString aSubName ("from_parts_of_"); + aSubName += anArgName; + aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString()); + // Restore color + aSubO->SetColor(anArgO->GetColor()); + } + } + else if (!CORBA::is_nil(aSubSO)) { + // remove created aSubSO, because no parts have been found + aStudyBuilder->RemoveObject(aSubSO); + } + } + } // try to build from published parts } - else { - anArgName = anArgSO->GetName(); - } - - // Find a sub-shape of theObject in place of the argument - GEOM::GEOM_Object_var aSubO; - switch (theFindMethod) { - case GEOM::FSM_GetInPlace: - { - // Use GetInPlace - aSubO = aShapesOp->GetInPlace(theObject, anArgO); - } - break; - case GEOM::FSM_Transformed: - { - // transformation, cannot use GetInPlace, operate with indices - GEOM::ListOfLong_var anIDs = anArgO->GetSubShapeIndices(); - if (anIDs->length() > 1) { - // group - aSubO = aGroupOp->CreateGroup(theObject, aGroupOp->GetType(anArgO)); - if (!CORBA::is_nil(aSubO)) - aGroupOp->UnionIDs(aSubO, anIDs); - } - else { - // single sub-shape - aSubO = aShapesOp->GetSubShape(theObject, anIDs[0]); - } - } - break; - case GEOM::FSM_GetSame: - { - // Use GetSame - aSubO = aShapesOp->GetSame(theObject, anArgO); - } - break; - case GEOM::FSM_GetShapesOnShape: - { - // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids - aSubO = aShapesOp->GetShapesOnShapeAsCompound(anArgO, theObject, - (short)GEOM::SOLID, GEOM::ST_ONIN); - } - break; - case GEOM::FSM_GetInPlaceByHistory: - { - // Use GetInPlaceByHistory - aSubO = aShapesOp->GetInPlaceByHistory(theObject, anArgO); - } - break; - default: - {} - } - - if (!CORBA::is_nil(aSubO)) { - // Publish the sub-shape - TCollection_AsciiString aSubName ("from_"); - aSubName += anArgName; - SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(theSObject); - aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString()); - // Restore color - aSubO->SetColor(anArgO->GetColor()); - - if (!CORBA::is_nil(anArgSO)) { - // Restore published sub-shapes of the argument - if (theFindMethod == GEOM::FSM_GetInPlaceByHistory) - // pass theObject, because only it has the history - RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, theObject, theFindMethod); - else - RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, aSubO, theFindMethod); - } - } - else { // GetInPlace failed, try to build from published parts - if (!CORBA::is_nil(anArgSO)) { - SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(theSObject); - - // Restore published sub-shapes of the argument - GEOM::ListOfGO_var aParts = - RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, theObject, theFindMethod); - - if (aParts->length() > 0) { - // try to build an argument from a set of its sub-shapes, - // that published and will be reconstructed - if (aParts->length() > 1) { - aSubO = aShapesOp->MakeCompound(aParts); - } - else { - aSubO = aParts[0]; - } - if (!CORBA::is_nil(aSubO)) { - // Publish the sub-shape - TCollection_AsciiString aSubName ("from_parts_of_"); - aSubName += anArgName; - aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString()); - // Restore color - aSubO->SetColor(anArgO->GetColor()); - } - } - else { - // remove created aSubSO, because no parts have been found - aStudyBuilder->RemoveObject(aSubSO); - } - } - } // try to build from published parts + } // process arguments + } + set anObjEntryMap; + GEOM::ListOfGO_var aResParts = new GEOM::ListOfGO; + int nbRes = 0; + int nb = aParts->length(); + aResParts->length(nb); + if (nb > 0) + { + Handle(GEOM_Object) aMainObj = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + Handle(GEOM_Function) aFunction = aMainObj->GetLastFunction(); + GEOM::TPythonDump pd (aFunction, true); + pd <<"["; + int i = 0, j = 0; + for ( ; i < nb; i++ ) + { + const GEOM::GEOM_Object_var& anObj = aParts[ i ]; + if (CORBA::is_nil(anObj)) + continue; + char* anEntry = anObj->GetEntry(); + if (anObjEntryMap.count(anEntry)) + continue; // already treated + anObjEntryMap.insert(anEntry); + aResParts[nbRes++] = anObj; + // clear python dump of object + Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anEntry); + Handle(GEOM_Function) anObjFun = aGeomObj->GetLastFunction(); + if ( !anObjFun.IsNull() ) + anObjFun->SetDescription( "" ); + if ( j > 0 ) + pd << ", "; + pd << aGeomObj; + j++; } - } // process arguments - - return true; + pd <<"]" << " = geompy.RestoreSubShapes(" << aMainObj << ", " << "["; + i = 0; nb = theArgs.length(); j = 0; + for ( ; i < nb; i++ ) + { + GEOM::GEOM_Object_var anObj = theArgs[ i ]; + if (CORBA::is_nil(anObj)) + continue; + Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry()); + if ( j > 0 ) + pd << ", "; + pd << aGeomObj; + j++; + } + pd <<"]" << ", " <<"geompy.GEOM."; + switch (theFindMethod) { + case GEOM::FSM_GetInPlace: + pd << "FSM_GetInPlace"; break; + case GEOM::FSM_Transformed: + pd << "FSM_Transformed"; break; + case GEOM::FSM_GetSame: + pd << "FSM_GetSame"; break; + case GEOM::FSM_GetShapesOnShape: + pd << "FSM_GetShapesOnShape"; break; + case GEOM::FSM_GetInPlaceByHistory: + default: + pd << "FSM_GetInPlaceByHistory"; break; + } + pd << ", " << theInheritFirstArg << ")"; + } + aResParts->length(nbRes); + return aResParts._retn(); } //============================================================================ @@ -991,8 +1103,9 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr th { int i = 0; GEOM::ListOfGO_var aParts = new GEOM::ListOfGO; + GEOM::ListOfGO_var aNewParts = new GEOM::ListOfGO; if (CORBA::is_nil(theStudy) || CORBA::is_nil(theOldSO) || - CORBA::is_nil(theNewO) || CORBA::is_nil(theNewSO)) + CORBA::is_nil(theNewO) /*|| CORBA::is_nil(theNewSO)*/) return aParts._retn(); SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); @@ -1073,53 +1186,68 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr th // add the part to the list aParts[i] = aNewSubO; i++; + // add to parts list + addToListOfGO( aNewSubO, aNewParts ); - // Publish the sub-shape - TCollection_AsciiString aSubName ("from_"); - aSubName += anArgName; - SALOMEDS::SObject_var aNewSubSO = aStudyBuilder->NewObject(theNewSO); - aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString()); - // Restore color - aNewSubO->SetColor(anOldSubO->GetColor()); - + SALOMEDS::SObject_var aNewSubSO; + if (!CORBA::is_nil(theNewSO)) { + // Publish the sub-shape + TCollection_AsciiString aSubName ("from_"); + aSubName += anArgName; + aNewSubSO = aStudyBuilder->NewObject(theNewSO); + aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString()); + // Restore color + aNewSubO->SetColor(anOldSubO->GetColor()); + } // Restore published sub-shapes of the argument + GEOM::ListOfGO_var aSubParts; if (theFindMethod == GEOM::FSM_GetInPlaceByHistory) // pass the main shape as Object, because only it has the history - RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, theNewO, theFindMethod); + aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, theNewO, theFindMethod); else - RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, aNewSubO, theFindMethod); + aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, aNewSubO, theFindMethod); + // add to parts list + addToListOfGO( aSubParts, aNewParts ); } else { // GetInPlace failed, try to build from published parts - SALOMEDS::SObject_var aNewSubSO = aStudyBuilder->NewObject(theNewSO); + SALOMEDS::SObject_var aNewSubSO; + if (!CORBA::is_nil(theNewSO)) + aNewSubSO = aStudyBuilder->NewObject(theNewSO); // Restore published sub-shapes of the argument - GEOM::ListOfGO_var aParts = + GEOM::ListOfGO_var aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, theNewO, theFindMethod); + // add to parts list + addToListOfGO( aSubParts, aNewParts ); - if (aParts->length() > 0) { + if (aSubParts->length() > 0) { // try to build an object from a set of its sub-shapes, // that published and will be reconstructed - if (aParts->length() > 1) { - aNewSubO = aShapesOp->MakeCompound(aParts); + if (aSubParts->length() > 1) { + aNewSubO = aShapesOp->MakeCompound(aSubParts); + // add to parts list + addToListOfGO( aNewSubO, aNewParts ); } else { - aNewSubO = aParts[0]; + aNewSubO = aSubParts[0]; } if (!CORBA::is_nil(aNewSubO)) { // add the part to the list - aParts[i] = aNewSubO; + aSubParts[i] = aNewSubO; i++; // Publish the sub-shape - TCollection_AsciiString aSubName = "from_parts_of_"; - aSubName += anArgName; - aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString()); - // Restore color - aNewSubO->SetColor(anOldSubO->GetColor()); + if (!CORBA::is_nil(aNewSubSO)) { + TCollection_AsciiString aSubName = "from_parts_of_"; + aSubName += anArgName; + aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString()); + // Restore color + aNewSubO->SetColor(anOldSubO->GetColor()); + } } } - else { + else if (!CORBA::is_nil(aNewSubSO)) { // remove created aSubSO, because no parts have been found aStudyBuilder->RemoveObject(aNewSubSO); } @@ -1129,6 +1257,8 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr th } // iterate on published sub-shapes aParts->length(i); + // add to parts list + addToListOfGO( aNewParts, aParts ); return aParts._retn(); } diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index 75b56384f..4bd530fa1 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -143,20 +143,20 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments. * To be used from python scripts out of geompy.addToStudy (non-default usage) */ - CORBA::Boolean RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, - GEOM::GEOM_Object_ptr theObject, - const GEOM::ListOfGO& theArgs, - GEOM::find_shape_method theFindMethod, - CORBA::Boolean theInheritFirstArg); + GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_ptr theObject, + const GEOM::ListOfGO& theArgs, + GEOM::find_shape_method theFindMethod, + CORBA::Boolean theInheritFirstArg); /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments. * To be used from GUI and from geompy.addToStudy */ - CORBA::Boolean RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr theSObject, - const GEOM::ListOfGO& theArgs, - GEOM::find_shape_method theFindMethod, - CORBA::Boolean theInheritFirstArg); + GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + const GEOM::ListOfGO& theArgs, + GEOM::find_shape_method theFindMethod, + CORBA::Boolean theInheritFirstArg); //-----------------------------------------------------------------------// // Transaction methods // @@ -255,12 +255,12 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi GEOM::GEOM_Object_ptr theNewO, GEOM::find_shape_method theFindMethod); - CORBA::Boolean RestoreSubShapes (SALOMEDS::Study_ptr theStudy, - GEOM::GEOM_Object_ptr theObject, - SALOMEDS::SObject_ptr theSObject, - const GEOM::ListOfGO& theArgs, - GEOM::find_shape_method theFindMethod, - CORBA::Boolean theInheritFirstArg); + GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_ptr theObject, + SALOMEDS::SObject_ptr theSObject, + const GEOM::ListOfGO& theArgs, + GEOM::find_shape_method theFindMethod, + CORBA::Boolean theInheritFirstArg); // auxilary for PublishNamedShapesInStudy void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,