]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
2 servant implementations of SMESH::SMESH_GEN. One with Study and ModuleCatalog retri...
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 12 Jan 2021 11:01:34 +0000 (12:01 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 1 Feb 2021 19:13:06 +0000 (20:13 +0100)
29 files changed:
src/SMDS/SMDS_SpacePosition.cxx
src/SMDS/SMDS_SpacePosition.hxx
src/SMESH_I/CMakeLists.txt
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_Filter_i.cxx
src/SMESH_I/SMESH_Gen_No_Session_i.cxx [new file with mode: 0644]
src/SMESH_I/SMESH_Gen_No_Session_i.hxx [new file with mode: 0644]
src/SMESH_I/SMESH_Gen_Session_i.cxx [new file with mode: 0644]
src/SMESH_I/SMESH_Gen_Session_i.hxx [new file with mode: 0644]
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_Hypothesis_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_NoteBook.cxx
src/SMESH_I/SMESH_PreMeshInfo.cxx
src/SMESH_I/SMESH_PythonDump.cxx
src/SMESH_I/SMESH_PythonDump.hxx
src/SMESH_SWIG/CMakeLists.txt
src/SMESH_SWIG/SMeshHelper.cxx [new file with mode: 0644]
src/SMESH_SWIG/SMeshHelper.h [new file with mode: 0644]
src/SMESH_SWIG/SMeshHelper.i [new file with mode: 0644]
src/SMESH_SWIG/smeshBuilder.py
src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.cxx
src/StdMeshers_I/StdMeshers_ImportSource1D_i.cxx
src/StdMeshers_I/StdMeshers_ImportSource2D_i.cxx
src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx
src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx

index 6a2dcf4c97e6c7abd24465ec7a9cf3db49bae128..9a484419dba030b6d63a4de99ce8240267199bf7 100644 (file)
 #include "SMDS_SpacePosition.hxx"
 #include "SMDS_VertexPosition.hxx"
 
-SMDS_SpacePosition* SMDS_SpacePosition::_originPosition = new SMDS_SpacePosition();
+SMDS_SpacePosition* SMDS_SpacePosition::__originPosition = nullptr;
 
 SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition()
 {
-  return SMDS_PositionPtr( _originPosition, /*isOwner=*/false );
+  return SMDS_PositionPtr( _originPosition(), /*isOwner=*/false );
 }
 
 SMDS_PositionPtr SMDS_VertexPosition::StaticPosition()
@@ -42,3 +42,9 @@ SMDS_PositionPtr SMDS_VertexPosition::StaticPosition()
   return SMDS_PositionPtr( _vertexPosition, /*isOwner=*/false );
 }
 
+SMDS_SpacePosition *SMDS_SpacePosition::_originPosition()
+{
+  if(!__originPosition)
+    __originPosition = new SMDS_SpacePosition;
+  return __originPosition;
+}
\ No newline at end of file
index c3829010cad216edc6b87c137ea1bdabc9e6d83b..d5959870beb5833751cd320c3f8186bbcb9e54da 100644 (file)
@@ -40,7 +40,8 @@ class SMDS_EXPORT SMDS_SpacePosition : public SMDS_Position
   virtual const double* GetParameters() const { return 0; }
 
  private:
-  static SMDS_SpacePosition* _originPosition;
+  static SMDS_SpacePosition *_originPosition();
+  static SMDS_SpacePosition* __originPosition;
 };
 
 #endif
index 4f1695d841c1cbdce741a3310f8a22ecebcaa0dc..cd73e1f09c84a9e76584884edcc32a45db545995 100644 (file)
@@ -70,6 +70,8 @@ SET(_link_LIBRARIES
   ${KERNEL_SalomeIDLKERNEL}
   ${KERNEL_SALOMELocalTrace}
   ${KERNEL_SalomeKernelHelpers}
+  ${KERNEL_SalomeDS}
+  ${KERNEL_SalomeCatalog}
   ${OpenCASCADE_ApplicationFramework_LIBRARIES}
   ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
   ${GEOM_GEOMClient}
@@ -88,6 +90,8 @@ SET(_link_LIBRARIES
 # header files / no moc processing
 SET(SMESHEngine_HEADERS
   SMESH_Gen_i.hxx
+  SMESH_Gen_No_Session_i.hxx
+  SMESH_Gen_Session_i.hxx
   SMESH_Algo_i.hxx
   SMESH_0D_Algo_i.hxx
   SMESH_1D_Algo_i.hxx
@@ -115,6 +119,8 @@ SET(SMESHEngine_HEADERS
 SET(SMESHEngine_SOURCES
   SMESH_Gen_i.cxx
   SMESH_Gen_i_1.cxx
+  SMESH_Gen_No_Session_i.cxx
+  SMESH_Gen_Session_i.cxx
   SMESH_PythonDump.cxx
   SMESH_Mesh_i.cxx
   SMESH_subMesh_i.cxx
index 4ab71b44977e29027da7f1d171073e8ae71b4121..3f345151e76f19da3349fa359b51bf0c0d645c44 100644 (file)
@@ -584,7 +584,7 @@ _pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod
     // find a GEOM (aPass == 0) and SHAPERSTUDY (aPass == 1) entries
     for(int aPass = 0; aPass < 2; aPass++) {
       _pyID geomID;
-      SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::getStudyServant()->
+      SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->
         FindComponent(aPass == 0 ? "GEOM" : "SHAPERSTUDY");
       if (geomComp->_is_nil()) continue;
       CORBA::String_var entry = geomComp->GetID();
@@ -1717,7 +1717,7 @@ bool _pyGen::IsNotPublished(const _pyID& theObjID) const
   // either the SMESH object is not in study or it is a GEOM object
   if ( IsGeomObject( theObjID ))
   {
-    SALOMEDS::SObject_wrap so = SMESH_Gen_i::getStudyServant()->FindObjectID( theObjID.ToCString() );
+    SALOMEDS::SObject_wrap so = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( theObjID.ToCString() );
     if ( so->_is_nil() ) return true;
     CORBA::Object_var obj = so->GetObject();
     return CORBA::is_nil( obj );
index 2a952d4dbab99f5db5277230f0e4c8e65f026d47..e284279951a1c538bbd269bf9dbc169b89883c16 100644 (file)
@@ -136,9 +136,9 @@ static TopoDS_Shape getShapeByName( const char* theName )
   if ( theName != 0 )
   {
     SMESH_Gen_i* aSMESHGen     = SMESH_Gen_i::GetSMESHGen();
-    SALOMEDS::Study::ListOfSObject_var aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "GEOM" );
+    SALOMEDS::Study::ListOfSObject_var aList = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectByName( theName, "GEOM" );
     if ( aList->length() == 0 )
-      aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "SHAPERSTUDY" );
+      aList = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectByName( theName, "SHAPERSTUDY" );
     if ( aList->length() > 0 )
     {
       CORBA::Object_var        anObj = aList[ 0 ]->GetObject();
@@ -155,7 +155,7 @@ static TopoDS_Shape getShapeByID (const char* theID)
 {
   if ( theID && strlen( theID ) > 0 ) {
     SMESH_Gen_i*     aSMESHGen = SMESH_Gen_i::GetSMESHGen();
-    SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID(theID);
+    SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID(theID);
     if ( !aSObj->_is_nil() ) {
       CORBA::Object_var          obj = aSObj->GetObject();
       GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
@@ -828,7 +828,7 @@ void BelongToMeshGroup_i::SetGroupID( const char* theID ) // IOR or StoreName
   }
   else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI
   {
-    SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( myID.c_str() );
+    SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( myID.c_str() );
     if ( !aSObj->_is_nil() ) {
       CORBA::Object_var obj = aSObj->GetObject();
       SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
@@ -1713,7 +1713,7 @@ void ConnectedElements_i::SetThreshold ( const char*
     }
   case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry /////////////////
     {
-      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( threshold );
+      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( threshold );
       if ( sobj->_is_nil() )
         THROW_SALOME_CORBA_EXCEPTION
           ( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM );
diff --git a/src/SMESH_I/SMESH_Gen_No_Session_i.cxx b/src/SMESH_I/SMESH_Gen_No_Session_i.cxx
new file mode 100644 (file)
index 0000000..4bf1abf
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SMESH_Gen_No_Session_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
+#include "SALOME_KernelServices.hxx"
+#include "SALOME_ModuleCatalog_impl.hxx"
+
+SMESH_Gen_No_Session_i::SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb,
+                                                PortableServer::POA_ptr   poa,
+                                                PortableServer::ObjectId* contId,
+                                                const char*               instanceName,
+                                                const char*               interfaceName):SMESH_Gen_i(orb,poa,contId,instanceName,interfaceName,false)
+{
+
+}
+
+GEOM::GEOM_Gen_var SMESH_Gen_No_Session_i::GetGeomEngine( bool isShaper )
+{
+  CORBA::Object_var temp = KERNEL::RetrieveCompo(isShaper ? "SHAPERSTUDY" : "GEOM");
+  myGeomGen = GEOM::GEOM_Gen::_narrow( temp );
+  return myGeomGen;
+}
+
+SALOMEDS::Study_var SMESH_Gen_No_Session_i::getStudyServantVirtual() const
+{
+  return SALOMEDS::Study::_duplicate(KERNEL::getStudyServantSA());
+}
+
+SALOME_ModuleCatalog::ModuleCatalog_var SMESH_Gen_No_Session_i::getModuleCatalog() const
+{
+  SALOME_ModuleCatalog::ModuleCatalog_var aCat = KERNEL::getModuleComponentServantSA();
+  return aCat;
+}
diff --git a/src/SMESH_I/SMESH_Gen_No_Session_i.hxx b/src/SMESH_I/SMESH_Gen_No_Session_i.hxx
new file mode 100644 (file)
index 0000000..e79407d
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SMESH_Gen_i.hxx"
+
+class SMESH_I_EXPORT SMESH_Gen_No_Session_i : public SMESH_Gen_i
+{
+public:
+  SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb,
+               PortableServer::POA_ptr   poa,
+               PortableServer::ObjectId* contId,
+               const char*               instanceName,
+               const char*               interfaceName);
+  GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override;
+  SALOMEDS::Study_var getStudyServantVirtual() const override;
+  SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const override;
+};
diff --git a/src/SMESH_I/SMESH_Gen_Session_i.cxx b/src/SMESH_I/SMESH_Gen_Session_i.cxx
new file mode 100644 (file)
index 0000000..f2577d7
--- /dev/null
@@ -0,0 +1,63 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SMESH_Gen_Session_i.hxx"
+#include "SALOME_KernelServices.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+
+
+SMESH_Gen_Session_i::SMESH_Gen_Session_i( CORBA::ORB_ptr orb,
+                                        PortableServer::POA_ptr   poa,
+                                        PortableServer::ObjectId* contId,
+                                        const char*               instanceName,
+                                        const char*               interfaceName):SMESH_Gen_i(orb,poa,contId,instanceName,interfaceName,true)
+{
+
+}
+
+GEOM::GEOM_Gen_var SMESH_Gen_Session_i::GetGeomEngine( bool isShaper )
+{
+    Engines::EngineComponent_ptr temp = GetLCC()->FindOrLoad_Component( isShaper ? "FactoryServer" : "FactoryServer", isShaper ? "SHAPERSTUDY" : "GEOM" );
+    myGeomGen = GEOM::GEOM_Gen::_narrow( temp );
+    return myGeomGen;
+}
+
+SALOMEDS::Study_var SMESH_Gen_Session_i::getStudyServantVirtual() const
+{
+  return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
+}
+
+SALOME_ModuleCatalog::ModuleCatalog_var SMESH_Gen_Session_i::getModuleCatalog() const
+{
+  SALOME_ModuleCatalog::ModuleCatalog_var aCat = SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") );
+  return aCat;
+}
+
+extern "C"
+{ SMESH_I_EXPORT
+  PortableServer::ObjectId* SMESHEngine_factory( CORBA::ORB_ptr            orb,
+                                                 PortableServer::POA_ptr   poa,
+                                                 PortableServer::ObjectId* contId,
+                                                 const char*               instanceName,
+                                                 const char*               interfaceName )
+  {
+    SMESH_Gen_Session_i* aSMESHGen = new SMESH_Gen_Session_i(orb, poa, contId, instanceName, interfaceName);
+    return aSMESHGen->getId() ;
+  }
+}
diff --git a/src/SMESH_I/SMESH_Gen_Session_i.hxx b/src/SMESH_I/SMESH_Gen_Session_i.hxx
new file mode 100644 (file)
index 0000000..af69571
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SMESH_Gen_i.hxx"
+
+class SMESH_I_EXPORT SMESH_Gen_Session_i : public SMESH_Gen_i
+{
+public:
+  SMESH_Gen_Session_i( CORBA::ORB_ptr orb,
+               PortableServer::POA_ptr   poa,
+               PortableServer::ObjectId* contId,
+               const char*               instanceName,
+               const char*               interfaceName);
+  GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override;
+  // Get the SALOMEDS::Study from naming service
+  SALOMEDS::Study_var getStudyServantVirtual() const override;
+  SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const override;
+};
index ad5b17f8c8ab13a011653dd5d542c124d91aa610..66f8570a3e32ba65299fd78a702c1b8e5ee42959 100644 (file)
@@ -49,7 +49,6 @@
 #include <TopoDS_Wire.hxx>
 #include <gp_Pnt.hxx>
 
-
 #ifdef WIN32
  #include <windows.h>
  #include <process.h>
@@ -280,24 +279,6 @@ SALOME_LifeCycleCORBA*  SMESH_Gen_i::GetLCC()
  */
 //=============================================================================
 
-GEOM::GEOM_Gen_var SMESH_Gen_i::GetGeomEngine( bool isShaper )
-{
-  Engines::EngineComponent_ptr temp =
-    GetLCC()->FindOrLoad_Component( isShaper ? "FactoryServer" : "FactoryServer",
-                                    isShaper ? "SHAPERSTUDY" : "GEOM" );
-  myGeomGen = GEOM::GEOM_Gen::_narrow( temp );
-
-  return myGeomGen;
-}
-
-//=============================================================================
-/*!
- *  GetGeomEngine [ static ]
- *
- *  Get GEOM::GEOM_Gen reference
- */
-//=============================================================================
-
 GEOM::GEOM_Gen_var SMESH_Gen_i::GetGeomEngine( GEOM::GEOM_Object_ptr go )
 {
   GEOM::GEOM_Gen_ptr gen = GEOM::GEOM_Gen::_nil();
@@ -330,8 +311,9 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr            orb,
                           PortableServer::POA_ptr   poa,
                           PortableServer::ObjectId* contId,
                           const char*               instanceName,
-                          const char*               interfaceName )
-  : Engines_Component_i( orb, poa, contId, instanceName, interfaceName )
+                          const char*               interfaceName,
+                          bool                      checkNS)
+  : Engines_Component_i( orb, poa, contId, instanceName, interfaceName, false, checkNS )
 {
 
   myOrb = CORBA::ORB::_duplicate(orb);
@@ -356,21 +338,24 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr            orb,
   // find out mode (embedded or standalone) here else
   // meshes created before calling SMESH_Client::GetSMESHGen(), which calls
   // SMESH_Gen_i::SetEmbeddedMode(), have wrong IsEmbeddedMode flag
-  if ( SALOME_NamingService* ns = GetNS() )
+  if(checkNS)
   {
-    CORBA::Object_var obj = ns->Resolve( "/Kernel/Session" );
-    SALOME::Session_var session = SALOME::Session::_narrow( obj ) ;
-    if ( !session->_is_nil() )
+    if ( SALOME_NamingService* ns = GetNS() )
     {
-      CORBA::String_var str_host = session->getHostname();
-      CORBA::Long        s_pid = session->getPID();
-      string my_host = Kernel_Utils::GetHostname();
+      CORBA::Object_var obj = ns->Resolve( "/Kernel/Session" );
+      SALOME::Session_var session = SALOME::Session::_narrow( obj ) ;
+      if ( !session->_is_nil() )
+      {
+        CORBA::String_var str_host = session->getHostname();
+        CORBA::Long        s_pid = session->getPID();
+        string my_host = Kernel_Utils::GetHostname();
 #ifdef WIN32
-      long    my_pid = (long)_getpid();
+        long    my_pid = (long)_getpid();
 #else
-      long    my_pid = (long) getpid();
+        long    my_pid = (long) getpid();
 #endif
-      SetEmbeddedMode( s_pid == my_pid && my_host == str_host.in() );
+        SetEmbeddedMode( s_pid == my_pid && my_host == str_host.in() );
+      }
     }
   }
 }
@@ -827,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 << "')";
     }
   }
@@ -862,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 << ", "
@@ -1217,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 << ")";
     }
   }
 
@@ -1247,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()";
     }
   }
 
@@ -1301,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 << "')";
     }
   }
 
@@ -1348,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) {
@@ -1498,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 << "')";
     }
   }
 
@@ -1536,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)
@@ -1624,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 << " )";
     }
@@ -1894,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 << "' )";
     }
@@ -2064,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 {
@@ -2350,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 {
@@ -2607,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
@@ -2888,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
@@ -3670,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();
@@ -4230,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 )
             {
@@ -5226,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:
@@ -6581,26 +6566,3 @@ std::vector<long> SMESH_Gen_i::_GetInside( SMESH::SMESH_IDSource_ptr meshPart,
   }
   return res;
 }
-
-//=============================================================================
-/*!
- *  SMESHEngine_factory
- *
- *  C factory, accessible with dlsym, after dlopen
- */
-//=============================================================================
-
-extern "C"
-{ SMESH_I_EXPORT
-  PortableServer::ObjectId* SMESHEngine_factory( CORBA::ORB_ptr            orb,
-                                                 PortableServer::POA_ptr   poa,
-                                                 PortableServer::ObjectId* contId,
-                                                 const char*               instanceName,
-                                                 const char*               interfaceName )
-  {
-    if(MYDEBUG) MESSAGE( "PortableServer::ObjectId* SMESHEngine_factory()" );
-    if(MYDEBUG) SCRUTE(interfaceName);
-    SMESH_Gen_i* aSMESHGen = new SMESH_Gen_i(orb, poa, contId, instanceName, interfaceName);
-    return aSMESHGen->getId() ;
-  }
-}
index fb16909b89743ceb7c0822599a0afd0ef66409a9..c78d57bfd9b8f99c9e9b05bfcf5a06851e78fc4e 100644 (file)
@@ -35,6 +35,7 @@
 #include CORBA_CLIENT_HEADER(GEOM_Gen)
 #include CORBA_CLIENT_HEADER(SALOMEDS)
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
+#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
 
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh_i.hxx"
@@ -93,9 +94,7 @@ private:
 // ===========================================================
 // SMESH module's engine
 // ==========================================================
-class SMESH_I_EXPORT SMESH_Gen_i:
-  public virtual POA_SMESH::SMESH_Gen,
-  public virtual Engines_Component_i
+class SMESH_I_EXPORT SMESH_Gen_i : public POA_SMESH::SMESH_Gen, public Engines_Component_i
 {
 public:
   // Get last created instance of the class
@@ -109,16 +108,23 @@ public:
   // Get SALOME_LifeCycleCORBA object
   static SALOME_LifeCycleCORBA* GetLCC();
   // Retrieve and get GEOM engine reference
-  static GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper );
   static GEOM::GEOM_Gen_var GetGeomEngine( GEOM::GEOM_Object_ptr );
+  // Retrieve Study depending on Session / Standalone mode
+  virtual GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) = 0;
+  SALOMEDS::Study_var getStudyServant() const { return this->getStudyServantVirtual(); }
+  virtual SALOMEDS::Study_var getStudyServantVirtual() const = 0 ;
+  virtual SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() 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
@@ -133,7 +139,8 @@ public:
                PortableServer::POA_ptr   poa,
                PortableServer::ObjectId* contId,
                const char*               instanceName,
-               const char*               interfaceName );
+               const char*               interfaceName,
+               bool                      checkNS = true);
   // Destructor
   virtual ~SMESH_Gen_i();
 
@@ -468,7 +475,7 @@ public:
 
   void CleanPythonTrace();
 
-  static int CountInPyDump(const TCollection_AsciiString& text);
+  int CountInPyDump(const TCollection_AsciiString& text);
 
   // *****************************************
   // Internal methods
@@ -522,12 +529,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();
@@ -637,8 +644,9 @@ private:
                                const TopoDS_Shape&       Shape,
                                double*                   Tolerance = NULL);
 
-private:
+protected:
   static GEOM::GEOM_Gen_var      myGeomGen;
+private:
   static CORBA::ORB_var          myOrb;         // ORB reference
   static PortableServer::POA_var myPoa;         // POA reference
   static SALOME_NamingService*   myNS;          // Naming Service
index 8f6077ca98c4a86b6dd26d699de7461ed2801987..672477ccc89d3c2d1db25e68e06a326f50632859 100644 (file)
 #include "SMESH_Mesh_i.hxx"
 #include "SMESH_subMesh_i.hxx"
 
-#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
-
 #include <utilities.h>
 #include <Utils_ExceptHandlers.hxx>
 #include <SALOMEDS_wrap.hxx>
 #include <SALOMEDS_Attributes_wrap.hxx>
-#include <SALOME_KernelServices.hxx>
+#include "SALOME_KernelServices.hxx"
+#include "SALOME_ModuleCatalog_impl.hxx"
 
 #include <TCollection_AsciiString.hxx>
 #include <TopoDS_Solid.hxx>
@@ -209,15 +208,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::getStudyServant());
-}
-
 //=======================================================================
 //function : objectToServant
 //purpose  : 
@@ -291,14 +281,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;
@@ -439,9 +429,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 );
@@ -587,8 +575,7 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent()
 
   // If component for this SMESH engine does not exist in the study, create it
 
-  SALOME_ModuleCatalog::ModuleCatalog_var aCat =
-    SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") );
+  SALOME_ModuleCatalog::ModuleCatalog_var aCat = this->getModuleCatalog();
   if ( CORBA::is_nil( aCat ) )
     return father._retn();
 
index fae136798babbda3ea2b366ca41dcd38fbd11fa5..dc41602a9f04dd0b0e29588f7d3c6767f22b2a6c 100644 (file)
@@ -130,7 +130,7 @@ bool SMESH_Hypothesis_i::IsPublished()
   bool res = false;
   if ( SMESH_Gen_i::GetSMESHGen() )
   {
-    SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( _this());
+    SALOMEDS::SObject_wrap SO = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject( _this());
     res = !SO->_is_nil();
   }
   return res;
index d542d9c85ac4e29210a0f39c945615b3daea1db1..8befed7a42763113ed123dfd74d984ea7b229e90 100644 (file)
@@ -4052,9 +4052,9 @@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::Offset( SMESH::SMESH_IDSource_ptr theO
     if ( *theMeshName && mesh_var->NbFaces() == 0 )
     {
       // new mesh empty, remove it
-      SALOMEDS::Study_var          study = SMESH_Gen_i::getStudyServant();
+      SALOMEDS::Study_var          study = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
       SALOMEDS::StudyBuilder_var builder = study->NewBuilder();
-      SALOMEDS::SObject_wrap      meshSO = SMESH_Gen_i::ObjectToSObject( mesh_var );
+      SALOMEDS::SObject_wrap      meshSO = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject( mesh_var );
       builder->RemoveObjectWithChildren( meshSO );
       THROW_SALOME_CORBA_EXCEPTION("Offset failed", SALOME::INTERNAL_ERROR);
     }
index b5c003e4c3b292fc5764cd60495a741205b11ac3..c03151e8b1a3a5d3cf29d3ed5e51e5ddf903249c 100644 (file)
@@ -1117,7 +1117,7 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
     TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
 
     // Remove group's SObject
-    SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
+    SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewBuilder();
     builder->RemoveObjectWithChildren( aGroupSO );
   }
   aGroup->Modified(/*removed=*/true); // notify dependent Filter with FT_BelongToMeshGroup criterion
@@ -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 = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
   if ( !aStudy->_is_nil() ) {
     builder  = aStudy->NewBuilder();
     aGroupSO = _gen_i->ObjectToSObject( theGroup );
@@ -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 = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
   if ( !aStudy->_is_nil() ) {
     SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject(  _this() );
     if ( !aMeshSO->_is_nil() ) {
@@ -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 = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->ParseVariables(aParameters);
     if ( aSections->length() > 0 ) {
       SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
       aResult->length( aVars.length() );
index 3f53f2c28a461126e79a5cecfcaa19db0dbdc00a..f999ad4e2f5562e73fd4b3fca52106f65d3bafe3 100644 (file)
@@ -707,7 +707,7 @@ void SMESH_NoteBook::ReplaceVariables()
         // dumped calls due to the fix of
         // issue 0021364:: Dump of netgen parameters has duplicate lines
         SMESH_Gen_i *          aGen = SMESH_Gen_i::GetSMESHGen();
-        SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( (*it).first.ToCString() );
+        SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( (*it).first.ToCString() );
         CORBA::Object_var       obj = aGen->SObjectToObject( sobj );
         if ( SMESH_Hypothesis_i* h = SMESH::DownCast< SMESH_Hypothesis_i*>( obj ))
         {
@@ -744,7 +744,7 @@ void SMESH_NoteBook::InitObjectMap()
   if(!aGen)
     return;
   
-  SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
+  SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
   if(aStudy->_is_nil())
     return;
   
@@ -953,7 +953,7 @@ bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double&
 {
   bool ok = false;
 
-  SALOMEDS::Study_ptr aStudy = SMESH_Gen_i::getStudyServant();
+  SALOMEDS::Study_ptr aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
   if(aStudy->_is_nil())
     return ok;
 
index 7514ad21580bf1dd2b3a451346aa63836cea69a9..b3eaa31f3fe86f0f09b469645c4185f9342c9571 100644 (file)
@@ -1233,7 +1233,7 @@ void SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD(SALOMEDS::SComponent_ptr sme
 {
   if ( theMeshCounter > 0 )
   {
-    SALOMEDS::ChildIterator_wrap itBig = SMESH_Gen_i::getStudyServant()->NewChildIterator( smeshComp );
+    SALOMEDS::ChildIterator_wrap itBig = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewChildIterator( smeshComp );
     for ( ; itBig->More(); itBig->Next() ) {
       SALOMEDS::SObject_wrap gotBranch = itBig->Value();
       CORBA::Object_var       anObject = SMESH_Gen_i::SObjectToObject( gotBranch );
index 3ecff618477b9bb3f43b2cc468048125bb85bbff..e741f51f28856ecfc9086d3edd6bbc11549aba6e 100644 (file)
@@ -68,9 +68,13 @@ namespace SMESH
     for ( size_t i = 0; i < value.length(); i++)
       myVals[i] = SMESH_Comment(value[i]);
   }
+  
+  TPythonDump::TPythonDump():myVarsCounter(0),mySmesh(SMESH_Gen_i::GetSMESHGen())
+  {
+    ++myCounter;
+  }
 
-  TPythonDump::
-  TPythonDump():myVarsCounter(0)
+  TPythonDump::TPythonDump(SMESH_Gen_i *smesh):myVarsCounter(0),mySmesh(smesh)
   {
     ++myCounter;
   }
@@ -304,7 +308,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 +327,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 +341,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 +356,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..59a5df790fa55d351fb752463b1af97bcce62f6f 100644 (file)
@@ -121,7 +121,9 @@ namespace SMESH
     std::ostringstream myStream;
     static size_t      myCounter;
     int                myVarsCounter; // counts stored TVar's
+    SMESH_Gen_i       *mySmesh = nullptr;
   public:
+    TPythonDump(SMESH_Gen_i *smesh);
     TPythonDump();
     virtual ~TPythonDump();
 
index becd38840d877acd9622ce0ee9c9b454a779de64..4defb70f76d2f996bc461717c9be226951bfcbe8 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-# --- scripts ---
+include(${SWIG_USE_FILE})
+
+include_directories(
+  ${PROJECT_SOURCE_DIR}/src/SMESHDS
+  ${PROJECT_SOURCE_DIR}/src/SMESHUtils
+  ${PROJECT_SOURCE_DIR}/src/SMDS
+  ${PROJECT_SOURCE_DIR}/src/SMESH
+  ${PROJECT_SOURCE_DIR}/src/SMESH_I
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${PROJECT_BINARY_DIR}/idl
+)
 
 # scripts / static
 SET(_bin_SCRIPTS
@@ -99,6 +109,23 @@ SET(StdMeshers_SCRIPTS
   __init__.py
   StdMeshersBuilder.py
 )
+
+SET(SMeshHelper_HEADERS SMeshHelper.h SMeshHelper.i)
+SET(SMeshHelper_SOURCES SMeshHelper.cxx ${SMeshHelper_HEADERS})
+SET_SOURCE_FILES_PROPERTIES(SMeshHelper.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(SMeshHelper.i PROPERTIES SWIG_FLAGS "-py3")
+SET_SOURCE_FILES_PROPERTIES(SMeshHelper_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/SMeshHelper.py )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
+  SWIG_ADD_MODULE(SMeshHelper python ${SMeshHelper_SOURCES})
+ELSE()
+  SWIG_ADD_LIBRARY(SMeshHelper LANGUAGE python SOURCES ${SMeshHelper_SOURCES})
+ENDIF()
+SWIG_LINK_LIBRARIES(SMeshHelper ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SMESHEngine )
+install(TARGETS _SMeshHelper DESTINATION ${SALOME_INSTALL_LIBS})
+install(FILES ${SMeshHelper_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_SMeshHelper_REAL_NAME}")
+
 # --- rules ---
 SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_PYTHON} DEF_PERMS)
 SALOME_INSTALL_SCRIPTS("${smesh_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/smesh DEF_PERMS)
diff --git a/src/SMESH_SWIG/SMeshHelper.cxx b/src/SMESH_SWIG/SMeshHelper.cxx
new file mode 100644 (file)
index 0000000..48b910f
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SMeshHelper.h"
+
+#include "SMESH_Gen_No_Session_i.hxx"
+#include "SALOME_Container_i.hxx"
+#include "SALOME_KernelServices.hxx"
+
+#include <cstring>
+
+std::string BuildSMESHInstanceInternal()
+{
+    CORBA::ORB_var orb;
+    { int argc(0); orb = CORBA::ORB_init(argc,nullptr); }
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = poa->the_POAManager();
+    PortableServer::ObjectId_var conId;
+    //
+    {
+        char *argv[4] = {"Container","FactoryServer","toto",nullptr};
+        Engines_Container_i *cont = new Engines_Container_i(orb,poa,"FactoryServer",2,argv,false,false);
+        conId = poa->activate_object(cont);
+    }
+    //
+    pman->activate();
+    //
+    SMESH_Gen_No_Session_i *servant = new SMESH_Gen_No_Session_i(orb,poa,const_cast<PortableServer::ObjectId*>(&conId.in()),"SMESH_inst_2","SMESH");
+    PortableServer::ObjectId *zeId = servant->getId();
+    CORBA::Object_var zeRef = poa->id_to_reference(*zeId);
+    CORBA::String_var ior = orb->object_to_string(zeRef);
+    return std::string(ior.in());
+}
diff --git a/src/SMESH_SWIG/SMeshHelper.h b/src/SMESH_SWIG/SMeshHelper.h
new file mode 100644 (file)
index 0000000..58b2c53
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include <string>
+
+std::string BuildSMESHInstanceInternal();
diff --git a/src/SMESH_SWIG/SMeshHelper.i b/src/SMESH_SWIG/SMeshHelper.i
new file mode 100644 (file)
index 0000000..b73a87d
--- /dev/null
@@ -0,0 +1,34 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module SMeshHelper
+
+%include "std_string.i"
+
+%{
+#include "SMeshHelper.h"
+%}
+
+%inline
+{
+  std::string BuildSMESHInstance()
+  {
+    return BuildSMESHInstanceInternal();
+  }
+}
index 7bdc59eb4b2d63676e953e9f17e9e98f576072b7..3372442a92c2d6493049601c8dc3d8ed39119785 100644 (file)
@@ -1962,9 +1962,10 @@ class Mesh(metaclass = MeshMeta):
                 print(msg)
                 print(allReasons)
             pass
-        if salome.sg.hasDesktop():
-            if not isinstance( refresh, list): # not a call from subMesh.Compute()
-                if refresh: salome.sg.updateObjBrowser()
+        if salome.sg:
+            if salome.sg.hasDesktop():
+                if not isinstance( refresh, list): # not a call from subMesh.Compute()
+                    if refresh: salome.sg.updateObjBrowser()
 
         return ok
 
index 31db0a7be7f4e5add339605081fde9fe0cf9eb0a..6739557a13a0e157daf0a62fdeb61f12ff2b7356 100644 (file)
@@ -596,7 +596,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::updateState()
 GEOM::GEOM_Object_var StdMeshersGUI_SubShapeSelectorWdg::GetGeomObjectByEntry( const QString& theEntry )
 {
   GEOM::GEOM_Object_var aGeomObj;
-  SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.toUtf8().data() );
+  SALOMEDS::SObject_var aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( theEntry.toUtf8().data() );
   if (!aSObj->_is_nil() )
   {
     CORBA::Object_var obj = aSObj->GetObject();
index 17da16dd89751e32ccc2135fa3e9d4d51a02d6dd..fe49c6bda410dc458d35017e682547fa015b6905 100644 (file)
@@ -92,7 +92,7 @@ void StdMeshers_ImportSource1D_i::SetSourceEdges(const SMESH::ListOfGroups& grou
           THROW_SALOME_CORBA_EXCEPTION("Wrong group type", SALOME::BAD_PARAM);
         smesh_groups.push_back( gp_i->GetSmeshGroup() );
 
-        SALOMEDS::SObject_wrap so = SMESH_Gen_i::ObjectToSObject(groups[i]);
+        SALOMEDS::SObject_wrap so = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject(groups[i]);
         if ( !so->_is_nil())
         {
           CORBA::String_var entry = so->GetID();
@@ -171,7 +171,7 @@ char* StdMeshers_ImportSource1D_i::SaveTo()
     os << " " << _groupEntries[i];
 
     // id
-    SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( _groupEntries[i] );
+    SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( _groupEntries[i] );
     CORBA::Object_var     groupObj;
     if ( !groupSO->_is_nil() )
       groupObj = groupSO->GetObject();
index 6297b20ebc17336197cac05bb054ae7a1f226d94..68fd2017153df67cb0a8620b7e5c92d59cc54f41 100644 (file)
@@ -91,7 +91,7 @@ void StdMeshers_ImportSource2D_i::SetSourceFaces(const SMESH::ListOfGroups& grou
           THROW_SALOME_CORBA_EXCEPTION("Wrong group type", SALOME::BAD_PARAM);
         smesh_groups.push_back( gp_i->GetSmeshGroup() );
 
-        SALOMEDS::SObject_var so = SMESH_Gen_i::ObjectToSObject(groups[i]);
+        SALOMEDS::SObject_var so = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject(groups[i]);
         if ( !so->_is_nil())
         {
           CORBA::String_var entry = so->GetID();
@@ -171,7 +171,7 @@ char* StdMeshers_ImportSource2D_i::SaveTo()
     os << " " << _groupEntries[i];
 
     // id
-    SALOMEDS::SObject_var groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( _groupEntries[i] );
+    SALOMEDS::SObject_var groupSO = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( _groupEntries[i] );
     CORBA::Object_var    groupObj;
     if ( !groupSO->_is_nil() ) {
       groupObj = groupSO->GetObject();
index 7f9b2e5919ba2e268a181e816119fdd93f9ee375..45a4cd7bd102bd67dbc12aabca823f2dcbac398b 100644 (file)
@@ -90,7 +90,7 @@ void StdMeshers_LayerDistribution_i::SetLayerDistribution(SMESH::SMESH_Hypothesi
       SALOMEDS::SObject_var  SO = gen->ObjectToSObject( hyp1D );
       if ( ! SO->_is_nil() )
       {
-        SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
+        SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewBuilder();
         builder->RemoveObjectWithChildren( SO );
         SO->UnRegister();
       }
index 363e3132111ccc917d994780bed10ea36973f729..b5fae233f2567edd9c2012cdcabf9db4e14cd14d 100644 (file)
@@ -60,7 +60,7 @@ StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject (const std::string&  theEntry,
   // try by entry
   if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
     if ( ! theEntry.empty() ) {
-      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() );
+      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( theEntry.c_str() );
       CORBA::Object_var       obj = gen->SObjectToObject( sobj );
       geom = GEOM::GEOM_Object::_narrow( obj );
     }
@@ -116,7 +116,7 @@ TopoDS_Shape StdMeshers_ObjRefUlils::LoadFromStream( istream &    stream,
     if ( entry )
       * entry = str;
     if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
-      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( str.c_str() );
+      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( str.c_str() );
       CORBA::Object_var       obj = gen->SObjectToObject( sobj );
       GEOM::GEOM_Object_var  geom = GEOM::GEOM_Object::_narrow( obj );
       return gen->GeomObjectToShape( geom.in() );
@@ -173,7 +173,7 @@ TopoDS_Shape StdMeshers_ObjRefUlils::EntryToShape(const std::string theEntry)
   TopoDS_Shape shape;
 
   if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
-    SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() );
+    SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( theEntry.c_str() );
     CORBA::Object_var       obj = gen->SObjectToObject( sobj );
     GEOM::GEOM_Object_var  geom = GEOM::GEOM_Object::_narrow( obj );
     shape = gen->GeomObjectToShape( geom.in() );