mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 09:50:34 +05:00
Reactivate Python
This commit is contained in:
parent
ec25237027
commit
310f0d5f89
@ -115,12 +115,20 @@ MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_SMESH_USE_CGNS SALOME_SMESH_USE_TBB SAL
|
|||||||
# Python
|
# Python
|
||||||
FIND_PACKAGE(SalomePythonInterp REQUIRED)
|
FIND_PACKAGE(SalomePythonInterp REQUIRED)
|
||||||
FIND_PACKAGE(SalomePythonLibs REQUIRED)
|
FIND_PACKAGE(SalomePythonLibs REQUIRED)
|
||||||
|
|
||||||
|
IF (DEFINED EMSCRIPTEN)
|
||||||
|
FIND_PACKAGE(SalomePythonWasm REQUIRED)
|
||||||
|
SET(PYTHON_INCLUDE_DIRS ${PYTHONWASM_INCLUDE_DIR})
|
||||||
|
SET(PYTHON_LIBRARIES ${PYTHONWASM_LIB})
|
||||||
|
ELSE()
|
||||||
|
FIND_PACKAGE(SalomeBoost REQUIRED)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# PThread
|
# PThread
|
||||||
FIND_PACKAGE(SalomePThread REQUIRED)
|
FIND_PACKAGE(SalomePThread REQUIRED)
|
||||||
# SWIG
|
# SWIG
|
||||||
FIND_PACKAGE(SalomeSWIG REQUIRED)
|
FIND_PACKAGE(SalomeSWIG REQUIRED)
|
||||||
# Boost
|
# Boost
|
||||||
# FIND_PACKAGE(SalomeBoost REQUIRED)
|
|
||||||
# CORBA
|
# CORBA
|
||||||
FIND_PACKAGE(SalomeOmniORB REQUIRED)
|
FIND_PACKAGE(SalomeOmniORB REQUIRED)
|
||||||
IF(DEFINED EMSCRIPTEN)
|
IF(DEFINED EMSCRIPTEN)
|
||||||
|
@ -28,6 +28,7 @@ INCLUDE_DIRECTORIES(
|
|||||||
${KERNEL_INCLUDE_DIRS}
|
${KERNEL_INCLUDE_DIRS}
|
||||||
${GUI_INCLUDE_DIRS}
|
${GUI_INCLUDE_DIRS}
|
||||||
${GEOM_INCLUDE_DIRS}
|
${GEOM_INCLUDE_DIRS}
|
||||||
|
${PYTHON_INCLUDE_DIRS}
|
||||||
${MEDCOUPLING_INCLUDE_DIRS}
|
${MEDCOUPLING_INCLUDE_DIRS}
|
||||||
${PROJECT_SOURCE_DIR}/src/Controls
|
${PROJECT_SOURCE_DIR}/src/Controls
|
||||||
${PROJECT_SOURCE_DIR}/src/SMDS
|
${PROJECT_SOURCE_DIR}/src/SMDS
|
||||||
@ -74,6 +75,7 @@ SET(_link_LIBRARIES
|
|||||||
${KERNEL_SalomeKernelHelpers}
|
${KERNEL_SalomeKernelHelpers}
|
||||||
${KERNEL_SalomeDS}
|
${KERNEL_SalomeDS}
|
||||||
${KERNEL_SalomeCatalog}
|
${KERNEL_SalomeCatalog}
|
||||||
|
# ${PYTHON_LIBRARIES}
|
||||||
${OpenCASCADE_ApplicationFramework_LIBRARIES}
|
${OpenCASCADE_ApplicationFramework_LIBRARIES}
|
||||||
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
|
${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
|
||||||
${GEOM_GEOMClient}
|
${GEOM_GEOMClient}
|
||||||
@ -127,7 +129,7 @@ SET(SMESHEngine_SOURCES
|
|||||||
SMESH_Gen_i_1.cxx
|
SMESH_Gen_i_1.cxx
|
||||||
SMESH_Gen_No_Session_i.cxx
|
SMESH_Gen_No_Session_i.cxx
|
||||||
SMESH_Gen_Session_i.cxx
|
SMESH_Gen_Session_i.cxx
|
||||||
# SMESH_PythonDump.cxx # EMscripten: duplicate symbol
|
# SMESH_PythonDump.cxx # Emscripten: duplicate symbol
|
||||||
SMESH_Mesh_i.cxx
|
SMESH_Mesh_i.cxx
|
||||||
SMESH_subMesh_i.cxx
|
SMESH_subMesh_i.cxx
|
||||||
SMESH_MeshEditor_i.cxx
|
SMESH_MeshEditor_i.cxx
|
||||||
|
@ -50,8 +50,8 @@
|
|||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
// Have to be included before std headers
|
// Have to be included before std headers
|
||||||
// #include <Python.h>
|
#include <Python.h>
|
||||||
// #include <structmember.h>
|
#include <structmember.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -2899,122 +2899,122 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateDualMesh(SMESH::SMESH_IDSource_ptr mesh
|
|||||||
const char* meshName,
|
const char* meshName,
|
||||||
CORBA::Boolean adapt_to_shape)
|
CORBA::Boolean adapt_to_shape)
|
||||||
{
|
{
|
||||||
// Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
|
|
||||||
// TPythonDump* pyDump = new TPythonDump(this); // prevent dump from CreateMesh()
|
TPythonDump* pyDump = new TPythonDump(this); // prevent dump from CreateMesh()
|
||||||
// std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
|
std::unique_ptr<TPythonDump> pyDumpDeleter( pyDump );
|
||||||
|
|
||||||
// // 1. Get source mesh
|
// 1. Get source mesh
|
||||||
|
|
||||||
// if ( CORBA::is_nil( mesh ))
|
if ( CORBA::is_nil( mesh ))
|
||||||
// THROW_SALOME_CORBA_EXCEPTION( "bad IDSource", SALOME::BAD_PARAM );
|
THROW_SALOME_CORBA_EXCEPTION( "bad IDSource", SALOME::BAD_PARAM );
|
||||||
|
|
||||||
// SMESH::SMESH_Mesh_var srcMesh = mesh->GetMesh();
|
SMESH::SMESH_Mesh_var srcMesh = mesh->GetMesh();
|
||||||
// SMESH_Mesh_i* srcMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( srcMesh );
|
SMESH_Mesh_i* srcMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( srcMesh );
|
||||||
// if ( !srcMesh_i )
|
if ( !srcMesh_i )
|
||||||
// THROW_SALOME_CORBA_EXCEPTION( "bad mesh of IDSource", SALOME::BAD_PARAM );
|
THROW_SALOME_CORBA_EXCEPTION( "bad mesh of IDSource", SALOME::BAD_PARAM );
|
||||||
|
|
||||||
// CORBA::String_var mesh_var=GetORB()->object_to_string(mesh);
|
CORBA::String_var mesh_var=GetORB()->object_to_string(mesh);
|
||||||
// std::string mesh_ior = mesh_var.in();
|
std::string mesh_ior = mesh_var.in();
|
||||||
|
|
||||||
// //temporary folder for the generation of the med file
|
//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::path tmp_folder = fs::temp_directory_path() / fs::unique_path(fs::path("dual_mesh-%%%%"));
|
||||||
// fs::create_directories(tmp_folder);
|
fs::create_directories(tmp_folder);
|
||||||
// fs::path dual_mesh_file = tmp_folder / fs::path("tmp_dual_mesh.med");
|
fs::path dual_mesh_file = tmp_folder / fs::path("tmp_dual_mesh.med");
|
||||||
// std::string mesh_name(meshName);
|
std::string mesh_name(meshName);
|
||||||
// MESSAGE("Working in folder" + tmp_folder.string());
|
MESSAGE("Working in folder" + tmp_folder.string());
|
||||||
|
|
||||||
// // Running Python script
|
// Running Python script
|
||||||
// assert(Py_IsInitialized());
|
assert(Py_IsInitialized());
|
||||||
// PyGILState_STATE gstate;
|
PyGILState_STATE gstate;
|
||||||
// gstate = PyGILState_Ensure();
|
gstate = PyGILState_Ensure();
|
||||||
|
|
||||||
|
|
||||||
// std::string ats;
|
std::string ats;
|
||||||
// if(adapt_to_shape)
|
if(adapt_to_shape)
|
||||||
// ats = "True";
|
ats = "True";
|
||||||
// else
|
else
|
||||||
// ats = "False";
|
ats = "False";
|
||||||
|
|
||||||
// std::string cmd="import salome.smesh.smesh_tools as smt\n";
|
std::string cmd="import salome.smesh.smesh_tools as smt\n";
|
||||||
// cmd +="smt.smesh_create_dual_mesh(\"" + mesh_ior + "\", r\"" +
|
cmd +="smt.smesh_create_dual_mesh(\"" + mesh_ior + "\", r\"" +
|
||||||
// dual_mesh_file.string() + "\", mesh_name=\"" + mesh_name + "\", adapt_to_shape=" + ats + ")";
|
dual_mesh_file.string() + "\", mesh_name=\"" + mesh_name + "\", adapt_to_shape=" + ats + ")";
|
||||||
// MESSAGE(cmd);
|
MESSAGE(cmd);
|
||||||
|
|
||||||
// PyObject *py_main = PyImport_AddModule("__main__");
|
PyObject *py_main = PyImport_AddModule("__main__");
|
||||||
// PyObject *py_dict = PyModule_GetDict(py_main);
|
PyObject *py_dict = PyModule_GetDict(py_main);
|
||||||
// PyObject *local_dict = PyDict_New();
|
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()) {
|
if (PyErr_Occurred()) {
|
||||||
// // Restrieving python error
|
// Restrieving python error
|
||||||
// MESSAGE("Catching error");
|
MESSAGE("Catching error");
|
||||||
// PyObject *errtype, *errvalue, *traceback;
|
PyObject *errtype, *errvalue, *traceback;
|
||||||
// PyErr_Fetch(&errtype, &errvalue, &traceback);
|
PyErr_Fetch(&errtype, &errvalue, &traceback);
|
||||||
// if(errvalue != NULL) {
|
if(errvalue != NULL) {
|
||||||
// MESSAGE("Error has a value");
|
MESSAGE("Error has a value");
|
||||||
// PyObject *s = PyObject_Str(errvalue);
|
PyObject *s = PyObject_Str(errvalue);
|
||||||
// Py_ssize_t size;
|
Py_ssize_t size;
|
||||||
// std::string msg = PyUnicode_AsUTF8AndSize(s, &size);
|
std::string msg = PyUnicode_AsUTF8AndSize(s, &size);
|
||||||
// msg = "Issue with the execution of create_dual_mesh:\n"+msg;
|
msg = "Issue with the execution of create_dual_mesh:\n"+msg;
|
||||||
// MESSAGE("throwing exception");
|
MESSAGE("throwing exception");
|
||||||
// // We need to deactivate the GIL before throwing the exception
|
// We need to deactivate the GIL before throwing the exception
|
||||||
// PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
// THROW_SALOME_CORBA_EXCEPTION(msg.c_str(), SALOME::INTERNAL_ERROR );
|
THROW_SALOME_CORBA_EXCEPTION(msg.c_str(), SALOME::INTERNAL_ERROR );
|
||||||
// Py_DECREF(s);
|
Py_DECREF(s);
|
||||||
// }
|
}
|
||||||
// Py_XDECREF(errvalue);
|
Py_XDECREF(errvalue);
|
||||||
// Py_XDECREF(errtype);
|
Py_XDECREF(errtype);
|
||||||
// Py_XDECREF(traceback);
|
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
|
// Import created MED
|
||||||
// SMESH::SMESH_Mesh_var newMesh = CreateMesh(GEOM::GEOM_Object::_nil());
|
SMESH::SMESH_Mesh_var newMesh = CreateMesh(GEOM::GEOM_Object::_nil());
|
||||||
// SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
|
SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
|
||||||
// if ( !newMesh_i )
|
if ( !newMesh_i )
|
||||||
// THROW_SALOME_CORBA_EXCEPTION( "can't create a mesh", SALOME::INTERNAL_ERROR );
|
THROW_SALOME_CORBA_EXCEPTION( "can't create a mesh", SALOME::INTERNAL_ERROR );
|
||||||
// SALOMEDS::SObject_wrap meshSO = ObjectToSObject( newMesh );
|
SALOMEDS::SObject_wrap meshSO = ObjectToSObject( newMesh );
|
||||||
// if ( !meshSO->_is_nil() )
|
if ( !meshSO->_is_nil() )
|
||||||
// {
|
{
|
||||||
// SetName( meshSO, meshName, meshName );
|
SetName( meshSO, meshName, meshName );
|
||||||
// SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
|
SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
|
||||||
// }
|
}
|
||||||
// int ret = newMesh_i->ImportMEDFile(dual_mesh_file.string().c_str(), meshName);
|
int ret = newMesh_i->ImportMEDFile(dual_mesh_file.string().c_str(), meshName);
|
||||||
// if(ret)
|
if(ret)
|
||||||
// THROW_SALOME_CORBA_EXCEPTION( "Issue when importing mesh", SALOME::INTERNAL_ERROR );
|
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);
|
MESSAGE("Loading file: " << dual_mesh_file.string() << " with mesh " << meshName);
|
||||||
// int ret = newMesh2.MEDToMesh(dual_mesh_file.c_str(), meshName);
|
int ret = newMesh2.MEDToMesh(dual_mesh_file.c_str(), meshName);
|
||||||
// */
|
*/
|
||||||
|
|
||||||
// newMesh_i->GetImpl().GetMeshDS()->Modified();
|
newMesh_i->GetImpl().GetMeshDS()->Modified();
|
||||||
|
|
||||||
// *pyDump << newMesh << " = " << this
|
*pyDump << newMesh << " = " << this
|
||||||
// << ".CreateDualMesh("
|
<< ".CreateDualMesh("
|
||||||
// << mesh << ", "
|
<< mesh << ", "
|
||||||
// << "'" << mesh_name << "', "
|
<< "'" << mesh_name << "', "
|
||||||
// << ats << ") ";
|
<< ats << ") ";
|
||||||
|
|
||||||
// pyDumpDeleter.reset(); // allow dump in GetGroups()
|
pyDumpDeleter.reset(); // allow dump in GetGroups()
|
||||||
|
|
||||||
// if ( srcMesh_i->GetImpl().GetGroupIds().size() > 0 ) // dump created groups
|
if ( srcMesh_i->GetImpl().GetGroupIds().size() > 0 ) // dump created groups
|
||||||
// MESSAGE("Dump of groups");
|
MESSAGE("Dump of groups");
|
||||||
// SMESH::ListOfGroups_var groups = newMesh->GetGroups();
|
SMESH::ListOfGroups_var groups = newMesh->GetGroups();
|
||||||
|
|
||||||
// #ifndef _DEBUG_
|
#ifndef _DEBUG_
|
||||||
// fs::remove_all(tmp_folder);
|
fs::remove_all(tmp_folder);
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
// return newMesh._retn();
|
return newMesh._retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user