]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 1 Feb 2021 14:15:38 +0000 (15:15 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 1 Feb 2021 14:15:38 +0000 (15:15 +0100)
src/SMESH_I/SMESH_Gen_No_Session_i.cxx
src/SMESH_I/SMESH_Gen_No_Session_i.hxx
src/SMESH_I/SMESH_Gen_Session_i.cxx
src/SMESH_I/SMESH_Gen_Session_i.hxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_PythonDump.cxx
src/SMESH_I/SMESH_PythonDump.hxx

index 3c216192fd7875edf3f2dbe7a7c149caac0806ca..f4f1f7877da07b42339920ee2f8c37c1411f5a8d 100644 (file)
@@ -18,7 +18,7 @@
 //
 
 #include "SMESH_Gen_No_Session_i.hxx"
-
+#include "SALOMEDS_Study_i.hxx"
 #include "SALOME_KernelServices.hxx"
 
 SMESH_Gen_No_Session_i::SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb,
@@ -36,3 +36,8 @@ GEOM::GEOM_Gen_var SMESH_Gen_No_Session_i::GetGeomEngine( bool isShaper )
   myGeomGen = GEOM::GEOM_Gen::_narrow( temp );
   return myGeomGen;
 }
+
+SALOMEDS::Study_var SMESH_Gen_No_Session_i::getStudyServant() const
+{
+  return SALOMEDS::Study::_duplicate(KERNEL::getStudyServantSA());
+}
index f3fd462fbc4a9795de94ab1f298b1a4e5ab1134f..da65157a8c4a0ac100430dd5052f44c38ba8a09e 100644 (file)
@@ -30,4 +30,5 @@ public:
                const char*               instanceName,
                const char*               interfaceName);
   GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override;
+  SALOMEDS::Study_var getStudyServant() const override;
 };
index a9b4c6bb0539d22b72cdfe3a27599094a6a415d5..e15c8ea7e1e2d73cd8c87ef327d7079e87c2d140 100644 (file)
@@ -18,7 +18,7 @@
 //
 
 #include "SMESH_Gen_Session_i.hxx"
-
+#include "SALOME_KernelServices.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
 
 
@@ -38,6 +38,11 @@ GEOM::GEOM_Gen_var SMESH_Gen_Session_i::GetGeomEngine( bool isShaper )
     return myGeomGen;
 }
 
+SALOMEDS::Study_var SMESH_Gen_Session_i::getStudyServant() const
+{
+  return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
+}
+
 extern "C"
 { SMESH_I_EXPORT
   PortableServer::ObjectId* SMESHEngine_factory( CORBA::ORB_ptr            orb,
index 464d13d0e7dc4f7a8c1c8e75df2adbfa1410a6da..4ce0678236248a7a6517d363b0bac1acc1aa2a71 100644 (file)
@@ -30,4 +30,6 @@ public:
                const char*               instanceName,
                const char*               interfaceName);
   GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override;
+  // Get the SALOMEDS::Study from naming service
+  SALOMEDS::Study_var getStudyServant() const override;
 };
index 23f7351118707ea9417dcda022abb69a067c8254..66f8570a3e32ba65299fd78a702c1b8e5ee42959 100644 (file)
@@ -812,7 +812,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam
     SALOMEDS::SObject_wrap aSO = PublishHypothesis( hyp );
     if ( !aSO->_is_nil() ) {
       // Update Python script
-      TPythonDump() << aSO << " = " << this << ".CreateHypothesis('"
+      TPythonDump(this) << aSO << " = " << this << ".CreateHypothesis('"
                     << theHypName << "', '" << theLibName << "')";
     }
   }
@@ -847,7 +847,7 @@ SMESH_Gen_i::CreateHypothesisByAverageLength( const char*    theHypType,
                                   initParams );
   SALOMEDS::SObject_wrap so = PublishHypothesis( hyp );
 
-  TPythonDump() << hyp << " = " << this << ".CreateHypothesisByAverageLength( '"
+  TPythonDump(this) << hyp << " = " << this << ".CreateHypothesisByAverageLength( '"
                 << theHypType << "', '"
                 << theLibName << "', "
                 << theAverageLength << ", "
@@ -1202,7 +1202,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj
     aStudyBuilder->CommitCommand();
     if ( !aSO->_is_nil() ) {
       // Update Python script
-      TPythonDump() << aSO << " = " << this << ".CreateMesh(" << theShapeObject << ")";
+      TPythonDump(this) << aSO << " = " << this << ".CreateMesh(" << theShapeObject << ")";
     }
   }
 
@@ -1232,7 +1232,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateEmptyMesh()
     aStudyBuilder->CommitCommand();
     if ( !aSO->_is_nil() ) {
       // Update Python script
-      TPythonDump() << aSO << " = " << this << ".CreateEmptyMesh()";
+      TPythonDump(this) << aSO << " = " << this << ".CreateEmptyMesh()";
     }
   }
 
@@ -1286,7 +1286,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
     aStudyBuilder->CommitCommand();
     if ( !aSO->_is_nil() ) {
       // Update Python script
-      TPythonDump() << aSO << " = " << this << ".CreateMeshesFromUNV(r'" << theFileName << "')";
+      TPythonDump(this) << aSO << " = " << this << ".CreateMeshesFromUNV(r'" << theFileName << "')";
     }
   }
 
@@ -1333,7 +1333,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileNa
   { // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
 
   // Python Dump
-  TPythonDump aPythonDump;
+  TPythonDump aPythonDump(this);
   aPythonDump << "([";
 
   if (theStatus == SMESH::DRS_OK) {
@@ -1483,7 +1483,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName
     aStudyBuilder->CommitCommand();
     if ( !aSO->_is_nil() ) {
       // Update Python script
-      TPythonDump() << aSO << " = " << this << ".CreateMeshesFromSTL(r'" << theFileName << "')";
+      TPythonDump(this) << aSO << " = " << this << ".CreateMeshesFromSTL(r'" << theFileName << "')";
     }
   }
 
@@ -1521,7 +1521,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char*
   { // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
 
     // Python Dump
-    TPythonDump aPythonDump;
+    TPythonDump aPythonDump(this);
     aPythonDump << "([";
 
     if (theStatus == SMESH::DRS_OK)
@@ -1609,7 +1609,7 @@ SMESH_Gen_i::CreateMeshesFromGMF( const char*             theFileName,
     aStudyBuilder->CommitCommand();
     if ( !aSO->_is_nil() ) {
       // Update Python script
-      TPythonDump() << "("<< aSO << ", error) = " << this << ".CreateMeshesFromGMF(r'"
+      TPythonDump(this) << "("<< aSO << ", error) = " << this << ".CreateMeshesFromGMF(r'"
                     << theFileName << "', "
                     << theMakeRequiredGroups << " )";
     }
@@ -1879,7 +1879,7 @@ SMESH_Gen_i::MakeGroupsOfBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
     if ( SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh ))
     {
       groups = meshServant->MakeGroupsOfBadInputElements( theSubShapeID, theGroupName );
-      TPythonDump() << groups << " = " << this
+      TPythonDump(this) << groups << " = " << this
                     << ".MakeGroupsOfBadInputElements( "
                     << theMesh << ", " << theSubShapeID << ", '" << theGroupName << "' )";
     }
@@ -2049,7 +2049,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
                                   SALOME::BAD_PARAM );
 
   // Update Python script
-  TPythonDump() << "isDone = " << this << ".Compute( "
+  TPythonDump(this) << "isDone = " << this << ".Compute( "
                 << theMesh << ", " << theShapeObject << ")";
 
   try {
@@ -2335,7 +2335,7 @@ SMESH::long_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh,
     nbels[i] = 0;
 
   // Update Python script
-  TPythonDump() << "theNbElems = " << this << ".Evaluate( "
+  TPythonDump(this) << "theNbElems = " << this << ".Evaluate( "
                 << theMesh << ", " << theShapeObject << ")";
 
   try {
@@ -2592,7 +2592,7 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::ListOfIDSources& theMeshesArray,
                                CORBA::Boolean                theCommonGroups,
                                SMESH::SMESH_Mesh_ptr         theMeshToAppendTo)
 {
-  std::unique_ptr< TPythonDump > pPythonDump( new TPythonDump );
+  std::unique_ptr< TPythonDump > pPythonDump( new TPythonDump(this) );
   TPythonDump& pythonDump = *pPythonDump; // prevent dump of called methods
 
   // create mesh if theMeshToAppendTo not provided
@@ -2873,7 +2873,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
 {
   Unexpect aCatch(SALOME_SalomeException);
 
-  TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh()
+  TPythonDump* pyDump = new TPythonDump(this); // prevent dump from CreateMesh()
   std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
 
   // 1. Get source mesh
@@ -3655,7 +3655,7 @@ CORBA::Boolean SMESH_Gen_i::CopyMeshWithGeom( SMESH::SMESH_Mesh_ptr       theSou
   bool ok = true;
   SMESH_TRY;
 
-  TPythonDump pyDump; // prevent dump from CreateMesh()
+  TPythonDump pyDump(this); // prevent dump from CreateMesh()
 
   theNewMesh        = CreateMesh( theNewGeometry );
   theNewGroups      = new SMESH::ListOfGroups();
@@ -4215,7 +4215,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
           SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ;
           if ( !myMesh->_is_nil() ) {
             myMesh->Load(); // load from study file if not yet done
-            TPythonDump pd; // not to dump GetGroups()
+            TPythonDump pd(this); // not to dump GetGroups()
             SMESH::ListOfGroups_var groups = myMesh->GetGroups();
             for ( CORBA::ULong i = 0; i < groups->length(); ++i )
             {
@@ -5211,7 +5211,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
     return false;
   }
 
-  TPythonDump pd; // prevent dump during loading
+  TPythonDump pd(this); // prevent dump during loading
 
   // For PAL13473 ("Repetitive mesh") implementation.
   // New dependencies between SMESH objects are established:
index f2c4c480148cb59ccd5aa7057e96b0f63666cb13..580340ab974d0e626e2cb5d1ce782b3fd27f5ff8 100644 (file)
@@ -109,14 +109,19 @@ public:
   // Retrieve and get GEOM engine reference
   virtual GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) = 0;
   static GEOM::GEOM_Gen_var GetGeomEngine( GEOM::GEOM_Object_ptr );
+  // Retrieve Study depending on Session / Standalone mode
+  virtual SALOMEDS::Study_var getStudyServant() const = 0;
+  SALOMEDS::SObject_ptr publish(CORBA::Object_ptr     theIOR,
+                                SALOMEDS::SObject_ptr theFatherObject,
+                                const int             theTag = 0,
+                                const char*           thePixMap = 0,
+                                const bool            theSelectable = true);
   // Get object of the CORBA reference
   static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
   // Get CORBA object corresponding to the SALOMEDS::SObject
   static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject );
   // Get the SALOMEDS::SObject corresponding to a CORBA object
-  static SALOMEDS::SObject_ptr ObjectToSObject( CORBA::Object_ptr theObject );
-  // Get the SALOMEDS::Study from naming service
-  static SALOMEDS::Study_var getStudyServant();
+  SALOMEDS::SObject_ptr ObjectToSObject( CORBA::Object_ptr theObject );
   // Get GEOM Object corresponding to TopoDS_Shape
   static GEOM::GEOM_Object_ptr ShapeToGeomObject( const TopoDS_Shape& theShape );
   // Get TopoDS_Shape corresponding to GEOM_Object
@@ -467,7 +472,7 @@ public:
 
   void CleanPythonTrace();
 
-  static int CountInPyDump(const TCollection_AsciiString& text);
+  int CountInPyDump(const TCollection_AsciiString& text);
 
   // *****************************************
   // Internal methods
@@ -521,12 +526,12 @@ public:
                                  SMESH::SMESH_Hypothesis_ptr theHyp);
   SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
                                                  GEOM::GEOM_Object_ptr theShape);
-  static void SetName(SALOMEDS::SObject_ptr theSObject,
-                      const char*           theName,
-                      const char*           theDefaultName = 0);
+  void SetName(SALOMEDS::SObject_ptr theSObject,
+              const char*           theName,
+              const char*           theDefaultName = 0);
 
-  static void SetPixMap(SALOMEDS::SObject_ptr theSObject,
-                        const char*           thePixMap);
+  void SetPixMap(SALOMEDS::SObject_ptr theSObject, const char *thePixMap);
+  void addReference (SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theToObject, int theTag = 0);
 
   //  Get study context
   StudyContext* GetStudyContext();
index a2577de8bfe8428074df27ed729c3049ec4deca4..26946cc2838f163010dfa5a27d96b7c798e9aa2f 100644 (file)
@@ -40,7 +40,6 @@
 #include <Utils_ExceptHandlers.hxx>
 #include <SALOMEDS_wrap.hxx>
 #include <SALOMEDS_Attributes_wrap.hxx>
-#include "SALOMEDS_Study_i.hxx"
 #include "SALOME_KernelServices.hxx"
 #include "SALOME_ModuleCatalog_impl.hxx"
 
@@ -211,15 +210,6 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(CORBA::Object_ptr theObject)
   return aSO._retn();
 }
 
-//=======================================================================
-//function : GetStudyPtr
-//purpose  : Get study from naming service
-//=======================================================================
-SALOMEDS::Study_var SMESH_Gen_i::getStudyServant()
-{
-  return SALOMEDS::Study::_duplicate(KERNEL::getStudyServantSA());
-}
-
 //=======================================================================
 //function : objectToServant
 //purpose  : 
@@ -293,14 +283,14 @@ GEOM::GEOM_Object_ptr SMESH_Gen_i::GetGeomObjectByEntry( const std::string& entr
 //purpose  :
 //=======================================================================
 
-static SALOMEDS::SObject_ptr publish(CORBA::Object_ptr     theIOR,
+SALOMEDS::SObject_ptr SMESH_Gen_i::publish(CORBA::Object_ptr     theIOR,
                                      SALOMEDS::SObject_ptr theFatherObject,
-                                     const int             theTag = 0,
-                                     const char*           thePixMap = 0,
-                                     const bool            theSelectable = true)
+                                     const int             theTag,
+                                     const char*           thePixMap,
+                                     const bool            theSelectable)
 {
-  SALOMEDS::Study_var theStudy = SMESH_Gen_i::getStudyServant();
-  SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theIOR );
+  SALOMEDS::Study_var theStudy = getStudyServant();
+  SALOMEDS::SObject_wrap SO = ObjectToSObject( theIOR );
   SALOMEDS::StudyBuilder_var     aStudyBuilder = theStudy->NewBuilder();
   SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder();
   bool isNewSO = false, isInUseCaseTree = false;
@@ -441,9 +431,7 @@ void SMESH_Gen_i::SetPixMap(SALOMEDS::SObject_ptr theSObject,
 //purpose  : 
 //=======================================================================
 
-static void addReference (SALOMEDS::SObject_ptr theSObject,
-                          CORBA::Object_ptr     theToObject,
-                          int                   theTag = 0)
+void SMESH_Gen_i::addReference (SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theToObject, int theTag)
 {
   SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
   SALOMEDS::SObject_wrap aToObjSO = SMESH_Gen_i::ObjectToSObject( theToObject );
index b5c003e4c3b292fc5764cd60495a741205b11ac3..267c82b14e259855932a88e374554ae0b051e3f9 100644 (file)
@@ -299,7 +299,7 @@ void SMESH_Mesh_i::Clear()
     THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
   }
 
-  TPythonDump() <<  SMESH::SMESH_Mesh_var(_this()) << ".Clear()";
+  TPythonDump(_gen_i) <<  SMESH::SMESH_Mesh_var(_this()) << ".Clear()";
 
   SMESH::SMESH_Mesh_var mesh = _this();
   _gen_i->UpdateIcons( mesh );
@@ -325,7 +325,7 @@ void SMESH_Mesh_i::ClearSubMesh(CORBA::Long ShapeID)
   }
   _impl->GetMeshDS()->Modified();
 
-  TPythonDump() <<  SMESH::SMESH_Mesh_var(_this()) << ".ClearSubMesh( " << ShapeID << " )";
+  TPythonDump(_gen_i) <<  SMESH::SMESH_Mesh_var(_this()) << ".ClearSubMesh( " << ShapeID << " )";
 }
 
 //=============================================================================
@@ -661,7 +661,7 @@ SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr       aSubShape,
   if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
 
   // Update Python script
-  TPythonDump() << "status = " << mesh << ".AddHypothesis( "
+  TPythonDump(_gen_i) << "status = " << mesh << ".AddHypothesis( "
                 << aSubShape << ", " << anHyp << " )";
 
   return ConvertHypothesisStatus(status);
@@ -745,10 +745,10 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr
   }
   // Update Python script
   if(_impl->HasShapeToMesh())
-    TPythonDump() << "status = " << mesh << ".RemoveHypothesis( "
+    TPythonDump(_gen_i) << "status = " << mesh << ".RemoveHypothesis( "
                   << aSubShape << ", " << anHyp << " )";
   else
-    TPythonDump() << "status = " << mesh << ".RemoveHypothesis( "
+    TPythonDump(_gen_i) << "status = " << mesh << ".RemoveHypothesis( "
                   << anHyp << " )";
 
   return ConvertHypothesisStatus(status);
@@ -855,7 +855,7 @@ SMESH::submesh_array* SMESH_Mesh_i::GetSubMeshes()
   SMESH::submesh_array_var aList = new SMESH::submesh_array();
 
   // Python Dump
-  TPythonDump aPythonDump;
+  TPythonDump aPythonDump(_gen_i);
   if ( !_mapSubMeshIor.empty() )
     aPythonDump << "[ ";
 
@@ -924,7 +924,7 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap
         _gen_i->PublishSubMesh( aMesh, subMesh, aSubShape, theName );
       if ( !aSO->_is_nil()) {
         // Update Python script
-        TPythonDump() << aSO << " = " << aMesh << ".GetSubMesh( "
+        TPythonDump(_gen_i) << aSO << " = " << aMesh << ".GetSubMesh( "
                       << aSubShape << ", '" << theName << "' )";
       }
     }
@@ -967,7 +967,7 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
     builder->RemoveObjectWithChildren( anSO );
 
     // Update Python script
-    TPythonDump() << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )";
+    TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )";
   }
 
   if ( removeSubMesh( theSubMesh, aSubShape.in() ))
@@ -1000,7 +1000,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType
       _gen_i->PublishGroup( mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName);
     if ( !aSO->_is_nil())
       // Update Python script
-      TPythonDump() << aSO << " = " << mesh << ".CreateGroup( "
+      TPythonDump(_gen_i) << aSO << " = " << mesh << ".CreateGroup( "
                     << theElemType << ", '" << theName << "' )";
   }
   return aNewGroup._retn();
@@ -1035,7 +1035,7 @@ SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementType    theElemType,
       SALOMEDS::SObject_wrap aSO =
         _gen_i->PublishGroup( mesh, aNewGroup, theGeomObj, theName );
       if ( !aSO->_is_nil())
-        TPythonDump() << aSO << " = " << mesh << ".CreateGroupFromGEOM( "
+        TPythonDump(_gen_i) << aSO << " = " << mesh << ".CreateGroupFromGEOM( "
                       << theElemType << ", '" << theName << "', " << theGeomObj << " )";
     }
   }
@@ -1072,7 +1072,7 @@ SMESH_Mesh_i::CreateGroupFromFilter(SMESH::ElementType theElemType,
   SMESH::SMESH_GroupOnFilter_var aNewGroup = SMESH::SMESH_GroupOnFilter::_narrow
     ( createGroup( theElemType, theName, /*id=*/-1, TopoDS_Shape(), predicate ));
 
-  TPythonDump pd;
+  TPythonDump pd(_gen_i);
   if ( !aNewGroup->_is_nil() )
     aNewGroup->SetFilter( theFilter );
 
@@ -1114,10 +1114,10 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
   if ( !aGroupSO->_is_nil() )
   {
     // Update Python script
-    TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
+    TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
 
     // Remove group's SObject
-    SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
+    SALOMEDS::StudyBuilder_var builder = _gen_i->getStudyServant()->NewBuilder();
     builder->RemoveObjectWithChildren( aGroupSO );
   }
   aGroup->Modified(/*removed=*/true); // notify dependent Filter with FT_BelongToMeshGroup criterion
@@ -1165,7 +1165,7 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup
   std::vector< const SMDS_MeshElement* > elems( theGroup->Size() );
   elems.assign( elemBeg, elemEnd );
 
-  TPythonDump pyDump; // Suppress dump from RemoveGroup()
+  TPythonDump pyDump(_gen_i); // Suppress dump from RemoveGroup()
 
   // Remove group
   RemoveGroup( theGroup );
@@ -1219,7 +1219,7 @@ SMESH::ListOfGroups * SMESH_Mesh_i::GetGroups()
   SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
 
   // Python Dump
-  TPythonDump aPythonDump;
+  TPythonDump aPythonDump(_gen_i);
   if ( !_mapGroups.empty() )
   {
     aPythonDump << "[ ";
@@ -1278,7 +1278,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the
   if ( theGroup1->GetType() != theGroup2->GetType() )
     THROW_SALOME_CORBA_EXCEPTION("UnionGroups(): different group types",
                                  SALOME::BAD_PARAM);
-  TPythonDump pyDump;
+  TPythonDump pyDump(_gen_i);
 
   // Create Union
   aResGrp = CreateGroup( theGroup1->GetType(), theName );
@@ -1335,7 +1335,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionListOfGroups(const SMESH::ListOfGroups
   if ( aType == SMESH::ALL )
     return SMESH::SMESH_Group::_nil();
 
-  TPythonDump pyDump;
+  TPythonDump pyDump(_gen_i);
 
   // Create Union
   aResGrp = CreateGroup( aType, theName );
@@ -1384,7 +1384,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr
   if ( theGroup1->GetType() != theGroup2->GetType() )
     THROW_SALOME_CORBA_EXCEPTION("IntersectGroups(): different group types",
                                  SALOME::BAD_PARAM);
-  TPythonDump pyDump;
+  TPythonDump pyDump(_gen_i);
 
   // Create Intersection
   aResGrp = CreateGroup( theGroup1->GetType(), theName );
@@ -1474,7 +1474,7 @@ SMESH_Mesh_i::IntersectListOfGroups(const SMESH::ListOfGroups& theGroups,
   if ( aType == SMESH::ALL ) // all groups are nil
     return SMESH::SMESH_Group::_nil();
 
-  TPythonDump pyDump;
+  TPythonDump pyDump(_gen_i);
 
   // Create a group
   aResGrp = CreateGroup( aType, theName );
@@ -1532,7 +1532,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr
   if ( theGroup1->GetType() != theGroup2->GetType() )
     THROW_SALOME_CORBA_EXCEPTION("CutGroups(): different group types",
                                  SALOME::BAD_PARAM);
-  TPythonDump pyDump;
+  TPythonDump pyDump(_gen_i);
 
   aResGrp = CreateGroup( theGroup1->GetType(), theName );
   if ( aResGrp->_is_nil() )
@@ -1633,7 +1633,7 @@ SMESH_Mesh_i::CutListOfGroups(const SMESH::ListOfGroups& theMainGroups,
         toolGroupVec.push_back( grpDS );
   }
 
-  TPythonDump pyDump;
+  TPythonDump pyDump(_gen_i);
 
   // Create a group
   aResGrp = CreateGroup( aType, theName );
@@ -1743,7 +1743,7 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfIDSources& theGroups,
 
   // Create a group
 
-  TPythonDump pyDump;
+  TPythonDump pyDump(_gen_i);
 
   aResGrp = CreateGroup( theElemType, theName );
   if ( aResGrp->_is_nil() )
@@ -1903,7 +1903,7 @@ SMESH_Mesh_i::FaceGroupsSeparatedByEdges( CORBA::Double  theSharpAngle,
 
   SMESH::ListOfGroups_var resultGroups = new SMESH::ListOfGroups;
 
-  TPythonDump pyDump;
+  TPythonDump pyDump(_gen_i);
 
   SMESH_TRY;
   if ( _preMeshInfo )
@@ -2159,10 +2159,10 @@ void SMESH_Mesh_i::ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom)
     _gen_i->UpdateIcons( SMESH::SMESH_Mesh_var( _this() ));
   }
 
-  TPythonDump() << "SHAPERSTUDY.breakLinkForSubElements(salome.ObjectToSObject("
+  TPythonDump(_gen_i) << "SHAPERSTUDY.breakLinkForSubElements(salome.ObjectToSObject("
                 << me <<".GetMesh()), " << entry.in() << ")";
 
-  TPythonDump(<<  me << ".ReplaceShape( " << entry.in() << " )";
+  TPythonDump(_gen_i)<<  me << ".ReplaceShape( " << entry.in() << " )";
 
 }
 
@@ -2350,7 +2350,7 @@ void SMESH_Mesh_i::CheckGeomModif( bool theIsBreakLink )
   SMESH::SMESH_Mesh_var me = _this();
   GEOM::GEOM_Object_var mainGO = GetShapeToMesh();
 
-  TPythonDump dumpNothing; // prevent any dump
+  TPythonDump dumpNothing(_gen_i); // prevent any dump
 
   //bool removedFromClient = false;
 
@@ -3055,7 +3055,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase
 
   SALOMEDS::StudyBuilder_var builder;
   SALOMEDS::SObject_wrap     aGroupSO;
-  SALOMEDS::Study_var        aStudy = SMESH_Gen_i::getStudyServant();
+  SALOMEDS::Study_var        aStudy = _gen_i->getStudyServant();
   if ( !aStudy->_is_nil() ) {
     builder  = aStudy->NewBuilder();
     aGroupSO = _gen_i->ObjectToSObject( theGroup );
@@ -3070,7 +3070,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase
         builder->RemoveObject( so );
       }
       // Update Python script
-      TPythonDump() << aGroupSO << " = " << SMESH::SMESH_Mesh_var(_this())
+      TPythonDump(_gen_i) << aGroupSO << " = " << SMESH::SMESH_Mesh_var(_this())
                     << ".ConvertToStandalone( " << aGroupSO << " )";
 
       // change icon of Group on Filter
@@ -3510,7 +3510,7 @@ SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
   aMeshEdVar = _editor->_this();
 
   // Update Python script
-  TPythonDump() << _editor << " = "
+  TPythonDump(_gen_i) << _editor << " = "
                 << SMESH::SMESH_Mesh_var(_this()) << ".GetMeshEditor()";
 
   SMESH_CATCH( SMESH::throwCorbaException );
@@ -3601,7 +3601,7 @@ void SMESH_Mesh_i::SetAutoColor(CORBA::Boolean theAutoColor)
   Unexpect aCatch(SALOME_SalomeException);
   _impl->SetAutoColor(theAutoColor);
 
-  TPythonDump pyDump; // not to dump group->SetColor() from below code
+  TPythonDump pyDump(_gen_i); // not to dump group->SetColor() from below code
   pyDump << SMESH::SMESH_Mesh_var(_this()) <<".SetAutoColor( "<<theAutoColor<<" )";
 
   std::list<SALOMEDS::Color> aReservedColors;
@@ -3693,7 +3693,7 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char*    file,
   // Perform Export
   PrepareForWriting(file, overwrite);
   string aMeshName = "Mesh";
-  SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
+  SALOMEDS::Study_var aStudy = _gen_i->getStudyServant();
   if ( !aStudy->_is_nil() ) {
     SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject(  _this() );
     if ( !aMeshSO->_is_nil() ) {
@@ -3717,7 +3717,7 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char*    file,
   }
   // Update Python script
   // set name of mesh before export
-  TPythonDump() << _gen_i << ".SetName("
+  TPythonDump(_gen_i) << _gen_i << ".SetName("
                 << SMESH::SMESH_Mesh_var(_this()) << ", '" << aMeshName.c_str() << "')";
 
   // check names of groups
@@ -3746,7 +3746,7 @@ void SMESH_Mesh_i::ExportMED(const char*        file,
   string aMeshName = prepareMeshNameAndGroups(file, overwrite);
   _impl->ExportMED( file, aMeshName.c_str(), auto_groups, version, 0, autoDimension );
 
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
                 << file << "', "
                 << "auto_groups=" <<auto_groups << ", "
                 << "version=" << version <<  ", "
@@ -3771,7 +3771,7 @@ void SMESH_Mesh_i::ExportSAUV (const char* file,
     _preMeshInfo->FullLoadFromFile();
 
   string aMeshName = prepareMeshNameAndGroups(file, true);
-  TPythonDump() << SMESH::SMESH_Mesh_var( _this())
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var( _this())
                 << ".ExportSAUV( r'" << file << "', " << auto_groups << " )";
   _impl->ExportSAUV(file, aMeshName.c_str(), auto_groups);
 }
@@ -3792,7 +3792,7 @@ void SMESH_Mesh_i::ExportDAT (const char *file)
   // Update Python script
   // check names of groups
   checkGroupNames();
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportDAT( r'" << file << "' )";
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportDAT( r'" << file << "' )";
 
   // Perform Export
   PrepareForWriting(file);
@@ -3814,7 +3814,7 @@ void SMESH_Mesh_i::ExportUNV (const char *file)
   // Update Python script
   // check names of groups
   checkGroupNames();
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportUNV( r'" << file << "' )";
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportUNV( r'" << file << "' )";
 
   // Perform Export
   PrepareForWriting(file);
@@ -3836,7 +3836,7 @@ void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii)
   // Update Python script
   // check names of groups
   checkGroupNames();
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this())
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this())
                 << ".ExportSTL( r'" << file << "', " << isascii << " )";
 
   CORBA::String_var name;
@@ -3956,7 +3956,7 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
     GEOM::GEOM_BaseObject_var gbo = GEOM::GEOM_BaseObject::_narrow( fields[i] );
     goList[i] = gbo;
   }
-  TPythonDump() << _this() << ".ExportPartToMED( "
+  TPythonDump(_gen_i) << _this() << ".ExportPartToMED( "
                 << meshPart << ", r'"
                 << file << "', "
                 << auto_groups << ", "
@@ -4258,7 +4258,7 @@ void SMESH_Mesh_i::ExportPartToDAT(::SMESH::SMESH_IDSource_ptr meshPart,
   SMESH_MeshPartDS partDS( meshPart );
   _impl->ExportDAT(file,&partDS);
 
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this())
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this())
                 << ".ExportPartToDAT( " << meshPart << ", r'" << file << "' )";
 }
 //================================================================================
@@ -4279,7 +4279,7 @@ void SMESH_Mesh_i::ExportPartToUNV(::SMESH::SMESH_IDSource_ptr meshPart,
   SMESH_MeshPartDS partDS( meshPart );
   _impl->ExportUNV(file, &partDS);
 
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this())
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this())
                 << ".ExportPartToUNV( " << meshPart<< ", r'" << file << "' )";
 }
 //================================================================================
@@ -4306,7 +4306,7 @@ void SMESH_Mesh_i::ExportPartToSTL(::SMESH::SMESH_IDSource_ptr meshPart,
   SMESH_MeshPartDS partDS( meshPart );
   _impl->ExportSTL( file, isascii, name.in(), &partDS );
 
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportPartToSTL( "
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportPartToSTL( "
                 << meshPart<< ", r'" << file << "', " << isascii << ")";
 }
 
@@ -4342,7 +4342,7 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
 
   SMESH_CATCH( SMESH::throwCorbaException );
 
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportCGNS( "
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportCGNS( "
                 << meshPart<< ", r'" << file << "', " << overwrite << ")";
 #else
   THROW_SALOME_CORBA_EXCEPTION("CGNS library is unavailable", SALOME::INTERNAL_ERROR);
@@ -4368,7 +4368,7 @@ void SMESH_Mesh_i::ExportGMF(::SMESH::SMESH_IDSource_ptr meshPart,
   SMESH_MeshPartDS partDS( meshPart );
   _impl->ExportGMF(file, &partDS, withRequiredGroups);
 
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportGMF( "
+  TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportGMF( "
                 << meshPart<< ", r'"
                 << file << "', "
                 << withRequiredGroups << ")";
@@ -5786,7 +5786,7 @@ void SMESH_Mesh_i::CreateGroupServants()
       set<int>::iterator it = addedIDs.find( i_grp->first );
       if ( it != addedIDs.end() )
       {
-        TPythonDump() << i_grp->second << " = " << aMesh << ".GetGroups()[ "<< index << " ]";
+        TPythonDump(_gen_i) << i_grp->second << " = " << aMesh << ".GetGroups()[ "<< index << " ]";
         addedIDs.erase( it );
         if ( addedIDs.empty() )
           break;
@@ -5904,7 +5904,7 @@ void SMESH_Mesh_i::checkGroupNames()
   // avoid dump of "GetGroups"
   {
     // store python dump into a local variable inside local scope
-    SMESH::TPythonDump pDump; // do not delete this line of code
+    SMESH::TPythonDump pDump(_gen_i); // do not delete this line of code
     grpList = GetGroups();
   }
 
@@ -5955,7 +5955,7 @@ SMESH::string_array* SMESH_Mesh_i::GetLastParameters()
   SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
   if(gen) {
     CORBA::String_var aParameters = GetParameters();
-    SALOMEDS::ListOfListOfStrings_var aSections = SMESH_Gen_i::getStudyServant()->ParseVariables(aParameters);
+    SALOMEDS::ListOfListOfStrings_var aSections = _gen_i->getStudyServant()->ParseVariables(aParameters);
     if ( aSections->length() > 0 ) {
       SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
       aResult->length( aVars.length() );
@@ -6824,7 +6824,7 @@ TListOfListOfInt SMESH_Mesh_i::findConcurrentSubMeshes()
   bool res = false;
   ::SMESH_Mesh& mesh = GetImpl();
 
-  TPythonDump aPythonDump; // prevent dump of called methods
+  TPythonDump aPythonDump(_gen_i); // prevent dump of called methods
   aPythonDump << "isDone = " << SMESH::SMESH_Mesh_var(_this()) << ".SetMeshOrder( [ ";
 
   TListOfListOfInt subMeshOrder;
@@ -6886,7 +6886,7 @@ void SMESH_Mesh_i::convertMeshOrder (const TListOfListOfInt&     theIdsOrder,
                                      const bool                  theIsDump)
 {
   int nbSet = theIdsOrder.size();
-  TPythonDump aPythonDump; // prevent dump of called methods
+  TPythonDump aPythonDump(_gen_i); // prevent dump of called methods
   if ( theIsDump )
     aPythonDump << "[ ";
   theResOrder.length(nbSet);
index 3ecff618477b9bb3f43b2cc468048125bb85bbff..1ac3511b5ae4839f152952c83d12321b64db2f37 100644 (file)
@@ -69,8 +69,7 @@ namespace SMESH
       myVals[i] = SMESH_Comment(value[i]);
   }
 
-  TPythonDump::
-  TPythonDump():myVarsCounter(0)
+  TPythonDump::TPythonDump(SMESH_Gen_i *smesh):myVarsCounter(0),mySmesh(smesh)
   {
     ++myCounter;
   }
@@ -304,7 +303,7 @@ namespace SMESH
   operator<<(CORBA::Object_ptr theArg)
   {
     SMESH_Gen_i*          aSMESHGen = SMESH_Gen_i::GetSMESHGen();
-    SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+    SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
     if(!aSObject->_is_nil()) {
       CORBA::String_var id = aSObject->GetID();
       myStream << id;
@@ -323,7 +322,7 @@ namespace SMESH
   TPythonDump::
   operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
   {
-    SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+    SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
     if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
       myStream << "hyp_" << theArg->GetId();
     else
@@ -337,7 +336,7 @@ namespace SMESH
   {
     if ( CORBA::is_nil( theArg ) )
       return *this << "None";
-    SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+    SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
     if(!aSObject->_is_nil())
     {
       return *this << aSObject;
@@ -352,7 +351,7 @@ namespace SMESH
       SMESH::long_array_var    anElementsId = theArg->GetIDs();
       SMESH::array_of_ElementType_var types = theArg->GetTypes();
       SMESH::ElementType               type = types->length() ? types[0] : SMESH::ALL;
-      SALOMEDS::SObject_wrap         meshSO = SMESH_Gen_i::ObjectToSObject(mesh);
+      SALOMEDS::SObject_wrap         meshSO = mySmesh->ObjectToSObject(mesh);
       if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
         return *this << mesh << ".GetIDSource([], " << type << ")";
       else
index 1025f4cf85381d3490eb986d46e8d0a4f416f58b..9d5138c5e12637e9f14532d9833c331c6d5ff8fd 100644 (file)
@@ -121,8 +121,9 @@ namespace SMESH
     std::ostringstream myStream;
     static size_t      myCounter;
     int                myVarsCounter; // counts stored TVar's
+    SMESH_Gen_i       *mySmesh = nullptr;
   public:
-    TPythonDump();
+    TPythonDump(SMESH_Gen_i *smesh);
     virtual ~TPythonDump();
 
     TPythonDump&