]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI.i
Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI.i
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 /* ModelHighAPI.i */
22 %module(directors="1") ModelHighAPI
23 %feature("director:except") {
24     if ($error != NULL) {
25       PyErr_Print();
26       std::cerr << std::endl;
27       throw Swig::DirectorMethodException();
28     }
29 }
30
31 %{
32   #include "ModelHighAPI_swig.h"
33
34   // fix for SWIG v2.0.4
35   #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
36 %}
37
38 %include "doxyhelp.i"
39
40 // import other modules
41 %import "GeomAPI.i"
42 %import "ModelAPI.i"
43 %import "GeomDataAPI.i"
44
45 // to avoid error on this
46 #define MODELHIGHAPI_EXPORT
47
48 // standard definitions
49 %include "typemaps.i"
50 %include "std_list.i"
51 %include "std_pair.i"
52 %include "std_string.i"
53 %include "std_shared_ptr.i"
54
55 // directors
56 %feature("director") ModelHighAPI_Dumper;
57
58 // shared pointers
59 %shared_ptr(ModelHighAPI_Interface)
60
61 // typemaps
62
63 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
64   if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) {
65     temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
66     $1 = &temp;
67   } else if (PyString_Check($input)) {
68     temp = ModelHighAPI_Double(PyString_AsString($input));
69     $1 = &temp;
70   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
71   } else {
72     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
73     return NULL;
74   }
75 }
76 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
77   $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
78 }
79
80 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
81   if (PyInt_Check($input)) {
82     temp = ModelHighAPI_Integer(static_cast<int>(PyInt_AsLong($input)));
83     $1 = &temp;
84   } else if (PyString_Check($input)) {
85     temp = ModelHighAPI_Integer(PyString_AsString($input));
86     $1 = &temp;
87   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
88   } else {
89     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
90     return NULL;
91   }
92 }
93 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
94   $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
95 }
96
97 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
98   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
99   std::shared_ptr<ModelAPI_Object> * temp_object;
100   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
101   int newmem = 0;
102   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
103     if (!temp_attribute) {
104       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
105       return NULL;
106     }
107     temp = ModelHighAPI_RefAttr(*temp_attribute);
108     if (newmem & SWIG_CAST_NEW_MEMORY) {
109       delete temp_attribute;
110     }
111     $1 = &temp;
112   } else
113   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
114     if (!temp_object) {
115       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
116       return NULL;
117     }
118     temp = ModelHighAPI_RefAttr(*temp_object);
119     if (newmem & SWIG_CAST_NEW_MEMORY) {
120       delete temp_object;
121     }
122     $1 = &temp;
123   } else
124   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
125     if (!temp_interface) {
126       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
127       return NULL;
128     }
129     temp = ModelHighAPI_RefAttr(*temp_interface);
130     if (newmem & SWIG_CAST_NEW_MEMORY) {
131       delete temp_interface;
132     }
133     $1 = &temp;
134   } else
135   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
136   } else {
137     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
138     return NULL;
139   }
140 }
141
142 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
143   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
144   std::shared_ptr<ModelAPI_Object> * temp_object;
145   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
146   int newmem = 0;
147   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
148     if (temp_attribute) {
149       $1 = 1;
150     } else {
151       $1 = 0;
152     }
153   } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
154     if (temp_object) {
155       $1 = 1;
156     } else {
157       $1 = 0;
158     }
159   } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
160     if (temp_interface) {
161       $1 = 1;
162     } else {
163       $1 = 0;
164     }
165   } else {
166     $1 = 0;
167   }
168 }
169
170 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
171   std::shared_ptr<ModelAPI_Object> * temp_object;
172   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
173   int newmem = 0;
174   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
175     if (!temp_object) {
176       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
177       return NULL;
178     }
179     temp = ModelHighAPI_Reference(*temp_object);
180     if (newmem & SWIG_CAST_NEW_MEMORY) {
181       delete temp_object;
182     }
183     $1 = &temp;
184   } else
185   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
186     if (!temp_interface) {
187       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
188       return NULL;
189     }
190     temp = ModelHighAPI_Reference(*temp_interface);
191     if (newmem & SWIG_CAST_NEW_MEMORY) {
192       delete temp_interface;
193     }
194     $1 = &temp;
195   } else
196   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
197   } else {
198     PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
199     return NULL;
200   }
201 }
202
203 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
204   std::shared_ptr<ModelAPI_Object> * temp_object;
205   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
206   int newmem = 0;
207   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
208     if (temp_object) {
209       $1 = 1;
210     } else {
211       $1 = 0;
212     }
213   } else
214   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
215     if (temp_interface) {
216       $1 = 1;
217     } else {
218       $1 = 0;
219     }
220   } else {
221     $1 = 0;
222   }
223 }
224
225 %typemap(out) const ModelHighAPI_Selection & {
226   $1_basetype * ptr = new $1_basetype(*$1);
227   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
228 }
229
230 %typemap(out) const ModelHighAPI_Reference & {
231   $1_basetype * ptr = new $1_basetype(*$1);
232   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
233 }
234
235 // std::list -> []
236 %template(SelectionList) std::list<ModelHighAPI_Selection>;
237 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
238 %template(RefList) std::list<ModelHighAPI_Reference>;
239
240 // std::pair -> []
241 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
242
243
244 // fix compilarion error: 'res*' was not declared in this scope
245 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
246 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
247
248 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
249   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
250   int newmem = 0;
251   if (PySequence_Check($input)) {
252     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
253       PyObject * item = PySequence_GetItem($input, i);
254       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
255         if (!temp_attribute) {
256           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
257           return NULL;
258         }
259         temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
260         if (newmem & SWIG_CAST_NEW_MEMORY) {
261           delete temp_attribute;
262         }
263       }
264       Py_DECREF(item);
265     }
266     $1 = &temp;
267   } else {
268     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
269     return NULL;
270   }
271 }
272
273 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
274   std::shared_ptr<ModelAPI_Object> * temp_object;
275   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
276   int newmem = 0;
277   if (PySequence_Check($input)) {
278     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
279       PyObject * item = PySequence_GetItem($input, i);
280       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
281         if (!temp_object) {
282           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
283           return NULL;
284         }
285         temp.push_back(*temp_object);
286         if (newmem & SWIG_CAST_NEW_MEMORY) {
287           delete temp_object;
288         }
289       } else
290       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
291         if (!temp_interface) {
292           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
293           return NULL;
294         }
295         temp.push_back((*temp_interface)->defaultResult());
296         if (newmem & SWIG_CAST_NEW_MEMORY) {
297           delete temp_interface;
298         }
299       }
300       Py_DECREF(item);
301     }
302     $1 = &temp;
303   } else {
304     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
305     return NULL;
306   }
307 }
308
309 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
310   std::shared_ptr<ModelAPI_Object> * temp_object;
311   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
312   int newmem = 0;
313   if (PySequence_Check($input)) {
314     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
315       PyObject * item = PySequence_GetItem($input, i);
316       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
317         if (temp_object) {
318           $1 = 1;
319         } else {
320           $1 = 0;
321           break;
322         }
323       } else
324       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
325         if (temp_interface) {
326           $1 = 1;
327         } else {
328           $1 = 0;
329           break;
330         }
331       }
332       Py_DECREF(item);
333     }
334   } else {
335     $1 = 0;
336   }
337 }
338
339 // all supported interfaces
340 %include "ModelHighAPI_Double.h"
341 %include "ModelHighAPI_Dumper.h"
342 %include "ModelHighAPI_Integer.h"
343 %include "ModelHighAPI_Interface.h"
344 %include "ModelHighAPI_RefAttr.h"
345 %include "ModelHighAPI_Reference.h"
346 %include "ModelHighAPI_Selection.h"
347 %include "ModelHighAPI_Services.h"
348 %include "ModelHighAPI_Macro.h"
349 %include "ModelHighAPI_Tools.h"