mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-26 17:30:35 +05:00
Remove Python usage
This commit is contained in:
parent
ac65da58f1
commit
f6c0b1924d
@ -113,6 +113,9 @@ FIND_PACKAGE(SalomePThread REQUIRED)
|
||||
# FIND_PACKAGE(SalomeSWIG REQUIRED)
|
||||
FIND_PACKAGE(SalomeBoost 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(SalomeHDF5 REQUIRED COMPONENTS C)
|
||||
|
@ -62,7 +62,7 @@ SET(GEOMImpl_HEADERS
|
||||
GEOMImpl_IShapesOperations.hxx
|
||||
GEOMImpl_IBlocksOperations.hxx
|
||||
GEOMImpl_IBooleanOperations.hxx
|
||||
# GEOMImpl_ICurvesOperations.hxx # Uses Python
|
||||
GEOMImpl_ICurvesOperations.hxx
|
||||
GEOMImpl_ILocalOperations.hxx
|
||||
GEOMImpl_IInsertOperations.hxx
|
||||
GEOMImpl_IECallBack.hxx
|
||||
@ -198,7 +198,7 @@ SET(GEOMImpl_SOURCES
|
||||
GEOMImpl_IShapesOperations.cxx
|
||||
GEOMImpl_IBlocksOperations.cxx
|
||||
GEOMImpl_IBooleanOperations.cxx
|
||||
# GEOMImpl_ICurvesOperations.cxx # Uses Python
|
||||
GEOMImpl_ICurvesOperations.cxx
|
||||
GEOMImpl_ILocalOperations.cxx
|
||||
GEOMImpl_IInsertOperations.cxx
|
||||
GEOMImpl_IECallBack.cxx
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include <pymath.h>
|
||||
#endif
|
||||
|
||||
#include <Python.h>
|
||||
#include <structmember.h>
|
||||
// #include <Python.h>
|
||||
// #include <structmember.h>
|
||||
|
||||
#ifdef HAVE_FINITE
|
||||
#undef HAVE_FINITE
|
||||
@ -78,108 +78,108 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
int softspace;
|
||||
std::string *out;
|
||||
} PyStdOut;
|
||||
// typedef struct {
|
||||
// PyObject_HEAD
|
||||
// int softspace;
|
||||
// std::string *out;
|
||||
// } PyStdOut;
|
||||
|
||||
static void
|
||||
PyStdOut_dealloc(PyStdOut *self)
|
||||
{
|
||||
PyObject_Del(self);
|
||||
}
|
||||
// static void
|
||||
// PyStdOut_dealloc(PyStdOut *self)
|
||||
// {
|
||||
// PyObject_Del(self);
|
||||
// }
|
||||
|
||||
static PyObject*
|
||||
PyStdOut_write(PyStdOut* self, PyObject* args)
|
||||
{
|
||||
char *c;
|
||||
if (!PyArg_ParseTuple(args, "s", &c))
|
||||
return NULL;
|
||||
// static PyObject*
|
||||
// PyStdOut_write(PyStdOut* self, PyObject* args)
|
||||
// {
|
||||
// char *c;
|
||||
// if (!PyArg_ParseTuple(args, "s", &c))
|
||||
// return NULL;
|
||||
|
||||
*(self->out) = *(self->out) + c;
|
||||
// *(self->out) = *(self->out) + c;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
// Py_INCREF(Py_None);
|
||||
// return Py_None;
|
||||
// }
|
||||
|
||||
static PyMethodDef PyStdOut_methods[] = {
|
||||
{"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
|
||||
PyDoc_STR("write(string) -> None")},
|
||||
{0, 0, 0, 0} /* sentinel */
|
||||
};
|
||||
// static PyMethodDef PyStdOut_methods[] = {
|
||||
// {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
|
||||
// PyDoc_STR("write(string) -> None")},
|
||||
// {0, 0, 0, 0} /* sentinel */
|
||||
// };
|
||||
|
||||
static PyMemberDef PyStdOut_memberlist[] = {
|
||||
{(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
|
||||
(char*)"flag indicating that a space needs to be printed; used by print"},
|
||||
{0, 0, 0, 0, 0} /* sentinel */
|
||||
};
|
||||
// static PyMemberDef PyStdOut_memberlist[] = {
|
||||
// {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
|
||||
// (char*)"flag indicating that a space needs to be printed; used by print"},
|
||||
// {0, 0, 0, 0, 0} /* sentinel */
|
||||
// };
|
||||
|
||||
static PyTypeObject PyStdOut_Type = {
|
||||
/* The ob_type field must be initialized in the module init function
|
||||
* to be portable to Windows without using C++. */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/* 0, */ /*ob_size*/
|
||||
"PyOut", /*tp_name*/
|
||||
sizeof(PyStdOut), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor)PyStdOut_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash*/
|
||||
0, /*tp_call*/
|
||||
0, /*tp_str*/
|
||||
PyObject_GenericGetAttr, /*tp_getattro*/
|
||||
/* softspace is writable: we must supply tp_setattro */
|
||||
PyObject_GenericSetAttr, /* tp_setattro */
|
||||
0, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
||||
0, /*tp_doc*/
|
||||
0, /*tp_traverse*/
|
||||
0, /*tp_clear*/
|
||||
0, /*tp_richcompare*/
|
||||
0, /*tp_weaklistoffset*/
|
||||
0, /*tp_iter*/
|
||||
0, /*tp_iternext*/
|
||||
PyStdOut_methods, /*tp_methods*/
|
||||
PyStdOut_memberlist, /*tp_members*/
|
||||
0, /*tp_getset*/
|
||||
0, /*tp_base*/
|
||||
0, /*tp_dict*/
|
||||
0, /*tp_descr_get*/
|
||||
0, /*tp_descr_set*/
|
||||
0, /*tp_dictoffset*/
|
||||
0, /*tp_init*/
|
||||
0, /*tp_alloc*/
|
||||
0, /*tp_new*/
|
||||
0, /*tp_free*/
|
||||
0, /*tp_is_gc*/
|
||||
0, /*tp_bases*/
|
||||
0, /*tp_mro*/
|
||||
0, /*tp_cache*/
|
||||
0, /*tp_subclasses*/
|
||||
0, /*tp_weaklist*/
|
||||
0, /*tp_del*/
|
||||
0, /*tp_version_tag*/
|
||||
0, /*tp_finalize*/
|
||||
};
|
||||
// static PyTypeObject PyStdOut_Type = {
|
||||
// /* The ob_type field must be initialized in the module init function
|
||||
// * to be portable to Windows without using C++. */
|
||||
// PyVarObject_HEAD_INIT(NULL, 0)
|
||||
// /* 0, */ /*ob_size*/
|
||||
// "PyOut", /*tp_name*/
|
||||
// sizeof(PyStdOut), /*tp_basicsize*/
|
||||
// 0, /*tp_itemsize*/
|
||||
// /* methods */
|
||||
// (destructor)PyStdOut_dealloc, /*tp_dealloc*/
|
||||
// 0, /*tp_print*/
|
||||
// 0, /*tp_getattr*/
|
||||
// 0, /*tp_setattr*/
|
||||
// 0, /*tp_compare*/
|
||||
// 0, /*tp_repr*/
|
||||
// 0, /*tp_as_number*/
|
||||
// 0, /*tp_as_sequence*/
|
||||
// 0, /*tp_as_mapping*/
|
||||
// 0, /*tp_hash*/
|
||||
// 0, /*tp_call*/
|
||||
// 0, /*tp_str*/
|
||||
// PyObject_GenericGetAttr, /*tp_getattro*/
|
||||
// /* softspace is writable: we must supply tp_setattro */
|
||||
// PyObject_GenericSetAttr, /* tp_setattro */
|
||||
// 0, /*tp_as_buffer*/
|
||||
// Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
||||
// 0, /*tp_doc*/
|
||||
// 0, /*tp_traverse*/
|
||||
// 0, /*tp_clear*/
|
||||
// 0, /*tp_richcompare*/
|
||||
// 0, /*tp_weaklistoffset*/
|
||||
// 0, /*tp_iter*/
|
||||
// 0, /*tp_iternext*/
|
||||
// PyStdOut_methods, /*tp_methods*/
|
||||
// PyStdOut_memberlist, /*tp_members*/
|
||||
// 0, /*tp_getset*/
|
||||
// 0, /*tp_base*/
|
||||
// 0, /*tp_dict*/
|
||||
// 0, /*tp_descr_get*/
|
||||
// 0, /*tp_descr_set*/
|
||||
// 0, /*tp_dictoffset*/
|
||||
// 0, /*tp_init*/
|
||||
// 0, /*tp_alloc*/
|
||||
// 0, /*tp_new*/
|
||||
// 0, /*tp_free*/
|
||||
// 0, /*tp_is_gc*/
|
||||
// 0, /*tp_bases*/
|
||||
// 0, /*tp_mro*/
|
||||
// 0, /*tp_cache*/
|
||||
// 0, /*tp_subclasses*/
|
||||
// 0, /*tp_weaklist*/
|
||||
// 0, /*tp_del*/
|
||||
// 0, /*tp_version_tag*/
|
||||
// 0, /*tp_finalize*/
|
||||
// };
|
||||
|
||||
PyObject* newPyStdOut( std::string& out )
|
||||
{
|
||||
PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
|
||||
if (self) {
|
||||
self->softspace = 0;
|
||||
self->out=&out;
|
||||
}
|
||||
return (PyObject*)self;
|
||||
}
|
||||
// PyObject* newPyStdOut( std::string& out )
|
||||
// {
|
||||
// PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
|
||||
// if (self) {
|
||||
// self->softspace = 0;
|
||||
// self->out=&out;
|
||||
// }
|
||||
// return (PyObject*)self;
|
||||
// }
|
||||
}
|
||||
|
||||
////////////////////////END PYTHON///////////////////////////
|
||||
@ -978,83 +978,83 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
|
||||
}
|
||||
|
||||
/* Initialize the Python interpreter */
|
||||
if (! Py_IsInitialized()) {
|
||||
SetErrorCode("Python interpreter is not initialized !!! ");
|
||||
return NULL;
|
||||
}
|
||||
// if (! Py_IsInitialized()) {
|
||||
// SetErrorCode("Python interpreter is not initialized !!! ");
|
||||
// return NULL;
|
||||
// }
|
||||
|
||||
PyGILState_STATE gstate;
|
||||
gstate = PyGILState_Ensure();
|
||||
// PyGILState_STATE gstate;
|
||||
// gstate = PyGILState_Ensure();
|
||||
|
||||
PyObject* main_mod = PyImport_AddModule("__main__");
|
||||
PyObject* main_dict = PyModule_GetDict(main_mod);
|
||||
// PyObject* main_mod = PyImport_AddModule("__main__");
|
||||
// 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) {
|
||||
SetErrorCode("Error during executing of python script !!!");
|
||||
PyErr_Print();
|
||||
PyGILState_Release(gstate);
|
||||
return NULL;
|
||||
} else {
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
// if (obj == NULL) {
|
||||
// SetErrorCode("Error during executing of python script !!!");
|
||||
// PyErr_Print();
|
||||
// PyGILState_Release(gstate);
|
||||
// return NULL;
|
||||
// } else {
|
||||
// Py_DECREF(obj);
|
||||
// }
|
||||
|
||||
PyObject * func = NULL;
|
||||
func = PyObject_GetAttrString(main_mod, "coordCalculator");
|
||||
// PyObject * func = NULL;
|
||||
// func = PyObject_GetAttrString(main_mod, "coordCalculator");
|
||||
|
||||
if (func == NULL){
|
||||
SetErrorCode("Can't get function from python module !!!");
|
||||
PyGILState_Release(gstate);
|
||||
return NULL;
|
||||
}
|
||||
// if (func == NULL){
|
||||
// SetErrorCode("Can't get function from python module !!!");
|
||||
// PyGILState_Release(gstate);
|
||||
// return NULL;
|
||||
// }
|
||||
|
||||
PyObject* coords;
|
||||
if (theNewMethod)
|
||||
coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
|
||||
else
|
||||
coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
|
||||
// PyObject* coords;
|
||||
// if (theNewMethod)
|
||||
// coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
|
||||
// else
|
||||
// coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
|
||||
|
||||
if (coords == NULL){
|
||||
fflush(stderr);
|
||||
std::string err_description="";
|
||||
PyObject* new_stderr = newPyStdOut(err_description);
|
||||
PyObject* old_stderr = PySys_GetObject((char*)"stderr");
|
||||
Py_INCREF(old_stderr);
|
||||
PySys_SetObject((char*)"stderr", new_stderr);
|
||||
PyErr_Print();
|
||||
PySys_SetObject((char*)"stderr", old_stderr);
|
||||
Py_DECREF(new_stderr);
|
||||
MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
|
||||
SetErrorCode("Can't evaluate the expressions, please check them !!!");
|
||||
PyGILState_Release(gstate);
|
||||
return NULL;
|
||||
}
|
||||
// if (coords == NULL){
|
||||
// fflush(stderr);
|
||||
// std::string err_description="";
|
||||
// PyObject* new_stderr = newPyStdOut(err_description);
|
||||
// PyObject* old_stderr = PySys_GetObject((char*)"stderr");
|
||||
// Py_INCREF(old_stderr);
|
||||
// PySys_SetObject((char*)"stderr", new_stderr);
|
||||
// PyErr_Print();
|
||||
// PySys_SetObject((char*)"stderr", old_stderr);
|
||||
// Py_DECREF(new_stderr);
|
||||
// MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
|
||||
// SetErrorCode("Can't evaluate the expressions, please check them !!!");
|
||||
// PyGILState_Release(gstate);
|
||||
// return NULL;
|
||||
// }
|
||||
|
||||
int lsize = PyList_Size( coords );
|
||||
// int lsize = PyList_Size( coords );
|
||||
|
||||
if(lsize <= 0) {
|
||||
SetErrorCode("Empty list of the points, please check input parameters !!!");
|
||||
return NULL;
|
||||
}
|
||||
// if(lsize <= 0) {
|
||||
// SetErrorCode("Empty list of the points, please check input parameters !!!");
|
||||
// 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;
|
||||
for ( Py_ssize_t i = 0; i < lsize; ++i ) {
|
||||
PyObject* coord = PyList_GetItem( coords, i );
|
||||
if (coord != NULL) {
|
||||
for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
|
||||
PyObject* item = PyList_GetItem(coord, j);
|
||||
aCoordsArray->SetValue(k, PyFloat_AsDouble(item));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// int k=1;
|
||||
// for ( Py_ssize_t i = 0; i < lsize; ++i ) {
|
||||
// PyObject* coord = PyList_GetItem( coords, i );
|
||||
// if (coord != NULL) {
|
||||
// for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
|
||||
// PyObject* item = PyList_GetItem(coord, j);
|
||||
// aCoordsArray->SetValue(k, PyFloat_AsDouble(item));
|
||||
// k++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Py_DECREF(coords);
|
||||
// Py_DECREF(coords);
|
||||
|
||||
PyGILState_Release(gstate);
|
||||
// PyGILState_Release(gstate);
|
||||
|
||||
Handle(GEOM_Object) aCurve;
|
||||
Handle(GEOM_Function) aFunction;
|
||||
@ -1074,10 +1074,10 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
|
||||
|
||||
GEOMImpl_IPolyline aCI (aFunction);
|
||||
|
||||
aCI.SetLength(lsize);
|
||||
aCI.SetConstructorType(COORD_CONSTRUCTOR);
|
||||
aCI.SetIsClosed(false);
|
||||
aCI.SetCoordinates(aCoordsArray);
|
||||
// aCI.SetLength(lsize);
|
||||
// aCI.SetConstructorType(COORD_CONSTRUCTOR);
|
||||
// aCI.SetIsClosed(false);
|
||||
// aCI.SetCoordinates(aCoordsArray);
|
||||
aCurveType = "GEOM.Polyline";
|
||||
break;
|
||||
}
|
||||
@ -1096,7 +1096,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
|
||||
|
||||
aCI.SetConstructorType(COORD_CONSTRUCTOR);
|
||||
aCI.SetIsClosed(false);
|
||||
aCI.SetCoordinates(aCoordsArray);
|
||||
// aCI.SetCoordinates(aCoordsArray);
|
||||
aCurveType = "GEOM.Bezier";
|
||||
break;
|
||||
}
|
||||
@ -1115,7 +1115,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
|
||||
aCI.SetConstructorType(COORD_CONSTRUCTOR);
|
||||
aCI.SetIsClosed(false);
|
||||
aCI.SetDoReordering(false);
|
||||
aCI.SetCoordinates(aCoordsArray);
|
||||
// aCI.SetCoordinates(aCoordsArray);
|
||||
aCurveType = "GEOM.Interpolation";
|
||||
break;
|
||||
}
|
||||
|
@ -74,3 +74,4 @@ ADD_LIBRARY(GEOM_SupervEngine ${GEOM_SupervEngine_SOURCES})
|
||||
TARGET_LINK_LIBRARIES(GEOM_SupervEngine ${_link_LIBRARIES})
|
||||
INSTALL(TARGETS GEOM_SupervEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
|
||||
|
||||
INSTALL(FILES ${GEOM_SupervEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
|
||||
|
Loading…
Reference in New Issue
Block a user