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))
36 #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
41 // import other modules
44 %import "GeomDataAPI.i"
46 // to avoid error on this
47 #define MODELHIGHAPI_EXPORT
49 // standard definitions
53 %feature("director") ModelHighAPI_Dumper;
56 %rename(__print__) ModelHighAPI_Dumper::operator<<;
59 %shared_ptr(ModelHighAPI_Interface)
60 %shared_ptr(ModelHighAPI_Folder)
64 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
65 if (PyFloat_Check($input) || PyLong_Check($input)) {
66 temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
68 } else if (PyUnicode_Check($input)) {
69 temp = ModelHighAPI_Double(PyUnicode_AsUTF8($input));
71 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
73 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
77 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
78 $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
81 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
82 if (PyLong_Check($input)) {
83 temp = ModelHighAPI_Integer(static_cast<int>(PyLong_AsLong($input)));
85 } else if (PyUnicode_Check($input)) {
86 temp = ModelHighAPI_Integer(PyUnicode_AsUTF8($input));
88 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
90 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
94 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
95 $1 = ((PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
98 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
99 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
100 std::shared_ptr<ModelAPI_Object> * temp_object;
101 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
102 ModelHighAPI_Selection* temp_selection;
104 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
105 if (!temp_selection) {
106 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
109 temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
110 if (newmem & SWIG_CAST_NEW_MEMORY) {
111 delete temp_selection;
115 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
116 if (!temp_attribute) {
117 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
120 temp = ModelHighAPI_RefAttr(*temp_attribute);
121 if (newmem & SWIG_CAST_NEW_MEMORY) {
122 delete temp_attribute;
126 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
128 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
131 temp = ModelHighAPI_RefAttr(*temp_object);
132 if (newmem & SWIG_CAST_NEW_MEMORY) {
137 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
138 if (!temp_interface) {
139 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
142 temp = ModelHighAPI_RefAttr(*temp_interface);
143 if (newmem & SWIG_CAST_NEW_MEMORY) {
144 delete temp_interface;
148 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
150 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
155 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
156 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
157 std::shared_ptr<ModelAPI_Object> * temp_object;
158 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
159 ModelHighAPI_Selection* temp_selection;
161 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
162 if (temp_attribute) {
167 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
173 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
174 if (temp_interface) {
179 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
180 if (temp_selection) {
190 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
191 std::shared_ptr<ModelAPI_Object> * temp_object;
192 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
194 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
196 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
199 temp = ModelHighAPI_Reference(*temp_object);
200 if (newmem & SWIG_CAST_NEW_MEMORY) {
205 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
206 if (!temp_interface) {
207 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
210 temp = ModelHighAPI_Reference(*temp_interface);
211 if (newmem & SWIG_CAST_NEW_MEMORY) {
212 delete temp_interface;
216 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
218 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
223 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
224 std::shared_ptr<ModelAPI_Object> * temp_object;
225 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
227 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
234 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
235 if (temp_interface) {
245 %typemap(out) const ModelHighAPI_Selection & {
246 $1_basetype * ptr = new $1_basetype(*$1);
247 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
250 %typemap(out) const ModelHighAPI_Reference & {
251 $1_basetype * ptr = new $1_basetype(*$1);
252 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
255 %typemap(out) const ModelHighAPI_RefAttr & {
256 $1_basetype * ptr = new $1_basetype(*$1);
257 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
261 %template(SelectionList) std::list<ModelHighAPI_Selection>;
262 %template(SelectionListList) std::list<std::list<ModelHighAPI_Selection> >;
263 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
264 %template(RefList) std::list<ModelHighAPI_Reference>;
267 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
268 %template(StringsPair) std::pair<std::string, std::string>;
269 %template(StringWStringPair) std::pair<std::string, std::wstring>;
272 // fix compilarion error: 'res*' was not declared in this scope
273 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
274 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
276 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
277 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
279 if (PySequence_Check($input)) {
280 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
281 PyObject * item = PySequence_GetItem($input, i);
282 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
283 if (!temp_attribute) {
284 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
287 temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
288 if (newmem & SWIG_CAST_NEW_MEMORY) {
289 delete temp_attribute;
296 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
301 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
302 std::shared_ptr<ModelAPI_Object> * temp_object;
303 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
305 if (PySequence_Check($input)) {
306 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
307 PyObject * item = PySequence_GetItem($input, i);
308 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
310 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
313 temp.push_back(*temp_object);
314 if (newmem & SWIG_CAST_NEW_MEMORY) {
318 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
319 if (!temp_interface) {
320 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
323 temp.push_back((*temp_interface)->defaultResult());
324 if (newmem & SWIG_CAST_NEW_MEMORY) {
325 delete temp_interface;
332 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
337 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
338 std::shared_ptr<ModelAPI_Object> * temp_object;
339 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
341 if (PySequence_Check($input)) {
342 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
343 PyObject * item = PySequence_GetItem($input, i);
344 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
352 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
353 if (temp_interface) {
368 %typemap(in) const std::list<int> & (std::list<int> temp) {
369 if (PySequence_Check($input)) {
370 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
371 PyObject * item = PySequence_GetItem($input, i);
372 if (PyLong_Check(item)) {
373 temp.push_back((int)PyLong_AsLong(item));
375 PyErr_SetString(PyExc_TypeError, "argument must integet value.");
382 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of integer values.");
387 %typecheck(SWIG_TYPECHECK_POINTER) std::list<int>, const std::list<int>& {
388 if (PySequence_Check($input)) {
389 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
390 PyObject * item = PySequence_GetItem($input, i);
391 if (PyLong_Check(item)) {
405 %typemap(in) const std::list<double> & (std::list<double> temp) {
406 if (PyTuple_Check($input)) {
407 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
408 PyObject * item = PySequence_GetItem($input, i);
409 if (PyNumber_Check(item)) {
410 temp.push_back((double)PyFloat_AsDouble(item));
412 PyErr_SetString(PyExc_TypeError, "argument must double value.");
419 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of double values.");
424 %typecheck(SWIG_TYPECHECK_POINTER) std::list<double>, const std::list<double>& {
425 if (PyTuple_Check($input)) {
426 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
427 PyObject * item = PySequence_GetItem($input, i);
428 if (PyNumber_Check(item)) {
442 %typemap(in) const std::list<ModelHighAPI_Double> & (std::list<ModelHighAPI_Double> temp) {
443 ModelHighAPI_Double * temp_double;
444 if (PySequence_Check($input)) {
445 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
446 PyObject * item = PySequence_GetItem($input, i);
447 if (PyFloat_Check(item) || PyLong_Check(item)) {
448 temp.push_back(ModelHighAPI_Double(PyFloat_AsDouble(item)));
449 } else if (PyUnicode_Check(item)) {
450 temp.push_back(ModelHighAPI_Double(PyUnicode_AsUTF8(item)));
451 } else if ((SWIG_ConvertPtr(item, (void **)&temp_double, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
452 temp.push_back(*temp_double);
454 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
461 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
466 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Double>, const std::list<ModelHighAPI_Double> & {
467 if (PySequence_Check($input)) {
469 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
470 PyObject * item = PySequence_GetItem($input, i);
471 $1 = ((PyFloat_Check(item) || PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
480 %typemap(in) const std::list<ModelHighAPI_Integer> & (std::list<ModelHighAPI_Integer> temp) {
481 ModelHighAPI_Integer * temp_int;
482 if (PySequence_Check($input)) {
483 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
484 PyObject * item = PySequence_GetItem($input, i);
485 if (PyLong_Check(item)) {
486 temp.push_back(ModelHighAPI_Integer(PyLong_AsLong(item)));
487 } else if (PyUnicode_Check(item)) {
488 temp.push_back(ModelHighAPI_Integer(PyUnicode_AsUTF8(item)));
489 } else if ((SWIG_ConvertPtr(item, (void **)&temp_int, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
490 temp.push_back(*temp_int);
492 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
499 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
504 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Integer>, const std::list<ModelHighAPI_Integer> & {
505 if (PySequence_Check($input)) {
507 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
508 PyObject * item = PySequence_GetItem($input, i);
509 $1 = ((PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
518 // all supported interfaces
519 %include "ModelHighAPI_Double.h"
520 %include "ModelHighAPI_Dumper.h"
521 %include "ModelHighAPI_Integer.h"
522 %include "ModelHighAPI_Interface.h"
523 %include "ModelHighAPI_Folder.h"
524 %include "ModelHighAPI_RefAttr.h"
525 %include "ModelHighAPI_Reference.h"
526 %include "ModelHighAPI_Selection.h"
527 %include "ModelHighAPI_Services.h"
528 %include "ModelHighAPI_Macro.h"
529 %include "ModelHighAPI_Tools.h"