From 189a27b3b2b0e2f60b428ab711784d2af5ac344f Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 20 Dec 2021 17:30:35 +0100 Subject: [PATCH] Padder smesh plugin in SSL mode --- src/SalomeSessionless/CMakeLists.txt | 1 + .../MeshJobManager_SalomeSessionless.py | 28 +++++++++ src/Tools/padder/meshjob/impl/CMakeLists.txt | 26 +++++++- .../padder/meshjob/impl/MeshJobManager_i.cxx | 10 ++- .../padder/meshjob/impl/MeshJobManager_i.hxx | 3 +- .../padder/meshjob/impl/SMeshPadderHelper.cxx | 62 +++++++++++++++++++ .../padder/meshjob/impl/SMeshPadderHelper.h | 25 ++++++++ .../padder/meshjob/impl/SMeshPadderHelper.i | 34 ++++++++++ src/Tools/padder/spadderpy/__init__.py | 2 +- 9 files changed, 186 insertions(+), 5 deletions(-) create mode 100644 src/SalomeSessionless/MeshJobManager_SalomeSessionless.py create mode 100644 src/Tools/padder/meshjob/impl/SMeshPadderHelper.cxx create mode 100644 src/Tools/padder/meshjob/impl/SMeshPadderHelper.h create mode 100644 src/Tools/padder/meshjob/impl/SMeshPadderHelper.i diff --git a/src/SalomeSessionless/CMakeLists.txt b/src/SalomeSessionless/CMakeLists.txt index b21eaa20e..dc1c5dc95 100644 --- a/src/SalomeSessionless/CMakeLists.txt +++ b/src/SalomeSessionless/CMakeLists.txt @@ -19,6 +19,7 @@ SET(_bin_SCRIPTS SMESH_SalomeSessionless.py + MeshJobManager_SalomeSessionless.py ) SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_PYTHON} DEF_PERMS) diff --git a/src/SalomeSessionless/MeshJobManager_SalomeSessionless.py b/src/SalomeSessionless/MeshJobManager_SalomeSessionless.py new file mode 100644 index 000000000..50f5d1fab --- /dev/null +++ b/src/SalomeSessionless/MeshJobManager_SalomeSessionless.py @@ -0,0 +1,28 @@ +# -*- coding: iso-8859-1 -*- +# 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 +# + +def buildInstance(orb): + import SMeshPadderHelper + padder_ior = SMeshPadderHelper.BuildPadderMeshJobManagerInstance() + import MESHJOB + import CORBA + orb=CORBA.ORB_init(['']) + padderInst = orb.string_to_object(padder_ior) + return padderInst, orb diff --git a/src/Tools/padder/meshjob/impl/CMakeLists.txt b/src/Tools/padder/meshjob/impl/CMakeLists.txt index dedd03cb5..6e555a7a4 100644 --- a/src/Tools/padder/meshjob/impl/CMakeLists.txt +++ b/src/Tools/padder/meshjob/impl/CMakeLists.txt @@ -17,9 +17,11 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +include(${SWIG_USE_FILE}) + # --- options --- -# additional include directories INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR} ${KERNEL_INCLUDE_DIRS} ${GEOM_INCLUDE_DIRS} ${OpenCASCADE_INCLUDE_DIR} @@ -86,6 +88,28 @@ SET(SPADDERPluginTesterEngine_SOURCES SPADDERPluginTester_i.cxx ) +# - swiggy pop + +SET(SMeshPadderHelper_HEADERS SMeshPadderHelper.h SMeshPadderHelper.i) +SET(SMeshPadderHelper_SOURCES SMeshPadderHelper.cxx ${SMeshPadderHelper_HEADERS}) +SET_SOURCE_FILES_PROPERTIES(SMeshPadderHelper.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(SMeshPadderHelper.i PROPERTIES SWIG_FLAGS "-py3") +SET_SOURCE_FILES_PROPERTIES(SMeshPadderHelper_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H") +SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/SMeshPadderHelper.py ) +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(SMeshPadderHelper python ${SMeshPadderHelper_SOURCES}) +ELSE() + SWIG_ADD_LIBRARY(SMeshPadderHelper LANGUAGE python SOURCES ${SMeshPadderHelper_SOURCES}) +ENDIF() +SWIG_LINK_LIBRARIES(SMeshPadderHelper ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} MeshJobManagerEngine ) +SWIG_CHECK_GENERATION(SMeshPadderHelper) +IF(WIN32) + SET_TARGET_PROPERTIES(_SMeshPadderHelper PROPERTIES DEBUG_OUTPUT_NAME _SMeshPadderHelper_d) +ENDIF(WIN32) +install(TARGETS _SMeshPadderHelper DESTINATION ${SALOME_INSTALL_LIBS}) +install(FILES ${SMeshPadderHelper_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) +SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}" ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_SMeshPadderHelper_REAL_NAME}") + # --- rules --- ADD_LIBRARY(MeshJobManagerEngine ${MeshJobManagerEngine_SOURCES}) diff --git a/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx b/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx index a8b0295a8..10bae23e7 100644 --- a/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx +++ b/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx @@ -83,6 +83,11 @@ static bool fexists(const char *filename) return false; } +Engines::EngineComponent_var RetrievePadderMeshJobManagerInstance() +{ + +} + // // ==================================================================== // Constructor/Destructor @@ -92,8 +97,9 @@ MeshJobManager_i::MeshJobManager_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, bool regist) + : Engines_Component_i(orb, poa, contId, instanceName, interfaceName, checkNS, regist) { LOG("Activating MESHJOB::MeshJobManager object"); _thisObj = this ; diff --git a/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx b/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx index e731371ff..9c9968f10 100644 --- a/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx +++ b/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx @@ -43,6 +43,7 @@ #define MESHJOBMANAGERENGINE_EXPORT #endif +Engines::EngineComponent_var RetrievePadderMeshJobManagerInstance(); class MESHJOBMANAGERENGINE_EXPORT MeshJobManager_i: public virtual POA_MESHJOB::MeshJobManager, public Engines_Component_i @@ -50,7 +51,7 @@ class MESHJOBMANAGERENGINE_EXPORT MeshJobManager_i: public virtual POA_MESHJOB:: public: MeshJobManager_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, - const char *instanceName, const char *interfaceName); + const char *instanceName, const char *interfaceName, bool checkNS = true, bool regist = true); ~MeshJobManager_i(); bool configure (const char *configId, diff --git a/src/Tools/padder/meshjob/impl/SMeshPadderHelper.cxx b/src/Tools/padder/meshjob/impl/SMeshPadderHelper.cxx new file mode 100644 index 000000000..cc51e5ad2 --- /dev/null +++ b/src/Tools/padder/meshjob/impl/SMeshPadderHelper.cxx @@ -0,0 +1,62 @@ +// 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 "SMeshPadderHelper.h" + +#include "MeshJobManager_i.hxx" +#include "SALOME_Container_i.hxx" +#include "SALOME_KernelServices.hxx" + +#include "SALOME_Fake_NamingService.hxx" + +static Engines::EngineComponent_var _unique_compo; + +Engines::EngineComponent_var BuildPadderMeshJobManagerInstance() +{ + 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); + auto *cont(KERNEL::getContainerSA()); + PortableServer::ObjectId *conId(cont->getCORBAId()); + // + pman->activate(); + // + MeshJobManager_i *servant = new MeshJobManager_i(orb, poa, conId, "MeshJobManager_inst_3", "MeshJobManager", false, false); + PortableServer::ObjectId *zeId = servant->getId(); + CORBA::Object_var zeRef = poa->id_to_reference(*zeId); + _unique_compo = Engines::EngineComponent::_narrow(zeRef); + } + return _unique_compo; +} + +std::string BuildPadderMeshJobManagerInstanceInternal() +{ + Engines::EngineComponent_var zeRef = BuildPadderMeshJobManagerInstance(); + CORBA::String_var ior = KERNEL::getORB()->object_to_string(zeRef); + return std::string(ior.in()); +} diff --git a/src/Tools/padder/meshjob/impl/SMeshPadderHelper.h b/src/Tools/padder/meshjob/impl/SMeshPadderHelper.h new file mode 100644 index 000000000..afd7594e7 --- /dev/null +++ b/src/Tools/padder/meshjob/impl/SMeshPadderHelper.h @@ -0,0 +1,25 @@ +// 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 + +std::string BuildPadderMeshJobManagerInstanceInternal(); + diff --git a/src/Tools/padder/meshjob/impl/SMeshPadderHelper.i b/src/Tools/padder/meshjob/impl/SMeshPadderHelper.i new file mode 100644 index 000000000..db619fceb --- /dev/null +++ b/src/Tools/padder/meshjob/impl/SMeshPadderHelper.i @@ -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 SMeshPadderHelper + +%include "std_string.i" + +%{ +#include "SMeshPadderHelper.h" +%} + +%inline +{ + std::string BuildPadderMeshJobManagerInstance() + { + return BuildPadderMeshJobManagerInstanceInternal(); + } +} diff --git a/src/Tools/padder/spadderpy/__init__.py b/src/Tools/padder/spadderpy/__init__.py index 8a1128e9b..13ec28d17 100644 --- a/src/Tools/padder/spadderpy/__init__.py +++ b/src/Tools/padder/spadderpy/__init__.py @@ -94,7 +94,7 @@ def getSpadderCatalogFilename(): def loadSpadderCatalog(): import salome salome.salome_init() - obj = salome.naming_service.Resolve('Kernel/ModulCatalog') + obj = salome.naming_service.Resolve('/Kernel/ModulCatalog') import SALOME_ModuleCatalog catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) if not catalog: -- 2.30.2