Minimal compilation fixes: Remove Python, Qt and boost async refs

This commit is contained in:
Louis Gombert 2024-08-12 08:33:53 +00:00
parent 1ead829f59
commit f3402508da
10 changed files with 142 additions and 135 deletions

View File

@ -339,7 +339,7 @@ SET(_${PROJECT_NAME}_exposed_targets
MeshDriverSTL MeshDriverUNV MEDWrapper
SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
SMESHUtils StdMeshers StdMeshersEngine
SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER
SalomeIDLSMESH SalomeIDLSPADDER
)
IF(SALOME_BUILD_GUI)

View File

@ -155,6 +155,5 @@ SET(SMESH_StdMeshers StdMeshers)
SET(SMESH_StdMeshersEngine StdMeshersEngine)
SET(SMESH_StdMeshersGUI StdMeshersGUI)
SET(SMESH_MeshJobManagerEngine MeshJobManagerEngine)
SET(SMESH_SPADDERPluginTesterEngine SPADDERPluginTesterEngine)
SET(SMESH_SalomeIDLSMESH SalomeIDLSMESH)
SET(SMESH_SalomeIDLSPADDER SalomeIDLSPADDER)

View File

@ -51,8 +51,8 @@
#include "memoire.h"
#include <functional>
#include <QString>
#include <QProcess>
// #include <QString>
// #include <QProcess>
#ifdef WIN32
#include <windows.h>
@ -302,6 +302,7 @@ const std::function<void(SMESH_subMesh*,
void SMESH_Gen::send_mesh(SMESH_Mesh& aMesh, std::string file_name)
{
#ifndef WIN32
#ifndef __EMSCRIPTEN__
SMESH_ParallelMesh& aParMesh = dynamic_cast<SMESH_ParallelMesh&>(aMesh);
// Calling run_mesher
// Path to mesher script
@ -353,6 +354,7 @@ void SMESH_Gen::send_mesh(SMESH_Mesh& aMesh, std::string file_name)
throw SALOME_Exception(msg);
}
#endif
#endif
}
//=============================================================================
@ -444,9 +446,9 @@ bool SMESH_Gen::parallelComputeSubMeshes(
shapeSM, aShapeOnly, allowedSubShapes,
aShapesId);
}else{
boost::asio::post(*(aParMesh.GetPool()), std::bind(compute_function, smToCompute, computeEvent,
shapeSM, aShapeOnly, allowedSubShapes,
aShapesId));
// boost::asio::post(*(aParMesh.GetPool()), std::bind(compute_function, smToCompute, computeEvent,
// shapeSM, aShapeOnly, allowedSubShapes,
// aShapesId));
}
}

View File

@ -52,7 +52,7 @@
#ifndef WIN32
#include <boost/filesystem.hpp>
#endif
#include <boost/thread.hpp>
// #include <boost/thread.hpp>
#ifdef WIN32
#pragma warning(disable:4251) // Warning DLL Interface ...

View File

@ -29,13 +29,14 @@
#include "SMESH_Mesh.hxx"
#ifndef WIN32
#if (!WIN32 && !__EMSCRIPTEN__)
#include <boost/asio.hpp>
#include <boost/thread/mutex.hpp>
#endif
#include "SMESH_Gen.hxx"
#include "SMESH_subMesh.hxx"
#ifdef WIN32
#if (WIN32 || __EMSCRIPTEN__)
#include <thread>
#include <boost/filesystem.hpp>
#endif
@ -52,7 +53,7 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
~SMESH_ParallelMesh();
// Locking mechanism
#ifndef WIN32
#if (!WIN32 && !__EMSCRIPTEN__)
void Lock() override {_my_lock.lock();};
void Unlock() override {_my_lock.unlock();};
// We need to recreate the pool afterthe join
@ -60,7 +61,7 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
#endif
// Thread Pool
#ifndef WIN32
#if (!WIN32 && !__EMSCRIPTEN__)
void InitPoolThreads() {_pool = new boost::asio::thread_pool(GetPoolNbThreads());};
boost::asio::thread_pool* GetPool() {return _pool;};
void DeletePoolThreads() {delete _pool;};
@ -127,7 +128,7 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
SMESH_ParallelMesh(const SMESH_ParallelMesh& aMesh):SMESH_Mesh(aMesh) {};
private:
// Mutex for multhitreading write in SMESH_Mesh
#ifndef WIN32
#if (!WIN32 && !__EMSCRIPTEN__)
boost::mutex _my_lock;
// thread pool for computation
boost::asio::thread_pool * _pool = nullptr;

View File

@ -2899,122 +2899,122 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateDualMesh(SMESH::SMESH_IDSource_ptr mesh
const char* meshName,
CORBA::Boolean adapt_to_shape)
{
Unexpect aCatch(SALOME_SalomeException);
// Unexpect aCatch(SALOME_SalomeException);
TPythonDump* pyDump = new TPythonDump(this); // prevent dump from CreateMesh()
std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
// TPythonDump* pyDump = new TPythonDump(this); // prevent dump from CreateMesh()
// std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
// 1. Get source mesh
// // 1. Get source mesh
if ( CORBA::is_nil( mesh ))
THROW_SALOME_CORBA_EXCEPTION( "bad IDSource", SALOME::BAD_PARAM );
// if ( CORBA::is_nil( mesh ))
// THROW_SALOME_CORBA_EXCEPTION( "bad IDSource", SALOME::BAD_PARAM );
SMESH::SMESH_Mesh_var srcMesh = mesh->GetMesh();
SMESH_Mesh_i* srcMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( srcMesh );
if ( !srcMesh_i )
THROW_SALOME_CORBA_EXCEPTION( "bad mesh of IDSource", SALOME::BAD_PARAM );
// SMESH::SMESH_Mesh_var srcMesh = mesh->GetMesh();
// SMESH_Mesh_i* srcMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( srcMesh );
// if ( !srcMesh_i )
// THROW_SALOME_CORBA_EXCEPTION( "bad mesh of IDSource", SALOME::BAD_PARAM );
CORBA::String_var mesh_var=GetORB()->object_to_string(mesh);
std::string mesh_ior = mesh_var.in();
// CORBA::String_var mesh_var=GetORB()->object_to_string(mesh);
// std::string mesh_ior = mesh_var.in();
//temporary folder for the generation of the med file
fs::path tmp_folder = fs::temp_directory_path() / fs::unique_path(fs::path("dual_mesh-%%%%"));
fs::create_directories(tmp_folder);
fs::path dual_mesh_file = tmp_folder / fs::path("tmp_dual_mesh.med");
std::string mesh_name(meshName);
MESSAGE("Working in folder" + tmp_folder.string());
// //temporary folder for the generation of the med file
// fs::path tmp_folder = fs::temp_directory_path() / fs::unique_path(fs::path("dual_mesh-%%%%"));
// fs::create_directories(tmp_folder);
// fs::path dual_mesh_file = tmp_folder / fs::path("tmp_dual_mesh.med");
// std::string mesh_name(meshName);
// MESSAGE("Working in folder" + tmp_folder.string());
// Running Python script
assert(Py_IsInitialized());
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
// // Running Python script
// assert(Py_IsInitialized());
// PyGILState_STATE gstate;
// gstate = PyGILState_Ensure();
std::string ats;
if(adapt_to_shape)
ats = "True";
else
ats = "False";
// std::string ats;
// if(adapt_to_shape)
// ats = "True";
// else
// ats = "False";
std::string cmd="import salome.smesh.smesh_tools as smt\n";
cmd +="smt.smesh_create_dual_mesh(\"" + mesh_ior + "\", r\"" +
dual_mesh_file.string() + "\", mesh_name=\"" + mesh_name + "\", adapt_to_shape=" + ats + ")";
MESSAGE(cmd);
// std::string cmd="import salome.smesh.smesh_tools as smt\n";
// cmd +="smt.smesh_create_dual_mesh(\"" + mesh_ior + "\", r\"" +
// dual_mesh_file.string() + "\", mesh_name=\"" + mesh_name + "\", adapt_to_shape=" + ats + ")";
// MESSAGE(cmd);
PyObject *py_main = PyImport_AddModule("__main__");
PyObject *py_dict = PyModule_GetDict(py_main);
PyObject *local_dict = PyDict_New();
// PyObject *py_main = PyImport_AddModule("__main__");
// PyObject *py_dict = PyModule_GetDict(py_main);
// PyObject *local_dict = PyDict_New();
PyRun_String(cmd.c_str(), Py_file_input, py_dict, local_dict);
// PyRun_String(cmd.c_str(), Py_file_input, py_dict, local_dict);
if (PyErr_Occurred()) {
// Restrieving python error
MESSAGE("Catching error");
PyObject *errtype, *errvalue, *traceback;
PyErr_Fetch(&errtype, &errvalue, &traceback);
if(errvalue != NULL) {
MESSAGE("Error has a value");
PyObject *s = PyObject_Str(errvalue);
Py_ssize_t size;
std::string msg = PyUnicode_AsUTF8AndSize(s, &size);
msg = "Issue with the execution of create_dual_mesh:\n"+msg;
MESSAGE("throwing exception");
// We need to deactivate the GIL before throwing the exception
PyGILState_Release(gstate);
THROW_SALOME_CORBA_EXCEPTION(msg.c_str(), SALOME::INTERNAL_ERROR );
Py_DECREF(s);
}
Py_XDECREF(errvalue);
Py_XDECREF(errtype);
Py_XDECREF(traceback);
}
// if (PyErr_Occurred()) {
// // Restrieving python error
// MESSAGE("Catching error");
// PyObject *errtype, *errvalue, *traceback;
// PyErr_Fetch(&errtype, &errvalue, &traceback);
// if(errvalue != NULL) {
// MESSAGE("Error has a value");
// PyObject *s = PyObject_Str(errvalue);
// Py_ssize_t size;
// std::string msg = PyUnicode_AsUTF8AndSize(s, &size);
// msg = "Issue with the execution of create_dual_mesh:\n"+msg;
// MESSAGE("throwing exception");
// // We need to deactivate the GIL before throwing the exception
// PyGILState_Release(gstate);
// THROW_SALOME_CORBA_EXCEPTION(msg.c_str(), SALOME::INTERNAL_ERROR );
// Py_DECREF(s);
// }
// Py_XDECREF(errvalue);
// Py_XDECREF(errtype);
// Py_XDECREF(traceback);
// }
PyGILState_Release(gstate);
// PyGILState_Release(gstate);
MESSAGE("Mesh created in " + dual_mesh_file.string());
// MESSAGE("Mesh created in " + dual_mesh_file.string());
// Import created MED
SMESH::SMESH_Mesh_var newMesh = CreateMesh(GEOM::GEOM_Object::_nil());
SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
if ( !newMesh_i )
THROW_SALOME_CORBA_EXCEPTION( "can't create a mesh", SALOME::INTERNAL_ERROR );
SALOMEDS::SObject_wrap meshSO = ObjectToSObject( newMesh );
if ( !meshSO->_is_nil() )
{
SetName( meshSO, meshName, meshName );
SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
}
int ret = newMesh_i->ImportMEDFile(dual_mesh_file.string().c_str(), meshName);
if(ret)
THROW_SALOME_CORBA_EXCEPTION( "Issue when importing mesh", SALOME::INTERNAL_ERROR );
// // Import created MED
// SMESH::SMESH_Mesh_var newMesh = CreateMesh(GEOM::GEOM_Object::_nil());
// SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
// if ( !newMesh_i )
// THROW_SALOME_CORBA_EXCEPTION( "can't create a mesh", SALOME::INTERNAL_ERROR );
// SALOMEDS::SObject_wrap meshSO = ObjectToSObject( newMesh );
// if ( !meshSO->_is_nil() )
// {
// SetName( meshSO, meshName, meshName );
// SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
// }
// int ret = newMesh_i->ImportMEDFile(dual_mesh_file.string().c_str(), meshName);
// if(ret)
// THROW_SALOME_CORBA_EXCEPTION( "Issue when importing mesh", SALOME::INTERNAL_ERROR );
/*
SMESH_Mesh& newMesh2 = newMesh_i->GetImpl();
// /*
// SMESH_Mesh& newMesh2 = newMesh_i->GetImpl();
MESSAGE("Loading file: " << dual_mesh_file.string() << " with mesh " << meshName);
int ret = newMesh2.MEDToMesh(dual_mesh_file.c_str(), meshName);
*/
// MESSAGE("Loading file: " << dual_mesh_file.string() << " with mesh " << meshName);
// int ret = newMesh2.MEDToMesh(dual_mesh_file.c_str(), meshName);
// */
newMesh_i->GetImpl().GetMeshDS()->Modified();
// newMesh_i->GetImpl().GetMeshDS()->Modified();
*pyDump << newMesh << " = " << this
<< ".CreateDualMesh("
<< mesh << ", "
<< "'" << mesh_name << "', "
<< ats << ") ";
// *pyDump << newMesh << " = " << this
// << ".CreateDualMesh("
// << mesh << ", "
// << "'" << mesh_name << "', "
// << ats << ") ";
pyDumpDeleter.reset(); // allow dump in GetGroups()
// pyDumpDeleter.reset(); // allow dump in GetGroups()
if ( srcMesh_i->GetImpl().GetGroupIds().size() > 0 ) // dump created groups
MESSAGE("Dump of groups");
SMESH::ListOfGroups_var groups = newMesh->GetGroups();
// if ( srcMesh_i->GetImpl().GetGroupIds().size() > 0 ) // dump created groups
// MESSAGE("Dump of groups");
// SMESH::ListOfGroups_var groups = newMesh->GetGroups();
#ifndef _DEBUG_
fs::remove_all(tmp_folder);
#endif
// #ifndef _DEBUG_
// fs::remove_all(tmp_folder);
// #endif
return newMesh._retn();
// return newMesh._retn();
}
//================================================================================

View File

@ -35,7 +35,7 @@
#include "SALOMEconfig.h"
// Have to be included before std headers
#include <Python.h>
// #include <Python.h>
#include <structmember.h>
#include <vector>
@ -1848,23 +1848,23 @@ CORBA::Long HOMARD_Gen_i::ComputeCAO()
// C. Lancement des projections
MESSAGE (". Lancement des projections");
assert(Py_IsInitialized());
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
PyRun_SimpleString("from FrontTrack import FrontTrack");
// FrontTrack().track( fic_med_brut, fic_med_new, l_fr, xao_file )
std::string pyCommand ("FrontTrack().track( \"");
pyCommand += theInputMedFile + "\", \"" + theOutputMedFile + "\", [";
for (int i = 0; i < icpt; i++) {
if (i > 0) pyCommand += ", ";
pyCommand += "\"";
pyCommand += theInputNodeFiles[i];
pyCommand += "\"";
}
pyCommand += "], \"" + theXaoFileName + "\", False )";
MESSAGE (". Lancement des projections: pyCommand = " << pyCommand);
PyRun_SimpleString(pyCommand.c_str());
PyGILState_Release(gstate);
// assert(Py_IsInitialized());
// PyGILState_STATE gstate;
// gstate = PyGILState_Ensure();
// PyRun_SimpleString("from FrontTrack import FrontTrack");
// // FrontTrack().track( fic_med_brut, fic_med_new, l_fr, xao_file )
// std::string pyCommand ("FrontTrack().track( \"");
// pyCommand += theInputMedFile + "\", \"" + theOutputMedFile + "\", [";
// for (int i = 0; i < icpt; i++) {
// if (i > 0) pyCommand += ", ";
// pyCommand += "\"";
// pyCommand += theInputNodeFiles[i];
// pyCommand += "\"";
// }
// pyCommand += "], \"" + theXaoFileName + "\", False )";
// MESSAGE (". Lancement des projections: pyCommand = " << pyCommand);
// PyRun_SimpleString(pyCommand.c_str());
// PyGILState_Release(gstate);
// D. Transfert des coordonnées modifiées dans le fichier historique de HOMARD
// On lance une exécution spéciale de HOMARD en attendant

View File

@ -51,6 +51,7 @@ SET(StdMeshers_SCRIPTS
)
# additional preprocessor / compiler flags
if (NOT DEFINED EMSCRIPTEN)
ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
SET(SMeshHelper_HEADERS SMeshHelper.h SMeshHelper.i)
SET(SMeshHelper_SOURCES SMeshHelper.cxx ${SMeshHelper_HEADERS})
@ -72,6 +73,7 @@ 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}")
SALOME_INSTALL_SCRIPTS("${smesh_exe_SCRIPTS}" ${SALOME_INSTALL_BINS})
endif()
# --- rules ---
SALOME_INSTALL_SCRIPTS("${smesh_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/smesh DEF_PERMS)

View File

@ -94,6 +94,8 @@ SET(_swig_SCRIPTS
)
# --- rules ---
if (NOT DEFINED EMSCRIPTEN)
IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")
SWIG_ADD_MODULE(libSMESH_Swig python ${SMESH_Swig_SOURCES})
ELSE()
@ -106,6 +108,7 @@ SWIG_CHECK_GENERATION(libSMESH_Swig)
IF(WIN32)
SET_TARGET_PROPERTIES(_libSMESH_Swig PROPERTIES DEBUG_OUTPUT_NAME _libSMESH_Swig_d)
ENDIF(WIN32)
endif()
INSTALL(TARGETS _libSMESH_Swig DESTINATION ${SALOME_INSTALL_LIBS})

View File

@ -83,13 +83,13 @@ SET(MeshJobManagerEngine_SOURCES
MeshJobManager_i.cxx
)
SET(SPADDERPluginTesterEngine_SOURCES
SPADDERPluginTester_i.hxx
SPADDERPluginTester_i.cxx
)
# SET(SPADDERPluginTesterEngine_SOURCES
# SPADDERPluginTester_i.hxx
# SPADDERPluginTester_i.cxx
# )
# - swiggy pop
if (NOT DEFINED EMSCRIPTEN)
SET(SMeshPadderHelper_HEADERS SMeshPadderHelper.h SMeshPadderHelper.i)
SET(SMeshPadderHelper_SOURCES SMeshPadderHelper.cxx ${SMeshPadderHelper_HEADERS})
SET_SOURCE_FILES_PROPERTIES(SMeshPadderHelper.i PROPERTIES CPLUSPLUS ON)
@ -109,16 +109,16 @@ 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}")
endif()
# --- rules ---
ADD_LIBRARY(MeshJobManagerEngine ${MeshJobManagerEngine_SOURCES})
TARGET_LINK_LIBRARIES(MeshJobManagerEngine ${MeshJobManagerEngine_LIBRARIES} )
INSTALL(TARGETS MeshJobManagerEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
# ADD_LIBRARY(MeshJobManagerEngine ${MeshJobManagerEngine_SOURCES})
# TARGET_LINK_LIBRARIES(MeshJobManagerEngine ${MeshJobManagerEngine_LIBRARIES} )
# INSTALL(TARGETS MeshJobManagerEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
ADD_LIBRARY(SPADDERPluginTesterEngine ${SPADDERPluginTesterEngine_SOURCES})
TARGET_LINK_LIBRARIES(SPADDERPluginTesterEngine ${SPADDERPluginTesterEngine_LIBRARIES} )
INSTALL(TARGETS SPADDERPluginTesterEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
# ADD_LIBRARY(SPADDERPluginTesterEngine ${SPADDERPluginTesterEngine_SOURCES})
# TARGET_LINK_LIBRARIES(SPADDERPluginTesterEngine ${SPADDERPluginTesterEngine_LIBRARIES} )
# INSTALL(TARGETS SPADDERPluginTesterEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
INSTALL(FILES ${MeshJobManagerEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
# INSTALL(FILES ${MeshJobManagerEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})