Salome HOME
Issue #2148: Moving an arc displays a circle
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI.i
1 /* ModelHighAPI.i */
2 %module(directors="1") ModelHighAPI
3 %feature("director:except") {
4     if ($error != NULL) {
5       PyErr_Print();
6       std::cerr << std::endl;
7       throw Swig::DirectorMethodException();
8     }
9 }
10
11 %{
12   #include "ModelHighAPI_swig.h"
13
14   // fix for SWIG v2.0.4
15   #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
16 %}
17
18 %include "doxyhelp.i"
19
20 // import other modules
21 %import "GeomAPI.i"
22 %import "ModelAPI.i"
23 %import "GeomDataAPI.i"
24
25 // to avoid error on this
26 #define MODELHIGHAPI_EXPORT
27
28 // standard definitions
29 %include "typemaps.i"
30 %include "std_list.i"
31 %include "std_pair.i"
32 %include "std_string.i"
33 %include "std_shared_ptr.i"
34
35 // directors
36 %feature("director") ModelHighAPI_Dumper;
37
38 // shared pointers
39 %shared_ptr(ModelHighAPI_Interface)
40
41 // typemaps
42
43 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
44   if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) {
45     temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
46     $1 = &temp;
47   } else if (PyString_Check($input)) {
48     temp = ModelHighAPI_Double(PyString_AsString($input));
49     $1 = &temp;
50   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
51   } else {
52     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
53     return NULL;
54   }
55 }
56 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
57   $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
58 }
59
60 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
61   if (PyInt_Check($input)) {
62     temp = ModelHighAPI_Integer(static_cast<int>(PyInt_AsLong($input)));
63     $1 = &temp;
64   } else if (PyString_Check($input)) {
65     temp = ModelHighAPI_Integer(PyString_AsString($input));
66     $1 = &temp;
67   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
68   } else {
69     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
70     return NULL;
71   }
72 }
73 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
74   $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
75 }
76
77 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
78   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
79   std::shared_ptr<ModelAPI_Object> * temp_object;
80   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
81   int newmem = 0;
82   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
83     if (!temp_attribute) {
84       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
85       return NULL;
86     }
87     temp = ModelHighAPI_RefAttr(*temp_attribute);
88     if (newmem & SWIG_CAST_NEW_MEMORY) {
89       delete temp_attribute;
90     }
91     $1 = &temp;
92   } else
93   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
94     if (!temp_object) {
95       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
96       return NULL;
97     }
98     temp = ModelHighAPI_RefAttr(*temp_object);
99     if (newmem & SWIG_CAST_NEW_MEMORY) {
100       delete temp_object;
101     }
102     $1 = &temp;
103   } else
104   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
105     if (!temp_interface) {
106       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
107       return NULL;
108     }
109     temp = ModelHighAPI_RefAttr(*temp_interface);
110     if (newmem & SWIG_CAST_NEW_MEMORY) {
111       delete temp_interface;
112     }
113     $1 = &temp;
114   } else
115   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
116   } else {
117     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
118     return NULL;
119   }
120 }
121
122 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
123   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
124   std::shared_ptr<ModelAPI_Object> * temp_object;
125   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
126   int newmem = 0;
127   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
128     if (temp_attribute) {
129       $1 = 1;
130     } else {
131       $1 = 0;
132     }
133   } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
134     if (temp_object) {
135       $1 = 1;
136     } else {
137       $1 = 0;
138     }
139   } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
140     if (temp_interface) {
141       $1 = 1;
142     } else {
143       $1 = 0;
144     }
145   } else {
146     $1 = 0;
147   }
148 }
149
150 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
151   std::shared_ptr<ModelAPI_Object> * temp_object;
152   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
153   int newmem = 0;
154   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
155     if (!temp_object) {
156       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
157       return NULL;
158     }
159     temp = ModelHighAPI_Reference(*temp_object);
160     if (newmem & SWIG_CAST_NEW_MEMORY) {
161       delete temp_object;
162     }
163     $1 = &temp;
164   } else
165   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
166     if (!temp_interface) {
167       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
168       return NULL;
169     }
170     temp = ModelHighAPI_Reference(*temp_interface);
171     if (newmem & SWIG_CAST_NEW_MEMORY) {
172       delete temp_interface;
173     }
174     $1 = &temp;
175   } else
176   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
177   } else {
178     PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
179     return NULL;
180   }
181 }
182
183 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
184   std::shared_ptr<ModelAPI_Object> * temp_object;
185   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
186   int newmem = 0;
187   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
188     if (temp_object) {
189       $1 = 1;
190     } else {
191       $1 = 0;
192     }
193   } else
194   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
195     if (temp_interface) {
196       $1 = 1;
197     } else {
198       $1 = 0;
199     }
200   } else {
201     $1 = 0;
202   }
203 }
204
205 %typemap(out) const ModelHighAPI_Selection & {
206   $1_basetype * ptr = new $1_basetype(*$1);
207   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
208 }
209
210 %typemap(out) const ModelHighAPI_Reference & {
211   $1_basetype * ptr = new $1_basetype(*$1);
212   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
213 }
214
215 // std::list -> []
216 %template(SelectionList) std::list<ModelHighAPI_Selection>;
217 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
218 %template(RefList) std::list<ModelHighAPI_Reference>;
219
220 // std::pair -> []
221 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
222
223
224 // fix compilarion error: ‘res*’ was not declared in this scope
225 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
226 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
227
228 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
229   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
230   int newmem = 0;
231   if (PySequence_Check($input)) {
232     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
233       PyObject * item = PySequence_GetItem($input, i);
234       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
235         if (!temp_attribute) {
236           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
237           return NULL;
238         }
239         temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
240         if (newmem & SWIG_CAST_NEW_MEMORY) {
241           delete temp_attribute;
242         }
243       }
244       Py_DECREF(item);
245     }
246     $1 = &temp;
247   } else {
248     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
249     return NULL;
250   }
251 }
252
253 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
254   std::shared_ptr<ModelAPI_Object> * temp_object;
255   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
256   int newmem = 0;
257   if (PySequence_Check($input)) {
258     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
259       PyObject * item = PySequence_GetItem($input, i);
260       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
261         if (!temp_object) {
262           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
263           return NULL;
264         }
265         temp.push_back(*temp_object);
266         if (newmem & SWIG_CAST_NEW_MEMORY) {
267           delete temp_object;
268         }
269       } else
270       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
271         if (!temp_interface) {
272           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
273           return NULL;
274         }
275         temp.push_back((*temp_interface)->defaultResult());
276         if (newmem & SWIG_CAST_NEW_MEMORY) {
277           delete temp_interface;
278         }
279       }
280       Py_DECREF(item);
281     }
282     $1 = &temp;
283   } else {
284     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
285     return NULL;
286   }
287 }
288
289 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
290   std::shared_ptr<ModelAPI_Object> * temp_object;
291   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
292   int newmem = 0;
293   if (PySequence_Check($input)) {
294     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
295       PyObject * item = PySequence_GetItem($input, i);
296       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
297         if (temp_object) {
298           $1 = 1;
299         } else {
300           $1 = 0;
301           break;
302         }
303       } else
304       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
305         if (temp_interface) {
306           $1 = 1;
307         } else {
308           $1 = 0;
309           break;
310         }
311       }
312       Py_DECREF(item);
313     }
314   } else {
315     $1 = 0;
316   }
317 }
318
319 // all supported interfaces
320 %include "ModelHighAPI_Double.h"
321 %include "ModelHighAPI_Dumper.h"
322 %include "ModelHighAPI_Integer.h"
323 %include "ModelHighAPI_Interface.h"
324 %include "ModelHighAPI_RefAttr.h"
325 %include "ModelHighAPI_Reference.h"
326 %include "ModelHighAPI_Selection.h"
327 %include "ModelHighAPI_Services.h"
328 %include "ModelHighAPI_Macro.h"
329 %include "ModelHighAPI_Tools.h"