Salome HOME
Issue #2812: Fix for point creation if pre-selection exists
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI.i
index 5b09cc980fab7b581f1dc1a2198e3b87829d075f..1876d8ee2023f0fcbb07e8632e3ea849ec7463ae 100644 (file)
@@ -32,7 +32,7 @@
   #include "ModelHighAPI_swig.h"
 
   // fix for SWIG v2.0.4
-  #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
+  #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
 %}
 
 %include "doxyhelp.i"
 
 // shared pointers
 %shared_ptr(ModelHighAPI_Interface)
+%shared_ptr(ModelHighAPI_Folder)
 
 // typemaps
 
 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
-  if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) {
+  if (PyFloat_Check($input) || PyLong_Check($input)) {
     temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
     $1 = &temp;
-  } else if (PyString_Check($input)) {
-    temp = ModelHighAPI_Double(PyString_AsString($input));
+  } else if (PyUnicode_Check($input)) {
+    temp = ModelHighAPI_Double(PyUnicode_AsUTF8($input));
     $1 = &temp;
   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
   } else {
   }
 }
 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
-  $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
+  $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
 }
 
 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
-  if (PyInt_Check($input)) {
-    temp = ModelHighAPI_Integer(static_cast<int>(PyInt_AsLong($input)));
+  if (PyLong_Check($input)) {
+    temp = ModelHighAPI_Integer(static_cast<int>(PyLong_AsLong($input)));
     $1 = &temp;
-  } else if (PyString_Check($input)) {
-    temp = ModelHighAPI_Integer(PyString_AsString($input));
+  } else if (PyUnicode_Check($input)) {
+    temp = ModelHighAPI_Integer(PyUnicode_AsUTF8($input));
     $1 = &temp;
   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
   } else {
@@ -91,7 +92,7 @@
   }
 }
 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
-  $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
+  $1 = ((PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
 }
 
 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
   std::shared_ptr<ModelAPI_Object> * temp_object;
   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
+  ModelHighAPI_Selection* temp_selection;
   int newmem = 0;
   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
     if (temp_attribute) {
     } else {
       $1 = 0;
     }
+  } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+    if (temp_selection) {
+      $1 = 1;
+    } else {
+      $1 = 0;
+    }
   } else {
     $1 = 0;
   }
   }
 }
 
+%typemap(in) const std::list<double> & (std::list<double> temp) {
+  double * temp_attribute;
+  int newmem = 0;
+  if (PyTuple_Check($input)) {
+    for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
+      PyObject * item = PySequence_GetItem($input, i);
+      if (PyNumber_Check(item)) {
+        temp.push_back((double)PyFloat_AsDouble(item));
+      } else {
+        PyErr_SetString(PyExc_TypeError, "argument must double value.");
+        return NULL;
+      }
+      Py_DECREF(item);
+    }
+    $1 = &temp;
+  } else {
+    PyErr_SetString(PyExc_ValueError, "argument must be a tuple of double values.");
+    return NULL;
+  }
+}
+
+%typecheck(SWIG_TYPECHECK_POINTER) std::list<double>, const std::list<double>& {
+  double * temp_object;
+  std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
+  int newmem = 0;
+  if (PyTuple_Check($input)) {
+    for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
+      PyObject * item = PySequence_GetItem($input, i);
+      if (PyNumber_Check(item)) {
+        $1 = 1;
+      } else {
+        $1 = 0;
+        break;
+      }
+      Py_DECREF(item);
+    }
+  } else {
+    $1 = 0;
+  }
+}
+
 // all supported interfaces
 %include "ModelHighAPI_Double.h"
 %include "ModelHighAPI_Dumper.h"
 %include "ModelHighAPI_Integer.h"
 %include "ModelHighAPI_Interface.h"
+%include "ModelHighAPI_Folder.h"
 %include "ModelHighAPI_RefAttr.h"
 %include "ModelHighAPI_Reference.h"
 %include "ModelHighAPI_Selection.h"