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