]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Mantis isuue 0020768: EDF 1319 GEOM : Some Dump with RestoreSubShapes not loadable.
authorjfa <jfa@opencascade.com>
Wed, 30 Jun 2010 11:34:42 +0000 (11:34 +0000)
committerjfa <jfa@opencascade.com>
Wed, 30 Jun 2010 11:34:42 +0000 (11:34 +0000)
idl/GEOM_Gen.idl
src/GEOM/GEOM_Engine.cxx
src/GEOM_I/GEOM_Gen_i.cc
src/GEOM_I/GEOM_Gen_i.hh
src/GEOM_SWIG/geompyDC.py

index eb8f389d624c19c1d7e4ac63d933bab332382e55..164969e51be1c3a7fa9ea0d4a195abf89ac735b9 100644 (file)
@@ -3341,6 +3341,36 @@ module GEOM
                                in boolean           theInheritFirstArg,
                                 in boolean           theAddPrefix);
 
+    /*!
+     *  Publish sub-shapes, standing for arguments and sub-shapes of arguments
+     *  To be used from python scripts out of geompy.addToStudy (non-default usage)
+     *  \param theStudy  the study, in which theObject is published already,
+     *                   and in which the arguments will be published
+     *  \param theObject published GEOM object, arguments of which will be published
+     *  \param theArgs   list of GEOM_Object, operation arguments to be published.
+     *                   If this list is empty, all operation arguments will be published
+     *  \param theFindMethod method to search subshapes, corresponding to arguments and
+     *                       their subshapes. Value from enumeration GEOM::find_shape_method.
+     *  \param theInheritFirstArg set properties of the first argument for \a theObject.
+     *                            Do not publish subshapes in place of arguments, but only
+     *                            in place of subshapes of the first argument,
+     *                            because the whole shape corresponds to the first argument.
+     *                            Mainly to be used after transformations, but it also can be
+     *                            usefull after partition with one object shape, and some other
+     *                            operations, where only the first argument has to be considered.
+     *                            If theObject has only one argument shape, this flag is automatically
+     *                            considered as True, not regarding really passed value.
+     *  \param theAddPrefix add prefix "from_" to names of restored sub-shapes,
+     *                      and prefix "from_subshapes_of_" to names of partially restored subshapes.
+     *  \return list of published sub-shapes
+     */
+    ListOfGO RestoreGivenSubShapesO (in SALOMEDS::Study   theStudy,
+                                     in GEOM_Object       theObject,
+                                     in ListOfGO          theArgs,
+                                     in find_shape_method theFindMethod,
+                                     in boolean           theInheritFirstArg,
+                                     in boolean           theAddPrefix);
+
     /*!
      *  Publish sub-shapes, standing for arguments and sub-shapes of arguments
      *  To be used from GUI and from geompy.addToStudy.
index 60a5e7da762479f8a900ad8b330867ae1f73b059..5de5a1e170f7879ea61db8905f731fd889df0f18 100644 (file)
@@ -627,9 +627,11 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
         for ( ; anEntryToCommand != anEntryToCommandMap.end(); ++anEntryToCommand )
           aFuncScript += (char*)anEntryToCommand->second.c_str();
 
-        // PTv, 0020001 add result objects from RestoreSubShapes into ignore list,
+        // PTv, 0020001 add result objects from RestoreGivenSubShapes into ignore list,
         //  because they will be published during command execution
-        int indx = anAfterScript.Search( "RestoreSubShapes" );
+        int indx = anAfterScript.Search( "RestoreGivenSubShapes" );
+        if ( indx == -1 )
+          indx = anAfterScript.Search( "RestoreSubShapes" );
         if ( indx != -1 ) {
           TCollection_AsciiString aSubStr = anAfterScript.SubString(1, indx);
           Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aSubStr);
@@ -922,9 +924,11 @@ bool ProcessFunction(Handle(GEOM_Function)&     theFunction,
   // 0020001 PTv, check for critical functions, which requier dump of objects
   if (theIsPublished)
   {
-    // currently, there is only one function "RestoreSubShapes",
+    // currently, there is only one function "RestoreGivenSubShapes",
     // later this check could be replaced by iterations on list of such functions
-    if (aDescr.Search( "RestoreSubShapes" ) != -1)
+    if (aDescr.Search( "RestoreGivenSubShapes" ) != -1)
+      theIsDumpCollected = true;
+    else if (aDescr.Search( "RestoreSubShapes" ) != -1)
       theIsDumpCollected = true;
   }
 
@@ -935,7 +939,9 @@ bool ProcessFunction(Handle(GEOM_Function)&     theFunction,
     bool isBefore = true;
     TCollection_AsciiString aSubStr = aDescr.Token("\n\t", i++);
     while (!aSubStr.IsEmpty()) {
-      if (isBefore && aSubStr.Search( "RestoreSubShapes" ) == -1)
+      if (isBefore &&
+          aSubStr.Search( "RestoreGivenSubShapes" ) == -1 &&
+          aSubStr.Search( "RestoreSubShapes" ) == -1)
         theScript += TCollection_AsciiString("\n\t") + aSubStr;
       else
         theAfterScript += TCollection_AsciiString("\n\t") + aSubStr;
index eb5d2d90842425d19490b4f13c91e9ff6649c09c..0b6a72d35528bfeacd691406ec88a7b3a5bca307 100644 (file)
@@ -801,6 +801,36 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr     theStudy,
   return aParts._retn();
 }
 
+//============================================================================
+// function : RestoreGivenSubShapesO
+// purpose  : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
+//            To be used from python scripts, generated by Dump Python.
+//============================================================================
+GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesO (SALOMEDS::Study_ptr     theStudy,
+                                                    GEOM::GEOM_Object_ptr   theObject,
+                                                    const GEOM::ListOfGO&   theArgs,
+                                                    GEOM::find_shape_method theFindMethod,
+                                                    CORBA::Boolean          theInheritFirstArg,
+                                                    CORBA::Boolean          theAddPrefix)
+{
+  GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
+  if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject))
+    return aParts._retn();
+
+  // 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());
+  //PTv, IMP 0020001, The salome object <aSO>
+  // is not obligatory in case of invokation from script
+  // if (CORBA::is_nil(aSO))
+  //  return aParts._retn();
+
+  aParts = RestoreGivenSubShapes(theStudy, theObject, aSO, theArgs,
+                                 theFindMethod, theInheritFirstArg, theAddPrefix);
+  if (!CORBA::is_nil(aSO)) aSO->Destroy();
+  return aParts._retn();
+}
+
 //============================================================================
 // function : RestoreSubShapesSO
 // purpose  : Publish sub-shapes, standing for arguments and sub-shapes of arguments.
@@ -879,6 +909,9 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
   if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) /*|| CORBA::is_nil(theSObject)*/)
     return aParts._retn();
 
+  // For Dump Python (mantis issue 0020768)
+  GEOM::ListOfGO_var anOutArgs = new GEOM::ListOfGO;
+
   // Arguments to be published
   GEOM::ListOfGO_var aList;
 
@@ -910,7 +943,11 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
     CORBA::String_var anIOR = _orb->object_to_string(aList[0]);
     SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
 
-    aParts = RestoreSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject, theFindMethod, theAddPrefix);
+    // remember restored objects for Python Dump
+    addToListOfGO(aList[0], anOutArgs);
+
+    aParts = RestoreSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject,
+                                      anOutArgs, theFindMethod, theAddPrefix);
 
     // set the color of the transformed shape to the color of initial shape
     theObject->SetColor(aList[0]->GetColor());
@@ -995,6 +1032,9 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
         }
 
         if (!CORBA::is_nil(aSubO)) {
+          // remember restored objects for Python Dump
+          addToListOfGO(anArgO, anOutArgs);
+
           // add to parts list
           addToListOfGO( aSubO, aParts );
 
@@ -1024,10 +1064,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
             if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
               // pass theObject, because only it has the history
               aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
-                                                   theObject, theFindMethod, theAddPrefix);
+                                                   theObject, anOutArgs, theFindMethod, theAddPrefix);
             else
               aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
-                                                   aSubO, theFindMethod, theAddPrefix);
+                                                   aSubO, anOutArgs, theFindMethod, theAddPrefix);
             // add to parts list
             addToListOfGO( aSubParts, aParts );
           }
@@ -1041,12 +1081,15 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
             // Restore published sub-shapes of the argument
             GEOM::ListOfGO_var aSubParts =
               RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
-                                       theObject, theFindMethod, theAddPrefix);
+                                       theObject, anOutArgs, theFindMethod, theAddPrefix);
 
             // add to parts list
             addToListOfGO( aSubParts, aParts );
 
             if (aSubParts->length() > 0) {
+              // remember restored objects for Python Dump
+              addToListOfGO(anArgO, anOutArgs);
+
               // try to build an argument from a set of its sub-shapes,
               // that published and will be reconstructed
               if (aSubParts->length() > 1) {
@@ -1117,11 +1160,13 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr     theStudy,
       pd << aGeomObj;
       j++;
     }
-    pd <<"]" << " = geompy.RestoreSubShapes(" << aMainObj << ", " << "[";
-    i = 0; nb = theArgs.length(); j = 0;
+    pd <<"]" << " = geompy.RestoreGivenSubShapes(" << aMainObj << ", " << "[";
+    //i = 0; nb = theArgs.length(); j = 0;
+    i = 0; nb = anOutArgs->length(); j = 0;
     for ( ; i < nb; i++ )
     {
-      GEOM::GEOM_Object_var anObj = theArgs[ i ];
+      //GEOM::GEOM_Object_var anObj = theArgs[ i ];
+      GEOM::GEOM_Object_var anObj = anOutArgs[ i ];
       if (CORBA::is_nil(anObj))
         continue;
       Handle(GEOM_Object) aGeomObj = _impl->GetObject(anObj->GetStudyID(), anObj->GetEntry());
@@ -1158,6 +1203,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     th
                                                       SALOMEDS::SObject_ptr   theOldSO,
                                                       SALOMEDS::SObject_ptr   theNewSO,
                                                       GEOM::GEOM_Object_ptr   theNewO,
+                                                      GEOM::ListOfGO&         theOutArgs,
                                                       GEOM::find_shape_method theFindMethod,
                                                       CORBA::Boolean          theAddPrefix)
 {
@@ -1243,6 +1289,9 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     th
         }
 
         if (!CORBA::is_nil(aNewSubO)) {
+          // remember restored objects for Python Dump
+          addToListOfGO(anOldSubO, theOutArgs);
+
           // add the part to the list
           aParts[i] = aNewSubO;
           i++;
@@ -1273,10 +1322,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     th
           if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
             // pass the main shape as Object, because only it has the history
             aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
-                                                 theNewO, theFindMethod, theAddPrefix);
+                                                 theNewO, theOutArgs, theFindMethod, theAddPrefix);
           else
             aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
-                                                 aNewSubO, theFindMethod, theAddPrefix);
+                                                 aNewSubO, theOutArgs, theFindMethod, theAddPrefix);
           // add to parts list
           addToListOfGO( aSubParts, aNewParts );
         }
@@ -1288,7 +1337,520 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     th
           // Restore published sub-shapes of the argument
           GEOM::ListOfGO_var aSubParts =
             RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
-                                     theNewO, theFindMethod, theAddPrefix);
+                                     theNewO, theOutArgs, theFindMethod, theAddPrefix);
+          // add to parts list
+          addToListOfGO( aSubParts, aNewParts );
+
+          if (aSubParts->length() > 0) {
+            // remember restored objects for Python Dump
+            addToListOfGO(anOldSubO, theOutArgs);
+
+            // try to build an object from a set of its sub-shapes,
+            // that published and will be reconstructed
+            if (aSubParts->length() > 1) {
+              aNewSubO = aShapesOp->MakeCompound(aSubParts);
+              // add to parts list
+              addToListOfGO( aNewSubO, aNewParts );
+            }
+            else {
+              aNewSubO = aSubParts[0];
+            }
+
+            if (!CORBA::is_nil(aNewSubO)) {
+              // add the part to the list
+              aSubParts[i] = aNewSubO;
+              i++;
+
+              // Publish the sub-shape
+              if (!CORBA::is_nil(aNewSubSO)) {
+                TCollection_AsciiString aSubName;
+                if (theAddPrefix) {
+                  aSubName = "from_parts_of_";
+                }
+                aSubName += anArgName;
+                aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
+                // Restore color
+                aNewSubO->SetColor(anOldSubO->GetColor());
+                // set the texture
+                if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
+                  aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
+                  if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
+                    aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
+                }
+              }
+            }
+          }
+          else if (!CORBA::is_nil(aNewSubSO)) {
+            // remove created aSubSO, because no parts have been found
+            aStudyBuilder->RemoveObject(aNewSubSO);
+          }
+        } // try to build from published parts
+      }
+    }
+  } // iterate on published sub-shapes
+
+  aParts->length(i);
+  // add to parts list
+  addToListOfGO( aNewParts, aParts );
+  return aParts._retn();
+}
+
+//============================================================================
+// function : RestoreGivenSubShapes
+// purpose  : Private method. Works only if both theObject and theSObject
+//            are defined, and does not check, if they correspond to each other.
+//            List theArgs in this case contains not only operation arguments,
+//            but also all subshapes, which must be published.
+//============================================================================
+GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(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,
+                                                  CORBA::Boolean          theAddPrefix)
+{
+  GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
+  //PTv, IMP 0020001, The salome object <theSObject>
+  //     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();
+
+  // If theArgs list is empty, nothing to do
+  Standard_Integer aLength = theArgs.length();
+  if (aLength == 0)
+    return aParts._retn();
+
+  // Get all arguments
+  GEOM::ListOfGO_var anOpArgsList = theObject->GetDependency();
+  Standard_Integer nbArgsActual = anOpArgsList->length();
+
+  // If anOpArgsList list is empty, nothing to do
+  if (nbArgsActual == 0)
+    return aParts._retn();
+
+  // Entries of arguments and subshapes
+  std::set<std::string> anArgs;
+  for (int i = 0; i < aLength; i++) {
+    CORBA::String_var anEntry = theArgs[i]->GetEntry();
+    anArgs.insert(anEntry.in());
+  }
+
+  // Arguments to be published
+  // We try to publish all arguments, that are in theArgs list
+  GEOM::ListOfGO_var aList = new GEOM::ListOfGO;
+  aList->length(nbArgsActual);
+
+  int k = 0;
+  for (int j = 0; j < nbArgsActual; j++) {
+    CORBA::String_var anEntry = anOpArgsList[j]->GetEntry();
+    if (anArgs.count(anEntry.in())) {
+      aList[k] = GEOM::GEOM_Object::_duplicate(anOpArgsList[j]);
+      k++;
+    }
+  }
+  nbArgsActual = k;
+  //aList->length(nbArgsActual);
+
+  if (nbArgsActual < 1)
+    return aParts._retn();
+
+  if (theInheritFirstArg || (nbArgsActual == 1)) {
+    // Do not publish argument's reflection,
+    // but only reconstruct its published sub-shapes
+
+    CORBA::String_var anIOR = _orb->object_to_string(aList[0]);
+    SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
+
+    aParts = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject,
+                                           anArgs, theFindMethod, theAddPrefix);
+
+    // set the color of the transformed shape to the color of initial shape
+    theObject->SetColor(aList[0]->GetColor());
+    // set the texture
+    if (theObject->GetShapeType() == GEOM::VERTEX) {
+      theObject->SetMarkerStd(aList[0]->GetMarkerType(), aList[0]->GetMarkerSize());
+      if (aList[0]->GetMarkerType() == GEOM::MT_USER)
+        theObject->SetMarkerTexture(aList[0]->GetMarkerTexture());
+    }
+
+    anArgSO->Destroy();
+  }
+  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());
+
+    // 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 < nbArgsActual; 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();
+        }
+
+        // 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 if (anIDs->length() > 0) {
+              // 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;
+            if (theAddPrefix) {
+              aSubName = "from_";
+            }
+            aSubName += anArgName;
+            aSubSO = aStudyBuilder->NewObject(theSObject);
+            aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
+            // Restore color
+            aSubO->SetColor(anArgO->GetColor());
+            // set the texture
+            if (aSubO->GetShapeType() == GEOM::VERTEX) {
+              aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
+              if (anArgO->GetMarkerType() == GEOM::MT_USER)
+                aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
+            }
+          }
+
+          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 = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
+                                                        theObject, anArgs, theFindMethod, theAddPrefix);
+            else
+              aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
+                                                        aSubO, anArgs, theFindMethod, theAddPrefix);
+            // 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 =
+              RestoreGivenSubShapesOneLevel(theStudy, anArgSO, aSubSO,
+                                            theObject, anArgs, theFindMethod, theAddPrefix);
+
+            // 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;
+                if (theAddPrefix) {
+                  aSubName = "from_parts_of_";
+                }
+                aSubName += anArgName;
+                aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
+                // Restore color
+                aSubO->SetColor(anArgO->GetColor());
+                // set the texture
+                if (aSubO->GetShapeType() == GEOM::VERTEX) {
+                  aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
+                  if (anArgO->GetMarkerType() == GEOM::MT_USER)
+                    aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
+                }
+              }
+            }
+            else if (!CORBA::is_nil(aSubSO)) {
+              // remove created aSubSO, because no parts have been found
+              aStudyBuilder->RemoveObject(aSubSO);
+            }
+          }
+        } // try to build from published parts
+        anArgSO->Destroy();
+      }
+    } // process arguments
+  }
+  std::set<std::string> 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++ )
+    {
+      GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_duplicate( 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++;
+    }
+    pd <<"]" << " = geompy.RestoreGivenSubShapes(" << 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 << ", " << theAddPrefix << ")";
+  }
+  aResParts->length(nbRes);
+  return aResParts._retn();
+}
+
+//============================================================================
+// function : RestoreGivenSubShapesOneLevel
+// purpose  : Private method
+//============================================================================
+GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr     theStudy,
+                                                           SALOMEDS::SObject_ptr   theOldSO,
+                                                           SALOMEDS::SObject_ptr   theNewSO,
+                                                           GEOM::GEOM_Object_ptr   theNewO,
+                                                           std::set<std::string>   theArgs,
+                                                           GEOM::find_shape_method theFindMethod,
+                                                           CORBA::Boolean          theAddPrefix)
+{
+  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)*/)
+    return aParts._retn();
+
+  SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+
+  // 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 published sub-shapes
+  SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO);
+
+  int aLen = 0;
+  for (it->Init(); it->More(); it->Next()) {
+    aLen++;
+  }
+  aParts->length(aLen);
+
+  for (it->Init(); it->More(); it->Next()) {
+    SALOMEDS::SObject_var anOldSubSO = it->Value();
+
+    TCollection_AsciiString anArgName = anOldSubSO->GetName();
+
+    SALOMEDS::GenericAttribute_var anAttr;
+    if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) {
+      SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+      GEOM::GEOM_Object_var anOldSubO =
+        GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value()));
+
+      bool okToContinue = false;
+
+      if (!CORBA::is_nil(anOldSubO)) {
+        CORBA::String_var anEntry = anOldSubO->GetEntry();
+        okToContinue = theArgs.count(anEntry.in());
+      }
+
+      if (okToContinue) {
+        // Find a sub-shape of theNewO in place of anOldSubO
+        GEOM::GEOM_Object_var aNewSubO;
+        switch (theFindMethod) {
+        case GEOM::FSM_GetInPlace:
+          {
+            // Use GetInPlace
+            aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
+          }
+          break;
+        case GEOM::FSM_Transformed:
+          {
+            // transformation, cannot use GetInPlace, operate with indices
+            GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices();
+            if (anIDs->length() > 1) {
+              // group
+              aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO));
+              if (!CORBA::is_nil(aNewSubO))
+                aGroupOp->UnionIDs(aNewSubO, anIDs);
+            }
+            else {
+              // single sub-shape
+              aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]);
+            }
+          }
+          break;
+        case GEOM::FSM_GetSame:
+          {
+            // Use GetSame
+            aNewSubO = aShapesOp->GetSame(theNewO, anOldSubO);
+          }
+          break;
+        case GEOM::FSM_GetShapesOnShape:
+          {
+            // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
+            aNewSubO = aShapesOp->GetShapesOnShapeAsCompound(anOldSubO, theNewO,
+                                                             (short)GEOM::SOLID, GEOM::ST_ONIN);
+          }
+          break;
+        case GEOM::FSM_GetInPlaceByHistory:
+          {
+            // Use GetInPlaceByHistory
+            aNewSubO = aShapesOp->GetInPlaceByHistory(theNewO, anOldSubO);
+          }
+          break;
+        default:
+          {}
+        }
+
+        if (!CORBA::is_nil(aNewSubO)) {
+          // add the part to the list
+          aParts[i] = aNewSubO;
+          i++;
+          // add to parts list
+          addToListOfGO( aNewSubO, aNewParts );
+
+          SALOMEDS::SObject_var aNewSubSO;
+          if (!CORBA::is_nil(theNewSO)) {
+              // Publish the sub-shape
+            TCollection_AsciiString aSubName;
+            if (theAddPrefix) {
+              aSubName = "from_";
+            }
+            aSubName += anArgName;
+            aNewSubSO = aStudyBuilder->NewObject(theNewSO);
+            aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
+            // Restore color
+            aNewSubO->SetColor(anOldSubO->GetColor());
+            // set the texture
+            if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
+              aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
+              if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
+                aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
+            }
+          }
+          // 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
+            aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
+                                                      theNewO, theArgs, theFindMethod, theAddPrefix);
+          else
+            aSubParts = RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
+                                                      aNewSubO, theArgs, theFindMethod, theAddPrefix);
+          // add to parts list
+          addToListOfGO( aSubParts, aNewParts );
+        }
+        else { // GetInPlace failed, try to build from published parts
+          SALOMEDS::SObject_var aNewSubSO;
+          if (!CORBA::is_nil(theNewSO))
+            aNewSubSO = aStudyBuilder->NewObject(theNewSO);
+
+          // Restore published sub-shapes of the argument
+          GEOM::ListOfGO_var aSubParts =
+            RestoreGivenSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
+                                          theNewO, theArgs, theFindMethod, theAddPrefix);
           // add to parts list
           addToListOfGO( aSubParts, aNewParts );
 
index cb8db42a2202a9e4d49ea87f41b3f0f3402a1178..9f24703c3f635bfc3e96bda43c30c5ad7e5a1ea6 100644 (file)
@@ -18,7 +18,6 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 #ifndef __GEOM_GEN_I_H__
 #define __GEOM_GEN_I_H__
@@ -54,6 +53,9 @@
 
 #include <TopTools_IndexedMapOfShape.hxx>
 
+#include <set>
+#include <string>
+
 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
 
 
@@ -71,10 +73,10 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   // constructor to be called for servant creation.
   GEOM_Gen_i();
   GEOM_Gen_i(CORBA::ORB_ptr orb,
-            PortableServer::POA_ptr poa,
-            PortableServer::ObjectId * contId,
-            const char *instanceName,
-            const char *interfaceName);
+             PortableServer::POA_ptr poa,
+             PortableServer::ObjectId * contId,
+             const char *instanceName,
+             const char *interfaceName);
 
   // destructor, doing nothing (for now)
   virtual ~GEOM_Gen_i();
@@ -88,75 +90,85 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   //-----------------------------------------------------------------------//
 
   SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
-                         const char* theURL,
-                         bool isMultiFile);
+                          const char* theURL,
+                          bool isMultiFile);
 
   SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
-                              const char* theURL,
-                              bool isMultiFile);
+                               const char* theURL,
+                               bool isMultiFile);
 
   CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
-                     const SALOMEDS::TMPFile& theStream,
-                     const char* theURL,
-                     bool isMultiFile);
+                      const SALOMEDS::TMPFile& theStream,
+                      const char* theURL,
+                      bool isMultiFile);
 
   CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
-                          const SALOMEDS::TMPFile& theStream,
-                          const char* theURL,
-                          bool isMultiFile);
+                           const SALOMEDS::TMPFile& theStream,
+                           const char* theURL,
+                           bool isMultiFile);
 
   void Close(SALOMEDS::SComponent_ptr theComponent);
   char* ComponentDataType();
 
 
   char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
-                              const char* IORString,
-                              CORBA::Boolean isMultiFile,
-                              CORBA::Boolean isASCII);
+                               const char* IORString,
+                               CORBA::Boolean isMultiFile,
+                               CORBA::Boolean isASCII);
   char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
-                              const char* aLocalPersistentID,
-                              CORBA::Boolean isMultiFile,
-                              CORBA::Boolean isASCII);
+                               const char* aLocalPersistentID,
+                               CORBA::Boolean isMultiFile,
+                               CORBA::Boolean isASCII);
 
   bool CanPublishInStudy(CORBA::Object_ptr theIOR);
   SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
-                                      SALOMEDS::SObject_ptr theSObject,
-                                      CORBA::Object_ptr theObject,
-                                      const char* theName) throw (SALOME::SALOME_Exception) ;
+                                       SALOMEDS::SObject_ptr theSObject,
+                                       CORBA::Object_ptr theObject,
+                                       const char* theName) throw (SALOME::SALOME_Exception) ;
 
   GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
-                                           CORBA::Object_ptr theObject);
+                                            CORBA::Object_ptr theObject);
 
   CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
   SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
   CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
   SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
-                                 CORBA::Long theObjectID,
-                                 SALOMEDS::SObject_ptr theObject);
+                                  CORBA::Long theObjectID,
+                                  SALOMEDS::SObject_ptr theObject);
 
   /*! \brief Adds theObject in the study with a name = theName, if
    *         theFather is not null the object is placed under theFather
    */
   SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
-                                   GEOM::GEOM_Object_ptr theObject,
-                                   const char* theName,
-                                   GEOM::GEOM_Object_ptr theFather);
+                                    GEOM::GEOM_Object_ptr theObject,
+                                    const char* theName,
+                                    GEOM::GEOM_Object_ptr theFather);
 
   /*! \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)
    */
   GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr     theStudy,
-                                    GEOM::GEOM_Object_ptr   theObject,
+                                     GEOM::GEOM_Object_ptr   theObject,
                                      const GEOM::ListOfGO&   theArgs,
                                      GEOM::find_shape_method theFindMethod,
                                      CORBA::Boolean          theInheritFirstArg,
                                      CORBA::Boolean          theAddPrefix);
 
+  /*! \brief Publish sub-shapes, standing for given in \a theArgs arguments and sub-shapes.
+   *         To be used from python scripts, generated by Dump Python.
+   */
+  GEOM::ListOfGO* RestoreGivenSubShapesO (SALOMEDS::Study_ptr     theStudy,
+                                          GEOM::GEOM_Object_ptr   theObject,
+                                          const GEOM::ListOfGO&   theArgs,
+                                          GEOM::find_shape_method theFindMethod,
+                                          CORBA::Boolean          theInheritFirstArg,
+                                          CORBA::Boolean          theAddPrefix);
+
   /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
    *         To be used from GUI and from geompy.addToStudy
    */
   GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr     theStudy,
-                                     SALOMEDS::SObject_ptr   theSObject,
+                                      SALOMEDS::SObject_ptr   theSObject,
                                       const GEOM::ListOfGO&   theArgs,
                                       GEOM::find_shape_method theFindMethod,
                                       CORBA::Boolean          theInheritFirstArg,
@@ -230,7 +242,7 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
 
   //Adds a new sub shape
   virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
-                                            const GEOM::ListOfLong& theIndices);
+                                             const GEOM::ListOfLong& theIndices);
 
   virtual void RemoveObject(GEOM::GEOM_Object_ptr theObject);
 
@@ -239,17 +251,17 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
 
   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
-                                      CORBA::Boolean isPublished,
-                                      CORBA::Boolean& isValidScript);
+                                       CORBA::Boolean isPublished,
+                                       CORBA::Boolean& isValidScript);
 
   char* GetDumpName (const char* theStudyEntry);
 
   GEOM::string_array* GetAllDumpNames();
-  
+
   // Object information
   virtual bool hasObjectInfo();
   virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
-  
+
   //-----------------------------------------------------------------------//
   // Internal methods                                                      //
   //-----------------------------------------------------------------------//
@@ -257,29 +269,46 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
   virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
 
  private:
-  GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     theStudy,
-                                           SALOMEDS::SObject_ptr   theOldSO,
-                                           SALOMEDS::SObject_ptr   theNewSO,
-                                           GEOM::GEOM_Object_ptr   theNewO,
-                                           GEOM::find_shape_method theFindMethod,
-                                            CORBA::Boolean          theAddPrefix);
-
   GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr     theStudy,
-                                   GEOM::GEOM_Object_ptr   theObject,
+                                    GEOM::GEOM_Object_ptr   theObject,
                                     SALOMEDS::SObject_ptr   theSObject,
                                     const GEOM::ListOfGO&   theArgs,
                                     GEOM::find_shape_method theFindMethod,
                                     CORBA::Boolean          theInheritFirstArg,
                                     CORBA::Boolean          theAddPrefix);
 
+  GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     theStudy,
+                                            SALOMEDS::SObject_ptr   theOldSO,
+                                            SALOMEDS::SObject_ptr   theNewSO,
+                                            GEOM::GEOM_Object_ptr   theNewO,
+                                            GEOM::ListOfGO&         theOutArgs,
+                                            GEOM::find_shape_method theFindMethod,
+                                            CORBA::Boolean          theAddPrefix);
+
+  GEOM::ListOfGO* RestoreGivenSubShapes (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,
+                                         CORBA::Boolean          theAddPrefix);
+
+  GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr     theStudy,
+                                                 SALOMEDS::SObject_ptr   theOldSO,
+                                                 SALOMEDS::SObject_ptr   theNewSO,
+                                                 GEOM::GEOM_Object_ptr   theNewO,
+                                                 std::set<std::string>   theArgs,
+                                                 GEOM::find_shape_method theFindMethod,
+                                                 CORBA::Boolean          theAddPrefix);
+
   // auxilary for PublishNamedShapesInStudy
   void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
-                            GEOM::GEOM_Object_var theMainShape,
-                            const TopTools_IndexedMapOfShape& anIndices,
-                            const TopTools_SequenceOfShape& SeqS,
-                            const TColStd_SequenceOfAsciiString& SeqN,
-                            const Standard_CString& GrName,
-                            GEOM::ListOfGO_var aResList);
+                             GEOM::GEOM_Object_var theMainShape,
+                             const TopTools_IndexedMapOfShape& anIndices,
+                             const TopTools_SequenceOfShape& SeqS,
+                             const TColStd_SequenceOfAsciiString& SeqN,
+                             const Standard_CString& GrName,
+                             GEOM::ListOfGO_var aResList);
 
  private:
 
index a873fc9c8c31486b8f5ac644373b7a78a30935f0..67657dce1657117c1d5d7f76cb077dc0f15898a0 100644 (file)
@@ -408,6 +408,33 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             return self.RestoreSubShapesO(self.myStudy, theObject, theArgs,
                                           theFindMethod, theInheritFirstArg, theAddPrefix)
 
+        ## Publish sub-shapes, standing for arguments and sub-shapes of arguments
+        #  To be used from python scripts out of geompy.addToStudy (non-default usage)
+        #  \param theObject published GEOM object, arguments of which will be published
+        #  \param theArgs   list of GEOM_Object, operation arguments to be published.
+        #                   If this list is empty, all operation arguments will be published
+        #  \param theFindMethod method to search subshapes, corresponding to arguments and
+        #                       their subshapes. Value from enumeration GEOM::find_shape_method.
+        #  \param theInheritFirstArg set properties of the first argument for <VAR>theObject</VAR>.
+        #                            Do not publish subshapes in place of arguments, but only
+        #                            in place of subshapes of the first argument,
+        #                            because the whole shape corresponds to the first argument.
+        #                            Mainly to be used after transformations, but it also can be
+        #                            usefull after partition with one object shape, and some other
+        #                            operations, where only the first argument has to be considered.
+        #                            If theObject has only one argument shape, this flag is automatically
+        #                            considered as True, not regarding really passed value.
+        #  \param theAddPrefix add prefix "from_" to names of restored sub-shapes,
+        #                      and prefix "from_subshapes_of_" to names of partially restored subshapes.
+        #  \return list of published sub-shapes
+        #
+        #  @ref tui_restore_prs_params "Example"
+        def RestoreGivenSubShapes (self, theObject, theArgs=[], theFindMethod=GEOM.FSM_GetInPlace,
+                                   theInheritFirstArg=False, theAddPrefix=True):
+            # Example: see GEOM_TestAll.py
+            return self.RestoreGivenSubShapesO(self.myStudy, theObject, theArgs,
+                                               theFindMethod, theInheritFirstArg, theAddPrefix)
+
         # end of l3_restore_ss
         ## @}