X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI.i;h=4c5755f48e0de01ec5ddeec88ba9a77293a5af05;hb=9add0e52ceac12abd0edef911a1c143e2c9b5a6f;hp=1876d8ee2023f0fcbb07e8632e3ea849ec7463ae;hpb=7fc1263ea0d94986475f96e209061e9a199118be;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI.i b/src/ModelHighAPI/ModelHighAPI.i index 1876d8ee2..4c5755f48 100644 --- a/src/ModelHighAPI/ModelHighAPI.i +++ b/src/ModelHighAPI/ModelHighAPI.i @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* ModelHighAPI.i */ @@ -99,10 +98,22 @@ std::shared_ptr * temp_attribute; std::shared_ptr * temp_object; std::shared_ptr * temp_interface; + ModelHighAPI_Selection* temp_selection; int newmem = 0; + if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { + if (!temp_selection) { + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); + return NULL; + } + temp = ModelHighAPI_RefAttr(std::shared_ptr(temp_selection->resultSubShapePair().first)); + if (newmem & SWIG_CAST_NEW_MEMORY) { + delete temp_selection; + } + $1 = &temp; + } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { if (!temp_attribute) { - PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); return NULL; } temp = ModelHighAPI_RefAttr(*temp_attribute); @@ -113,7 +124,7 @@ } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { if (!temp_object) { - PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); return NULL; } temp = ModelHighAPI_RefAttr(*temp_object); @@ -124,7 +135,7 @@ } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { if (!temp_interface) { - PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); return NULL; } temp = ModelHighAPI_RefAttr(*temp_interface); @@ -135,7 +146,7 @@ } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { } else { - PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); return NULL; } } @@ -240,18 +251,29 @@ $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 ); } +%typemap(out) const ModelHighAPI_RefAttr & { + $1_basetype * ptr = new $1_basetype(*$1); + $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 ); +} + // std::list -> [] %template(SelectionList) std::list; +%template(SelectionListList) std::list >; %template(RefAttrList) std::list; %template(RefList) std::list; +%template(DoubleAPIList) std::list; +%template(IntegerAPIList) std::list; // std::pair -> [] %template(ResultSubShapePair) std::pair, std::shared_ptr >; +%template(StringsPair) std::pair; // fix compilarion error: 'res*' was not declared in this scope %typemap(freearg) const std::list & {} %typemap(freearg) const std::list > & {} +%typemap(freearg) const std::list & {} +%typemap(freearg) const std::list & {} %typemap(in) const std::list & (std::list temp) { std::shared_ptr * temp_attribute; @@ -344,8 +366,47 @@ } } + +%typemap(in) const std::list & (std::list temp) { + int newmem = 0; + if (PySequence_Check($input)) { + for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) { + PyObject * item = PySequence_GetItem($input, i); + if (PyLong_Check(item)) { + temp.push_back((int)PyLong_AsLong(item)); + } else { + PyErr_SetString(PyExc_TypeError, "argument must integet value."); + return NULL; + } + Py_DECREF(item); + } + $1 = &temp; + } else { + PyErr_SetString(PyExc_ValueError, "argument must be a tuple of integer values."); + return NULL; + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) std::list, const std::list& { + int newmem = 0; + if (PySequence_Check($input)) { + for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) { + PyObject * item = PySequence_GetItem($input, i); + if (PyLong_Check(item)) { + $1 = 1; + } else { + $1 = 0; + break; + } + Py_DECREF(item); + } + } else { + $1 = 0; + } +} + + %typemap(in) const std::list & (std::list temp) { - double * temp_attribute; int newmem = 0; if (PyTuple_Check($input)) { for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) { @@ -366,8 +427,6 @@ } %typecheck(SWIG_TYPECHECK_POINTER) std::list, const std::list& { - double * temp_object; - std::shared_ptr * temp_interface; int newmem = 0; if (PyTuple_Check($input)) { for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) { @@ -385,6 +444,83 @@ } } + +%typemap(in) const std::list & (std::list temp) { + ModelHighAPI_Double * temp_double; + if (PySequence_Check($input)) { + for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) { + PyObject * item = PySequence_GetItem($input, i); + if (PyFloat_Check(item) || PyLong_Check(item)) { + temp.push_back(ModelHighAPI_Double(PyFloat_AsDouble(item))); + } else if (PyUnicode_Check(item)) { + temp.push_back(ModelHighAPI_Double(PyUnicode_AsUTF8(item))); + } else if ((SWIG_ConvertPtr(item, (void **)&temp_double, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { + temp.push_back(*temp_double); + } else { + PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string."); + return NULL; + } + Py_DECREF(item); + } + $1 = &temp; + } else { + PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string."); + return NULL; + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) std::list, const std::list & { + if (PySequence_Check($input)) { + $1 = 1; + for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) { + PyObject * item = PySequence_GetItem($input, i); + $1 = ((PyFloat_Check(item) || PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0; + Py_DECREF(item); + } + } else { + $1 = 0; + } +} + + +%typemap(in) const std::list & (std::list temp) { + ModelHighAPI_Integer * temp_int; + if (PySequence_Check($input)) { + for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) { + PyObject * item = PySequence_GetItem($input, i); + if (PyLong_Check(item)) { + temp.push_back(ModelHighAPI_Integer(PyLong_AsLong(item))); + } else if (PyUnicode_Check(item)) { + temp.push_back(ModelHighAPI_Integer(PyUnicode_AsUTF8(item))); + } else if ((SWIG_ConvertPtr(item, (void **)&temp_int, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { + temp.push_back(*temp_int); + } else { + PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string."); + return NULL; + } + Py_DECREF(item); + } + $1 = &temp; + } else { + PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string."); + return NULL; + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) std::list, const std::list & { + if (PySequence_Check($input)) { + $1 = 1; + for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) { + PyObject * item = PySequence_GetItem($input, i); + $1 = ((PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0; + Py_DECREF(item); + } + } else { + $1 = 0; + } +} + + // all supported interfaces %include "ModelHighAPI_Double.h" %include "ModelHighAPI_Dumper.h"