From 7911fd4a180b52de89180dd88624d3d8dceb94d7 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 14 Jan 2021 07:27:11 +0100 Subject: [PATCH] WIP --- src/SMESH_I/SMESH_Gen_i.cxx | 6 ++---- src/SMESH_SWIG/SMeshHelper.cxx | 10 ++++++++++ src/SMESH_SWIG/SMeshHelper.h | 1 + src/SMESH_SWIG/SMeshHelper.i | 15 +++++++++++++++ src/SMESH_SWIG/smeshBuilder.py | 5 +++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 290428403..41f5da7dd 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -49,6 +49,7 @@ #include #include +#include "SALOME_KernelServices.hxx" #ifdef WIN32 #include @@ -282,11 +283,8 @@ 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" ); + CORBA::Object_var temp = KERNEL::RetrieveCompo(isShaper ? "SHAPERSTUDY" : "GEOM"); myGeomGen = GEOM::GEOM_Gen::_narrow( temp ); - return myGeomGen; } diff --git a/src/SMESH_SWIG/SMeshHelper.cxx b/src/SMESH_SWIG/SMeshHelper.cxx index c370fbb37..4b7b2b275 100644 --- a/src/SMESH_SWIG/SMeshHelper.cxx +++ b/src/SMESH_SWIG/SMeshHelper.cxx @@ -21,6 +21,8 @@ #include "SMESH_Gen_i.hxx" #include "SALOME_Container_i.hxx" +#include "SALOME_KernelServices.hxx" +#include "SALOMEDS_Study_i.hxx" #include @@ -48,3 +50,11 @@ std::string BuildSMESHInstanceInternal(bool checkNS) CORBA::String_var ior = orb->object_to_string(zeRef); return std::string(ior.in()); } + +std::string GetSessionInstanceInternal() +{ + SALOMEDS::Study_var study = KERNEL::getStudyServantSA(); + CORBA::ORB_ptr orb = KERNEL::getORB(); + CORBA::String_var ior = orb->object_to_string(study); + return std::string(ior.in()); +} diff --git a/src/SMESH_SWIG/SMeshHelper.h b/src/SMESH_SWIG/SMeshHelper.h index bef5532ca..dd3d5dabe 100644 --- a/src/SMESH_SWIG/SMeshHelper.h +++ b/src/SMESH_SWIG/SMeshHelper.h @@ -22,3 +22,4 @@ #include std::string BuildSMESHInstanceInternal(bool checkNS); +std::string GetSessionInstanceInternal(); diff --git a/src/SMESH_SWIG/SMeshHelper.i b/src/SMESH_SWIG/SMeshHelper.i index 8745d96e0..63b7c7e77 100644 --- a/src/SMESH_SWIG/SMeshHelper.i +++ b/src/SMESH_SWIG/SMeshHelper.i @@ -31,4 +31,19 @@ { return BuildSMESHInstanceInternal(checkNS); } + + std::string GetSessionInstance() + { + return GetSessionInstanceInternal(); + } } + +%pythoncode %{ + +def myStudy(): + import SALOMEDS + import CORBA + orb=CORBA.ORB_init(['']) + return orb.string_to_object(GetSessionInstance()) + +%} \ No newline at end of file diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 6ec2064ce..98c1f3e3b 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -652,8 +652,9 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ): self.geompyD=geompyD self.SetGeomEngine(geompyD) SMESH._objref_SMESH_Gen.UpdateStudy(self) - sb = salome.myStudy.NewBuilder() - sc = salome.myStudy.FindComponent("SMESH") + import GeomHelper + sb = GeomHelper.myStudy().NewBuilder() + sc = GeomHelper.myStudy().FindComponent("SMESH") if sc: sb.LoadWith(sc, self) pass -- 2.39.2