mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-28 02:10:36 +05:00
Reactivate Python
This commit is contained in:
parent
f6c0b1924d
commit
96bad7002c
@ -107,16 +107,22 @@ MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_GEOM_USE_OPENCV SALOME_GEOM_USE_VTK)
|
|||||||
##
|
##
|
||||||
|
|
||||||
# Various
|
# Various
|
||||||
# FIND_PACKAGE(SalomePythonInterp REQUIRED)
|
FIND_PACKAGE(SalomePythonInterp REQUIRED)
|
||||||
# FIND_PACKAGE(SalomePythonLibs REQUIRED)
|
FIND_PACKAGE(SalomePythonLibs REQUIRED)
|
||||||
|
|
||||||
|
IF (NOT DEFINED EMSCRIPTEN)
|
||||||
|
FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
|
||||||
|
FIND_PACKAGE(SalomeSWIG REQUIRED)
|
||||||
|
ELSE()
|
||||||
|
LIST(TRANSFORM OMNIORB_LIBRARIES REPLACE "\.so$" "\.a")
|
||||||
|
FIND_PACKAGE(SalomePythonWasm REQUIRED)
|
||||||
|
SET(PYTHON_INCLUDE_DIRS ${PYTHONWASM_INCLUDE_DIR})
|
||||||
|
SET(PYTHON_LIBRARIES ${PYTHONWASM_LIB})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
FIND_PACKAGE(SalomePThread REQUIRED)
|
FIND_PACKAGE(SalomePThread REQUIRED)
|
||||||
# FIND_PACKAGE(SalomeSWIG REQUIRED)
|
|
||||||
FIND_PACKAGE(SalomeBoost REQUIRED)
|
FIND_PACKAGE(SalomeBoost REQUIRED)
|
||||||
FIND_PACKAGE(SalomeOmniORB REQUIRED)
|
FIND_PACKAGE(SalomeOmniORB REQUIRED)
|
||||||
IF(DEFINED EMSCRIPTEN)
|
|
||||||
LIST(TRANSFORM OMNIORB_LIBRARIES REPLACE "\.so$" "\.a")
|
|
||||||
ENDIF()
|
|
||||||
# FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
|
|
||||||
FIND_PACKAGE(SalomeLibXml2 REQUIRED)
|
FIND_PACKAGE(SalomeLibXml2 REQUIRED)
|
||||||
FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
|
FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
# --- options ---
|
# --- options ---
|
||||||
|
|
||||||
# additional include directories
|
# additional include directories
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${OpenCASCADE_INCLUDE_DIR}
|
${OpenCASCADE_INCLUDE_DIR}
|
||||||
${PTHREAD_INCLUDE_DIR}
|
${PTHREAD_INCLUDE_DIR}
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
#include <pymath.h>
|
#include <pymath.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #include <Python.h>
|
#include <Python.h>
|
||||||
// #include <structmember.h>
|
#include <structmember.h>
|
||||||
|
|
||||||
#ifdef HAVE_FINITE
|
#ifdef HAVE_FINITE
|
||||||
#undef HAVE_FINITE
|
#undef HAVE_FINITE
|
||||||
@ -78,108 +78,108 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// typedef struct {
|
typedef struct {
|
||||||
// PyObject_HEAD
|
PyObject_HEAD
|
||||||
// int softspace;
|
int softspace;
|
||||||
// std::string *out;
|
std::string *out;
|
||||||
// } PyStdOut;
|
} PyStdOut;
|
||||||
|
|
||||||
// static void
|
static void
|
||||||
// PyStdOut_dealloc(PyStdOut *self)
|
PyStdOut_dealloc(PyStdOut *self)
|
||||||
// {
|
{
|
||||||
// PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// static PyObject*
|
static PyObject*
|
||||||
// PyStdOut_write(PyStdOut* self, PyObject* args)
|
PyStdOut_write(PyStdOut* self, PyObject* args)
|
||||||
// {
|
{
|
||||||
// char *c;
|
char *c;
|
||||||
// if (!PyArg_ParseTuple(args, "s", &c))
|
if (!PyArg_ParseTuple(args, "s", &c))
|
||||||
// return NULL;
|
return NULL;
|
||||||
|
|
||||||
// *(self->out) = *(self->out) + c;
|
*(self->out) = *(self->out) + c;
|
||||||
|
|
||||||
// Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
// return Py_None;
|
return Py_None;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// static PyMethodDef PyStdOut_methods[] = {
|
static PyMethodDef PyStdOut_methods[] = {
|
||||||
// {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
|
{"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
|
||||||
// PyDoc_STR("write(string) -> None")},
|
PyDoc_STR("write(string) -> None")},
|
||||||
// {0, 0, 0, 0} /* sentinel */
|
{0, 0, 0, 0} /* sentinel */
|
||||||
// };
|
};
|
||||||
|
|
||||||
// static PyMemberDef PyStdOut_memberlist[] = {
|
static PyMemberDef PyStdOut_memberlist[] = {
|
||||||
// {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
|
{(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
|
||||||
// (char*)"flag indicating that a space needs to be printed; used by print"},
|
(char*)"flag indicating that a space needs to be printed; used by print"},
|
||||||
// {0, 0, 0, 0, 0} /* sentinel */
|
{0, 0, 0, 0, 0} /* sentinel */
|
||||||
// };
|
};
|
||||||
|
|
||||||
// static PyTypeObject PyStdOut_Type = {
|
static PyTypeObject PyStdOut_Type = {
|
||||||
// /* The ob_type field must be initialized in the module init function
|
/* The ob_type field must be initialized in the module init function
|
||||||
// * to be portable to Windows without using C++. */
|
* to be portable to Windows without using C++. */
|
||||||
// PyVarObject_HEAD_INIT(NULL, 0)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
// /* 0, */ /*ob_size*/
|
/* 0, */ /*ob_size*/
|
||||||
// "PyOut", /*tp_name*/
|
"PyOut", /*tp_name*/
|
||||||
// sizeof(PyStdOut), /*tp_basicsize*/
|
sizeof(PyStdOut), /*tp_basicsize*/
|
||||||
// 0, /*tp_itemsize*/
|
0, /*tp_itemsize*/
|
||||||
// /* methods */
|
/* methods */
|
||||||
// (destructor)PyStdOut_dealloc, /*tp_dealloc*/
|
(destructor)PyStdOut_dealloc, /*tp_dealloc*/
|
||||||
// 0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
// 0, /*tp_getattr*/
|
0, /*tp_getattr*/
|
||||||
// 0, /*tp_setattr*/
|
0, /*tp_setattr*/
|
||||||
// 0, /*tp_compare*/
|
0, /*tp_compare*/
|
||||||
// 0, /*tp_repr*/
|
0, /*tp_repr*/
|
||||||
// 0, /*tp_as_number*/
|
0, /*tp_as_number*/
|
||||||
// 0, /*tp_as_sequence*/
|
0, /*tp_as_sequence*/
|
||||||
// 0, /*tp_as_mapping*/
|
0, /*tp_as_mapping*/
|
||||||
// 0, /*tp_hash*/
|
0, /*tp_hash*/
|
||||||
// 0, /*tp_call*/
|
0, /*tp_call*/
|
||||||
// 0, /*tp_str*/
|
0, /*tp_str*/
|
||||||
// PyObject_GenericGetAttr, /*tp_getattro*/
|
PyObject_GenericGetAttr, /*tp_getattro*/
|
||||||
// /* softspace is writable: we must supply tp_setattro */
|
/* softspace is writable: we must supply tp_setattro */
|
||||||
// PyObject_GenericSetAttr, /* tp_setattro */
|
PyObject_GenericSetAttr, /* tp_setattro */
|
||||||
// 0, /*tp_as_buffer*/
|
0, /*tp_as_buffer*/
|
||||||
// Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
||||||
// 0, /*tp_doc*/
|
0, /*tp_doc*/
|
||||||
// 0, /*tp_traverse*/
|
0, /*tp_traverse*/
|
||||||
// 0, /*tp_clear*/
|
0, /*tp_clear*/
|
||||||
// 0, /*tp_richcompare*/
|
0, /*tp_richcompare*/
|
||||||
// 0, /*tp_weaklistoffset*/
|
0, /*tp_weaklistoffset*/
|
||||||
// 0, /*tp_iter*/
|
0, /*tp_iter*/
|
||||||
// 0, /*tp_iternext*/
|
0, /*tp_iternext*/
|
||||||
// PyStdOut_methods, /*tp_methods*/
|
PyStdOut_methods, /*tp_methods*/
|
||||||
// PyStdOut_memberlist, /*tp_members*/
|
PyStdOut_memberlist, /*tp_members*/
|
||||||
// 0, /*tp_getset*/
|
0, /*tp_getset*/
|
||||||
// 0, /*tp_base*/
|
0, /*tp_base*/
|
||||||
// 0, /*tp_dict*/
|
0, /*tp_dict*/
|
||||||
// 0, /*tp_descr_get*/
|
0, /*tp_descr_get*/
|
||||||
// 0, /*tp_descr_set*/
|
0, /*tp_descr_set*/
|
||||||
// 0, /*tp_dictoffset*/
|
0, /*tp_dictoffset*/
|
||||||
// 0, /*tp_init*/
|
0, /*tp_init*/
|
||||||
// 0, /*tp_alloc*/
|
0, /*tp_alloc*/
|
||||||
// 0, /*tp_new*/
|
0, /*tp_new*/
|
||||||
// 0, /*tp_free*/
|
0, /*tp_free*/
|
||||||
// 0, /*tp_is_gc*/
|
0, /*tp_is_gc*/
|
||||||
// 0, /*tp_bases*/
|
0, /*tp_bases*/
|
||||||
// 0, /*tp_mro*/
|
0, /*tp_mro*/
|
||||||
// 0, /*tp_cache*/
|
0, /*tp_cache*/
|
||||||
// 0, /*tp_subclasses*/
|
0, /*tp_subclasses*/
|
||||||
// 0, /*tp_weaklist*/
|
0, /*tp_weaklist*/
|
||||||
// 0, /*tp_del*/
|
0, /*tp_del*/
|
||||||
// 0, /*tp_version_tag*/
|
0, /*tp_version_tag*/
|
||||||
// 0, /*tp_finalize*/
|
0, /*tp_finalize*/
|
||||||
// };
|
};
|
||||||
|
|
||||||
// PyObject* newPyStdOut( std::string& out )
|
PyObject* newPyStdOut( std::string& out )
|
||||||
// {
|
{
|
||||||
// PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
|
PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
|
||||||
// if (self) {
|
if (self) {
|
||||||
// self->softspace = 0;
|
self->softspace = 0;
|
||||||
// self->out=&out;
|
self->out=&out;
|
||||||
// }
|
}
|
||||||
// return (PyObject*)self;
|
return (PyObject*)self;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////END PYTHON///////////////////////////
|
////////////////////////END PYTHON///////////////////////////
|
||||||
@ -978,83 +978,83 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the Python interpreter */
|
/* Initialize the Python interpreter */
|
||||||
// if (! Py_IsInitialized()) {
|
if (! Py_IsInitialized()) {
|
||||||
// SetErrorCode("Python interpreter is not initialized !!! ");
|
SetErrorCode("Python interpreter is not initialized !!! ");
|
||||||
// return NULL;
|
return NULL;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// PyGILState_STATE gstate;
|
PyGILState_STATE gstate;
|
||||||
// gstate = PyGILState_Ensure();
|
gstate = PyGILState_Ensure();
|
||||||
|
|
||||||
// PyObject* main_mod = PyImport_AddModule("__main__");
|
PyObject* main_mod = PyImport_AddModule("__main__");
|
||||||
// PyObject* main_dict = PyModule_GetDict(main_mod);
|
PyObject* main_dict = PyModule_GetDict(main_mod);
|
||||||
|
|
||||||
// PyObject* obj = PyRun_String(aPyScript.ToCString(), Py_file_input, main_dict, NULL);
|
PyObject* obj = PyRun_String(aPyScript.ToCString(), Py_file_input, main_dict, NULL);
|
||||||
|
|
||||||
// if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
// SetErrorCode("Error during executing of python script !!!");
|
SetErrorCode("Error during executing of python script !!!");
|
||||||
// PyErr_Print();
|
PyErr_Print();
|
||||||
// PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
// return NULL;
|
return NULL;
|
||||||
// } else {
|
} else {
|
||||||
// Py_DECREF(obj);
|
Py_DECREF(obj);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// PyObject * func = NULL;
|
PyObject * func = NULL;
|
||||||
// func = PyObject_GetAttrString(main_mod, "coordCalculator");
|
func = PyObject_GetAttrString(main_mod, "coordCalculator");
|
||||||
|
|
||||||
// if (func == NULL){
|
if (func == NULL){
|
||||||
// SetErrorCode("Can't get function from python module !!!");
|
SetErrorCode("Can't get function from python module !!!");
|
||||||
// PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
// return NULL;
|
return NULL;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// PyObject* coords;
|
PyObject* coords;
|
||||||
// if (theNewMethod)
|
if (theNewMethod)
|
||||||
// coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
|
coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
|
||||||
// else
|
else
|
||||||
// coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
|
coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
|
||||||
|
|
||||||
// if (coords == NULL){
|
if (coords == NULL){
|
||||||
// fflush(stderr);
|
fflush(stderr);
|
||||||
// std::string err_description="";
|
std::string err_description="";
|
||||||
// PyObject* new_stderr = newPyStdOut(err_description);
|
PyObject* new_stderr = newPyStdOut(err_description);
|
||||||
// PyObject* old_stderr = PySys_GetObject((char*)"stderr");
|
PyObject* old_stderr = PySys_GetObject((char*)"stderr");
|
||||||
// Py_INCREF(old_stderr);
|
Py_INCREF(old_stderr);
|
||||||
// PySys_SetObject((char*)"stderr", new_stderr);
|
PySys_SetObject((char*)"stderr", new_stderr);
|
||||||
// PyErr_Print();
|
PyErr_Print();
|
||||||
// PySys_SetObject((char*)"stderr", old_stderr);
|
PySys_SetObject((char*)"stderr", old_stderr);
|
||||||
// Py_DECREF(new_stderr);
|
Py_DECREF(new_stderr);
|
||||||
// MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
|
MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
|
||||||
// SetErrorCode("Can't evaluate the expressions, please check them !!!");
|
SetErrorCode("Can't evaluate the expressions, please check them !!!");
|
||||||
// PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
// return NULL;
|
return NULL;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// int lsize = PyList_Size( coords );
|
int lsize = PyList_Size( coords );
|
||||||
|
|
||||||
// if(lsize <= 0) {
|
if(lsize <= 0) {
|
||||||
// SetErrorCode("Empty list of the points, please check input parameters !!!");
|
SetErrorCode("Empty list of the points, please check input parameters !!!");
|
||||||
// return NULL;
|
return NULL;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, lsize * 3);
|
Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, lsize * 3);
|
||||||
|
|
||||||
// int k=1;
|
int k=1;
|
||||||
// for ( Py_ssize_t i = 0; i < lsize; ++i ) {
|
for ( Py_ssize_t i = 0; i < lsize; ++i ) {
|
||||||
// PyObject* coord = PyList_GetItem( coords, i );
|
PyObject* coord = PyList_GetItem( coords, i );
|
||||||
// if (coord != NULL) {
|
if (coord != NULL) {
|
||||||
// for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
|
for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
|
||||||
// PyObject* item = PyList_GetItem(coord, j);
|
PyObject* item = PyList_GetItem(coord, j);
|
||||||
// aCoordsArray->SetValue(k, PyFloat_AsDouble(item));
|
aCoordsArray->SetValue(k, PyFloat_AsDouble(item));
|
||||||
// k++;
|
k++;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Py_DECREF(coords);
|
Py_DECREF(coords);
|
||||||
|
|
||||||
// PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
|
|
||||||
Handle(GEOM_Object) aCurve;
|
Handle(GEOM_Object) aCurve;
|
||||||
Handle(GEOM_Function) aFunction;
|
Handle(GEOM_Function) aFunction;
|
||||||
|
Loading…
Reference in New Issue
Block a user