diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 1a5619a10..05688ce81 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -247,5 +247,6 @@ SET(SMESH_RESOURCES_FILES INSTALL(FILES ${SMESH_RESOURCES_FILES} DESTINATION ${SALOME_SMESH_INSTALL_RES_DATA}) SALOME_CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/SalomeApp.xml.in ${CMAKE_CURRENT_BINARY_DIR}/SalomeApp.xml INSTALL ${SALOME_SMESH_INSTALL_RES_DATA}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SalomeApp.xml RENAME SalomeAppSL.xml DESTINATION ${SALOME_SMESH_INSTALL_RES_DATA}) SALOME_CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/StdMeshers.xml.in ${CMAKE_CURRENT_BINARY_DIR}/StdMeshers.xml INSTALL ${SALOME_SMESH_INSTALL_RES_DATA}) SALOME_CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/SMESHCatalog.xml.in ${CMAKE_CURRENT_BINARY_DIR}/SMESHCatalog.xml INSTALL ${SALOME_SMESH_INSTALL_RES_DATA}) diff --git a/src/SMESHClient/CMakeLists.txt b/src/SMESHClient/CMakeLists.txt index 1e67b6624..6712177e9 100644 --- a/src/SMESHClient/CMakeLists.txt +++ b/src/SMESHClient/CMakeLists.txt @@ -36,6 +36,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/SMESHDS ${PROJECT_SOURCE_DIR}/src/SMESH ${PROJECT_SOURCE_DIR}/src/SMESHUtils + ${PROJECT_SOURCE_DIR}/src/SMESH_I ${PROJECT_BINARY_DIR}/idl ) diff --git a/src/SMESHClient/SMESH_Client.cxx b/src/SMESHClient/SMESH_Client.cxx index 0c1b1aeab..66d071a07 100644 --- a/src/SMESHClient/SMESH_Client.cxx +++ b/src/SMESHClient/SMESH_Client.cxx @@ -28,6 +28,7 @@ #include "SMESHDS_Mesh.hxx" #include "SMESHDS_Script.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_Component_Generator.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" @@ -783,26 +784,35 @@ SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB, { static SMESH::SMESH_Gen_var aMeshGen; - if(CORBA::is_nil(aMeshGen.in())){ + if(CORBA::is_nil(aMeshGen.in())) + { + Engines::EngineComponent_var isCompoInSSLMode = GetSMESHInstanceHasThis(); + if( CORBA::is_nil(isCompoInSSLMode) ) + { #ifdef WIN32 - long aClientPID = (long)_getpid(); + long aClientPID = (long)_getpid(); #else - long aClientPID = (long)getpid(); + long aClientPID = (long)getpid(); #endif - SALOME_NamingService aNamingService(theORB); - SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService); - Engines::EngineComponent_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH"); - aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent); + SALOME_NamingService aNamingService(theORB); + SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService); + Engines::EngineComponent_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH"); + aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent); - std::string aClientHostName = Kernel_Utils::GetHostname(); - Engines::Container_var aServerContainer = aMeshGen->GetContainerRef(); - CORBA::String_var aServerHostName = aServerContainer->getHostName(); - CORBA::Long aServerPID = aServerContainer->getPID(); - aMeshGen->SetEmbeddedMode((aClientPID == aServerPID) && (aClientHostName == aServerHostName.in())); + std::string aClientHostName = Kernel_Utils::GetHostname(); + Engines::Container_var aServerContainer = aMeshGen->GetContainerRef(); + CORBA::String_var aServerHostName = aServerContainer->getHostName(); + CORBA::Long aServerPID = aServerContainer->getPID(); + aMeshGen->SetEmbeddedMode((aClientPID == aServerPID) && (aClientHostName == aServerHostName.in())); + } + else + { + aMeshGen = SMESH::SMESH_Gen::_narrow(isCompoInSSLMode); + } + } theIsEmbeddedMode = aMeshGen->IsEmbeddedMode(); - return aMeshGen; } diff --git a/src/SMESHGUI/CMakeLists.txt b/src/SMESHGUI/CMakeLists.txt index 5bd61d945..af116da9f 100644 --- a/src/SMESHGUI/CMakeLists.txt +++ b/src/SMESHGUI/CMakeLists.txt @@ -42,6 +42,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/Controls ${PROJECT_SOURCE_DIR}/src/SMESHClient ${PROJECT_SOURCE_DIR}/src/MEDWrapper + ${PROJECT_SOURCE_DIR}/src/SMESH_I ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/idl ) @@ -73,6 +74,7 @@ SET(_link_LIBRARIES SMDS SMESHControls SMESHObject + SMESHEngine ) # --- headers --- diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index ff88035b1..e96570c1f 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -104,6 +104,7 @@ #include "SMESH_ControlsDef.hxx" #include "SMESH_ScalarBarActor.h" #include "SMESH_TypeFilter.hxx" +#include "SMESH_Component_Generator.hxx" // SALOME GUI includes #include @@ -2155,13 +2156,20 @@ SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil(); * */ //============================================================================= -SMESHGUI::SMESHGUI() : -SalomeApp_Module( "SMESH" ) +SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" ) { if ( CORBA::is_nil( myComponentSMESH ) ) { CORBA::Boolean anIsEmbeddedMode; - myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode); + SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService(); + if( dynamic_cast(ns) ) + myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode); + else + { + Engines::EngineComponent_var comp = RetrieveSMESHInstance(); + myComponentSMESH = SMESH::SMESH_Gen::_narrow(comp); + } + //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode); // 0019923: EDF 765 SMESH : default values of hypothesis diff --git a/src/SMESH_I/CMakeLists.txt b/src/SMESH_I/CMakeLists.txt index cd73e1f09..9079fbf5a 100644 --- a/src/SMESH_I/CMakeLists.txt +++ b/src/SMESH_I/CMakeLists.txt @@ -31,6 +31,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/Controls ${PROJECT_SOURCE_DIR}/src/SMDS ${PROJECT_SOURCE_DIR}/src/SMESHDS + ${PROJECT_SOURCE_DIR}/src/SMESH_I ${PROJECT_SOURCE_DIR}/src/MEDWrapper ${PROJECT_SOURCE_DIR}/src/Driver ${PROJECT_SOURCE_DIR}/src/DriverMED @@ -111,6 +112,7 @@ SET(SMESHEngine_HEADERS SMESH_PreMeshInfo.hxx SMESH_MeshPartDS.hxx SMESH.hxx + SMESH_Component_Generator.hxx ) # --- sources --- @@ -138,6 +140,7 @@ SET(SMESHEngine_SOURCES SMESH_NoteBook.cxx SMESH_Measurements_i.cxx SMESH_PreMeshInfo.cxx + SMESH_Component_Generator.cxx ) # --- rules --- diff --git a/src/SMESH_I/SMESH_Component_Generator.cxx b/src/SMESH_I/SMESH_Component_Generator.cxx new file mode 100644 index 000000000..a1819c5e1 --- /dev/null +++ b/src/SMESH_I/SMESH_Component_Generator.cxx @@ -0,0 +1,60 @@ +// 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 "SMESH_Component_Generator.hxx" + +#include "SMESH_Gen_No_Session_i.hxx" +#include "SALOME_Container_i.hxx" +#include "SALOME_KernelServices.hxx" + +#include + +static Engines::EngineComponent_var _unique_compo; + +Engines::EngineComponent_var RetrieveSMESHInstance() +{ + if (CORBA::is_nil(_unique_compo)) + { + 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(); + CORBA::PolicyList policies; + policies.length(0); + Engines_Container_i *cont(KERNEL::getContainerSA()); + PortableServer::ObjectId *conId(cont->getCORBAId()); + // + pman->activate(); + // + SMESH_Gen_No_Session_i *servant = new SMESH_Gen_No_Session_i(orb, poa, conId, "SMESH_inst_2", "SMESH"); + PortableServer::ObjectId *zeId = servant->getId(); + CORBA::Object_var zeRef = poa->id_to_reference(*zeId); + _unique_compo = Engines::EngineComponent::_narrow(zeRef); + } + return _unique_compo; +} + +Engines::EngineComponent_var GetSMESHInstanceHasThis() +{ + return _unique_compo; +} diff --git a/src/SMESH_I/SMESH_Component_Generator.hxx b/src/SMESH_I/SMESH_Component_Generator.hxx new file mode 100644 index 000000000..db796a531 --- /dev/null +++ b/src/SMESH_I/SMESH_Component_Generator.hxx @@ -0,0 +1,29 @@ +// 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 "SMESH.hxx" + +#include "SALOMEconfig.h" + +#include CORBA_SERVER_HEADER(SMESH_Gen) + +SMESH_I_EXPORT Engines::EngineComponent_var RetrieveSMESHInstance(); +SMESH_I_EXPORT Engines::EngineComponent_var GetSMESHInstanceHasThis(); diff --git a/src/SMESH_I/SMESH_Gen_No_Session_i.cxx b/src/SMESH_I/SMESH_Gen_No_Session_i.cxx index 4bf1abf39..db261e7d4 100644 --- a/src/SMESH_I/SMESH_Gen_No_Session_i.cxx +++ b/src/SMESH_I/SMESH_Gen_No_Session_i.cxx @@ -20,6 +20,7 @@ #include "SMESH_Gen_No_Session_i.hxx" #include "SALOMEDS_Study_i.hxx" #include "SALOME_KernelServices.hxx" +#include "SALOME_Fake_NamingService.hxx" #include "SALOME_ModuleCatalog_impl.hxx" SMESH_Gen_No_Session_i::SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb, @@ -28,7 +29,7 @@ SMESH_Gen_No_Session_i::SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb, const char* instanceName, const char* interfaceName):SMESH_Gen_i(orb,poa,contId,instanceName,interfaceName,false) { - + myNS = new SALOME_Fake_NamingService; } GEOM::GEOM_Gen_var SMESH_Gen_No_Session_i::GetGeomEngine( bool isShaper ) diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 66f8570a3..e89466cfb 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -164,9 +164,9 @@ static int MYDEBUG = 0; GEOM::GEOM_Gen_var SMESH_Gen_i::myGeomGen; CORBA::ORB_var SMESH_Gen_i::myOrb; PortableServer::POA_var SMESH_Gen_i::myPoa; -SALOME_NamingService* SMESH_Gen_i::myNS = NULL; -SALOME_LifeCycleCORBA* SMESH_Gen_i::myLCC = NULL; -SMESH_Gen_i* SMESH_Gen_i::mySMESHGen = NULL; +SALOME_NamingService_Abstract* SMESH_Gen_i::myNS = nullptr; +SALOME_LifeCycleCORBA* SMESH_Gen_i::myLCC = nullptr; +SMESH_Gen_i* SMESH_Gen_i::mySMESHGen = nullptr; const int nbElemPerDiagonal = 10; @@ -245,7 +245,7 @@ CORBA::Object_var SMESH_Gen_i::SObjectToObject( SALOMEDS::SObject_ptr theSObject */ //============================================================================= -SALOME_NamingService* SMESH_Gen_i::GetNS() +SALOME_NamingService_Abstract* SMESH_Gen_i::GetNS() { if ( myNS == NULL ) { myNS = SINGLETON_::Instance(); @@ -340,7 +340,7 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb, // SMESH_Gen_i::SetEmbeddedMode(), have wrong IsEmbeddedMode flag if(checkNS) { - if ( SALOME_NamingService* ns = GetNS() ) + if ( SALOME_NamingService_Abstract* ns = GetNS() ) { CORBA::Object_var obj = ns->Resolve( "/Kernel/Session" ); SALOME::Session_var session = SALOME::Session::_narrow( obj ) ; diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index c78d57bfd..5a5ba6fad 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -104,7 +104,7 @@ public: // Get SMESH module's POA object static PortableServer::POA_var GetPOA() { return myPoa;} // Get Naming Service object - static SALOME_NamingService* GetNS(); + static SALOME_NamingService_Abstract* GetNS(); // Get SALOME_LifeCycleCORBA object static SALOME_LifeCycleCORBA* GetLCC(); // Retrieve and get GEOM engine reference @@ -646,10 +646,10 @@ private: protected: static GEOM::GEOM_Gen_var myGeomGen; + static SALOME_NamingService_Abstract* myNS; // Naming Service private: static CORBA::ORB_var myOrb; // ORB reference static PortableServer::POA_var myPoa; // POA reference - static SALOME_NamingService* myNS; // Naming Service static SALOME_LifeCycleCORBA* myLCC; // Life Cycle CORBA static SMESH_Gen_i* mySMESHGen; // Point to last created instance of the class ::SMESH_Gen myGen; // SMESH_Gen local implementation diff --git a/src/SMESH_SWIG/SMeshHelper.cxx b/src/SMESH_SWIG/SMeshHelper.cxx index 036ef2973..ee2d54b05 100644 --- a/src/SMESH_SWIG/SMeshHelper.cxx +++ b/src/SMESH_SWIG/SMeshHelper.cxx @@ -19,32 +19,15 @@ #include "SMeshHelper.h" -#include "SMESH_Gen_No_Session_i.hxx" -#include "SALOME_Container_i.hxx" #include "SALOME_KernelServices.hxx" +#include "SMESH_Component_Generator.hxx" + #include 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","SMESH",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(&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()); + Engines::EngineComponent_var zeRef = RetrieveSMESHInstance(); + CORBA::String_var ior = KERNEL::getORB()->object_to_string(zeRef); + return std::string(ior.in()); }