From 45f1540bdb731cf2042584c45075ae9ce6ef0600 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 20 Dec 2021 18:04:44 +0100 Subject: [PATCH] WIP --- src/SalomeSessionless/CMakeLists.txt | 1 + .../MeshJobManager_SalomeSessionless.py | 28 +++++++++ src/Tools/padder/meshjob/impl/CMakeLists.txt | 26 +++++++- .../padder/meshjob/impl/MeshJobManager_i.cxx | 5 ++ .../padder/meshjob/impl/MeshJobManager_i.hxx | 1 + .../padder/meshjob/impl/SMeshPadderHelper.cxx | 62 +++++++++++++++++++ .../padder/meshjob/impl/SMeshPadderHelper.h | 25 ++++++++ .../padder/meshjob/impl/SMeshPadderHelper.i | 34 ++++++++++ 8 files changed, 181 insertions(+), 1 deletion(-) 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..acc8e4484 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 diff --git a/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx b/src/Tools/padder/meshjob/impl/MeshJobManager_i.hxx index e731371ff..fd14e12b4 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 diff --git a/src/Tools/padder/meshjob/impl/SMeshPadderHelper.cxx b/src/Tools/padder/meshjob/impl/SMeshPadderHelper.cxx new file mode 100644 index 000000000..342c61816 --- /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, "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; +} + +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(); + } +} -- 2.39.2