1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 %module(directors="1") ModelHighAPI
22 %feature("director:except") {
25 std::cerr << std::endl;
26 throw Swig::DirectorMethodException();
31 #include "ModelHighAPI_swig.h"
33 // fix for SWIG v2.0.4
34 #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
39 // import other modules
42 %import "GeomDataAPI.i"
44 // to avoid error on this
45 #define MODELHIGHAPI_EXPORT
47 // standard definitions
51 %include "std_string.i"
52 %include "std_shared_ptr.i"
55 %feature("director") ModelHighAPI_Dumper;
58 %rename(__print__) ModelHighAPI_Dumper::operator<<;
61 %shared_ptr(ModelHighAPI_Interface)
62 %shared_ptr(ModelHighAPI_Folder)
66 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
67 if (PyFloat_Check($input) || PyLong_Check($input)) {
68 temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
70 } else if (PyUnicode_Check($input)) {
71 temp = ModelHighAPI_Double(PyUnicode_AsUTF8($input));
73 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
75 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
79 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
80 $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
83 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
84 if (PyLong_Check($input)) {
85 temp = ModelHighAPI_Integer(static_cast<int>(PyLong_AsLong($input)));
87 } else if (PyUnicode_Check($input)) {
88 temp = ModelHighAPI_Integer(PyUnicode_AsUTF8($input));
90 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
92 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
96 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
97 $1 = ((PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
100 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
101 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
102 std::shared_ptr<ModelAPI_Object> * temp_object;
103 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
104 ModelHighAPI_Selection* temp_selection;
106 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
107 if (!temp_selection) {
108 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
111 temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
112 if (newmem & SWIG_CAST_NEW_MEMORY) {
113 delete temp_selection;
117 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
118 if (!temp_attribute) {
119 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
122 temp = ModelHighAPI_RefAttr(*temp_attribute);
123 if (newmem & SWIG_CAST_NEW_MEMORY) {
124 delete temp_attribute;
128 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
130 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
133 temp = ModelHighAPI_RefAttr(*temp_object);
134 if (newmem & SWIG_CAST_NEW_MEMORY) {
139 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
140 if (!temp_interface) {
141 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
144 temp = ModelHighAPI_RefAttr(*temp_interface);
145 if (newmem & SWIG_CAST_NEW_MEMORY) {
146 delete temp_interface;
150 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
152 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
157 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
158 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
159 std::shared_ptr<ModelAPI_Object> * temp_object;
160 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
161 ModelHighAPI_Selection* temp_selection;
163 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
164 if (temp_attribute) {
169 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
175 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
176 if (temp_interface) {
181 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
182 if (temp_selection) {
192 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
193 std::shared_ptr<ModelAPI_Object> * temp_object;
194 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
196 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
198 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
201 temp = ModelHighAPI_Reference(*temp_object);
202 if (newmem & SWIG_CAST_NEW_MEMORY) {
207 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
208 if (!temp_interface) {
209 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
212 temp = ModelHighAPI_Reference(*temp_interface);
213 if (newmem & SWIG_CAST_NEW_MEMORY) {
214 delete temp_interface;
218 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
220 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
225 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
226 std::shared_ptr<ModelAPI_Object> * temp_object;
227 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
229 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
236 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
237 if (temp_interface) {
247 %typemap(out) const ModelHighAPI_Selection & {
248 $1_basetype * ptr = new $1_basetype(*$1);
249 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
252 %typemap(out) const ModelHighAPI_Reference & {
253 $1_basetype * ptr = new $1_basetype(*$1);
254 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
257 %typemap(out) const ModelHighAPI_RefAttr & {
258 $1_basetype * ptr = new $1_basetype(*$1);
259 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
263 %template(SelectionList) std::list<ModelHighAPI_Selection>;
264 %template(SelectionListList) std::list<std::list<ModelHighAPI_Selection> >;
265 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
266 %template(RefList) std::list<ModelHighAPI_Reference>;
269 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
270 %template(StringsPair) std::pair<std::string, std::string>;
273 // fix compilarion error: 'res*' was not declared in this scope
274 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
275 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
277 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
278 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
280 if (PySequence_Check($input)) {
281 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
282 PyObject * item = PySequence_GetItem($input, i);
283 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
284 if (!temp_attribute) {
285 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
288 temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
289 if (newmem & SWIG_CAST_NEW_MEMORY) {
290 delete temp_attribute;
297 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
302 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
303 std::shared_ptr<ModelAPI_Object> * temp_object;
304 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
306 if (PySequence_Check($input)) {
307 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
308 PyObject * item = PySequence_GetItem($input, i);
309 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
311 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
314 temp.push_back(*temp_object);
315 if (newmem & SWIG_CAST_NEW_MEMORY) {
319 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
320 if (!temp_interface) {
321 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
324 temp.push_back((*temp_interface)->defaultResult());
325 if (newmem & SWIG_CAST_NEW_MEMORY) {
326 delete temp_interface;
333 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
338 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
339 std::shared_ptr<ModelAPI_Object> * temp_object;
340 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
342 if (PySequence_Check($input)) {
343 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
344 PyObject * item = PySequence_GetItem($input, i);
345 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
353 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
354 if (temp_interface) {
369 %typemap(in) const std::list<int> & (std::list<int> temp) {
370 if (PySequence_Check($input)) {
371 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
372 PyObject * item = PySequence_GetItem($input, i);
373 if (PyLong_Check(item)) {
374 temp.push_back((int)PyLong_AsLong(item));
376 PyErr_SetString(PyExc_TypeError, "argument must integet value.");
383 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of integer values.");
388 %typecheck(SWIG_TYPECHECK_POINTER) std::list<int>, const std::list<int>& {
389 if (PySequence_Check($input)) {
390 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
391 PyObject * item = PySequence_GetItem($input, i);
392 if (PyLong_Check(item)) {
406 %typemap(in) const std::list<double> & (std::list<double> temp) {
407 if (PyTuple_Check($input)) {
408 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
409 PyObject * item = PySequence_GetItem($input, i);
410 if (PyNumber_Check(item)) {
411 temp.push_back((double)PyFloat_AsDouble(item));
413 PyErr_SetString(PyExc_TypeError, "argument must double value.");
420 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of double values.");
425 %typecheck(SWIG_TYPECHECK_POINTER) std::list<double>, const std::list<double>& {
426 if (PyTuple_Check($input)) {
427 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
428 PyObject * item = PySequence_GetItem($input, i);
429 if (PyNumber_Check(item)) {
443 %typemap(in) const std::list<ModelHighAPI_Double> & (std::list<ModelHighAPI_Double> temp) {
444 ModelHighAPI_Double * temp_double;
445 if (PySequence_Check($input)) {
446 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
447 PyObject * item = PySequence_GetItem($input, i);
448 if (PyFloat_Check(item) || PyLong_Check(item)) {
449 temp.push_back(ModelHighAPI_Double(PyFloat_AsDouble(item)));
450 } else if (PyUnicode_Check(item)) {
451 temp.push_back(ModelHighAPI_Double(PyUnicode_AsUTF8(item)));
452 } else if ((SWIG_ConvertPtr(item, (void **)&temp_double, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
453 temp.push_back(*temp_double);
455 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
462 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
467 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Double>, const std::list<ModelHighAPI_Double> & {
468 if (PySequence_Check($input)) {
470 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
471 PyObject * item = PySequence_GetItem($input, i);
472 $1 = ((PyFloat_Check(item) || PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
481 %typemap(in) const std::list<ModelHighAPI_Integer> & (std::list<ModelHighAPI_Integer> temp) {
482 ModelHighAPI_Integer * temp_int;
483 if (PySequence_Check($input)) {
484 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
485 PyObject * item = PySequence_GetItem($input, i);
486 if (PyLong_Check(item)) {
487 temp.push_back(ModelHighAPI_Integer(PyLong_AsLong(item)));
488 } else if (PyUnicode_Check(item)) {
489 temp.push_back(ModelHighAPI_Integer(PyUnicode_AsUTF8(item)));
490 } else if ((SWIG_ConvertPtr(item, (void **)&temp_int, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
491 temp.push_back(*temp_int);
493 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
500 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
505 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Integer>, const std::list<ModelHighAPI_Integer> & {
506 if (PySequence_Check($input)) {
508 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
509 PyObject * item = PySequence_GetItem($input, i);
510 $1 = ((PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
519 // all supported interfaces
520 %include "ModelHighAPI_Double.h"
521 %include "ModelHighAPI_Dumper.h"
522 %include "ModelHighAPI_Integer.h"
523 %include "ModelHighAPI_Interface.h"
524 %include "ModelHighAPI_Folder.h"
525 %include "ModelHighAPI_RefAttr.h"
526 %include "ModelHighAPI_Reference.h"
527 %include "ModelHighAPI_Selection.h"
528 %include "ModelHighAPI_Services.h"
529 %include "ModelHighAPI_Macro.h"
530 %include "ModelHighAPI_Tools.h"