1 // Copyright (C) 2014-2021 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;
55 // functions with named parameters
56 %feature("kwargs") setColor;
59 %rename(__print__) ModelHighAPI_Dumper::operator<<;
62 %shared_ptr(ModelHighAPI_Interface)
63 %shared_ptr(ModelHighAPI_Folder)
67 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
68 if (PyFloat_Check($input) || PyLong_Check($input)) {
69 temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
71 } else if (PyUnicode_Check($input)) {
73 temp = ModelHighAPI_Double(PyUnicode_AsWideCharString($input, &size));
75 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
77 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
81 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
82 $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
85 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
86 if (PyLong_Check($input)) {
87 temp = ModelHighAPI_Integer(static_cast<int>(PyLong_AsLong($input)));
89 } else if (PyUnicode_Check($input)) {
91 temp = ModelHighAPI_Integer(PyUnicode_AsWideCharString($input, &size));
93 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
95 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
99 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
100 $1 = ((PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
103 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
104 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
105 std::shared_ptr<ModelAPI_Object> * temp_object;
106 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
107 ModelHighAPI_Selection* temp_selection;
109 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
110 if (!temp_selection) {
111 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
114 temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
115 if (newmem & SWIG_CAST_NEW_MEMORY) {
116 delete temp_selection;
120 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
121 if (!temp_attribute) {
122 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
125 temp = ModelHighAPI_RefAttr(*temp_attribute);
126 if (newmem & SWIG_CAST_NEW_MEMORY) {
127 delete temp_attribute;
131 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
133 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
136 temp = ModelHighAPI_RefAttr(*temp_object);
137 if (newmem & SWIG_CAST_NEW_MEMORY) {
142 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
143 if (!temp_interface) {
144 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
147 temp = ModelHighAPI_RefAttr(*temp_interface);
148 if (newmem & SWIG_CAST_NEW_MEMORY) {
149 delete temp_interface;
153 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
155 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
160 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
161 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
162 std::shared_ptr<ModelAPI_Object> * temp_object;
163 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
164 ModelHighAPI_Selection* temp_selection;
166 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
167 if (temp_attribute) {
172 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
178 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
179 if (temp_interface) {
184 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
185 if (temp_selection) {
195 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
196 std::shared_ptr<ModelAPI_Object> * temp_object;
197 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
199 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
201 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
204 temp = ModelHighAPI_Reference(*temp_object);
205 if (newmem & SWIG_CAST_NEW_MEMORY) {
210 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
211 if (!temp_interface) {
212 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
215 temp = ModelHighAPI_Reference(*temp_interface);
216 if (newmem & SWIG_CAST_NEW_MEMORY) {
217 delete temp_interface;
221 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
223 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
228 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
229 std::shared_ptr<ModelAPI_Object> * temp_object;
230 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
232 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
239 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
240 if (temp_interface) {
250 %typemap(out) const ModelHighAPI_Selection & {
251 $1_basetype * ptr = new $1_basetype(*$1);
252 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
255 %typemap(out) const ModelHighAPI_Reference & {
256 $1_basetype * ptr = new $1_basetype(*$1);
257 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
260 %typemap(out) const ModelHighAPI_RefAttr & {
261 $1_basetype * ptr = new $1_basetype(*$1);
262 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
266 %template(SelectionList) std::list<ModelHighAPI_Selection>;
267 %template(SelectionListList) std::list<std::list<ModelHighAPI_Selection> >;
268 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
269 %template(RefList) std::list<ModelHighAPI_Reference>;
272 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
273 %template(StringsPair) std::pair<std::string, std::string>;
274 %template(StringWStringPair) std::pair<std::string, std::wstring>;
277 // fix compilarion error: 'res*' was not declared in this scope
278 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
279 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
281 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
282 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
284 if (PySequence_Check($input)) {
285 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
286 PyObject * item = PySequence_GetItem($input, i);
287 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
288 if (!temp_attribute) {
289 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
292 temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
293 if (newmem & SWIG_CAST_NEW_MEMORY) {
294 delete temp_attribute;
301 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
306 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
307 std::shared_ptr<ModelAPI_Object> * temp_object;
308 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
310 if (PySequence_Check($input)) {
311 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
312 PyObject * item = PySequence_GetItem($input, i);
313 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
315 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
318 temp.push_back(*temp_object);
319 if (newmem & SWIG_CAST_NEW_MEMORY) {
323 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
324 if (!temp_interface) {
325 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
328 temp.push_back((*temp_interface)->defaultResult());
329 if (newmem & SWIG_CAST_NEW_MEMORY) {
330 delete temp_interface;
337 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
342 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
343 std::shared_ptr<ModelAPI_Object> * temp_object;
344 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
346 if (PySequence_Check($input)) {
347 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
348 PyObject * item = PySequence_GetItem($input, i);
349 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
357 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
358 if (temp_interface) {
373 %typemap(in) const std::list<int> & (std::list<int> temp) {
374 if (PySequence_Check($input)) {
375 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
376 PyObject * item = PySequence_GetItem($input, i);
377 if (PyLong_Check(item)) {
378 temp.push_back((int)PyLong_AsLong(item));
380 PyErr_SetString(PyExc_TypeError, "argument must integet value.");
387 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of integer values.");
392 %typecheck(SWIG_TYPECHECK_POINTER) std::list<int>, const std::list<int>& {
393 if (PySequence_Check($input)) {
394 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
395 PyObject * item = PySequence_GetItem($input, i);
396 if (PyLong_Check(item)) {
410 %typemap(in) const std::list<double> & (std::list<double> temp) {
411 if (PyTuple_Check($input)) {
412 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
413 PyObject * item = PySequence_GetItem($input, i);
414 if (PyNumber_Check(item)) {
415 temp.push_back((double)PyFloat_AsDouble(item));
417 PyErr_SetString(PyExc_TypeError, "argument must double value.");
424 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of double values.");
429 %typecheck(SWIG_TYPECHECK_POINTER) std::list<double>, const std::list<double>& {
430 if (PyTuple_Check($input)) {
431 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
432 PyObject * item = PySequence_GetItem($input, i);
433 if (PyNumber_Check(item)) {
447 %typemap(in) const std::list<ModelHighAPI_Double> & (std::list<ModelHighAPI_Double> temp) {
448 ModelHighAPI_Double * temp_double;
449 if (PySequence_Check($input)) {
450 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
451 PyObject * item = PySequence_GetItem($input, i);
452 if (PyFloat_Check(item) || PyLong_Check(item)) {
453 temp.push_back(ModelHighAPI_Double(PyFloat_AsDouble(item)));
454 } else if (PyUnicode_Check(item)) {
456 temp.push_back(ModelHighAPI_Double(PyUnicode_AsWideCharString(item, &size)));
457 } else if ((SWIG_ConvertPtr(item, (void **)&temp_double, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
458 temp.push_back(*temp_double);
460 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
467 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
472 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Double>, const std::list<ModelHighAPI_Double> & {
473 if (PySequence_Check($input)) {
475 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
476 PyObject * item = PySequence_GetItem($input, i);
477 $1 = ((PyFloat_Check(item) || PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
486 %typemap(in) const std::list<ModelHighAPI_Integer> & (std::list<ModelHighAPI_Integer> temp) {
487 ModelHighAPI_Integer * temp_int;
488 if (PySequence_Check($input)) {
489 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
490 PyObject * item = PySequence_GetItem($input, i);
491 if (PyLong_Check(item)) {
492 temp.push_back(ModelHighAPI_Integer(PyLong_AsLong(item)));
493 } else if (PyUnicode_Check(item)) {
495 temp.push_back(ModelHighAPI_Integer(PyUnicode_AsWideCharString(item, &size)));
496 } else if ((SWIG_ConvertPtr(item, (void **)&temp_int, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
497 temp.push_back(*temp_int);
499 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
506 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
511 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Integer>, const std::list<ModelHighAPI_Integer> & {
512 if (PySequence_Check($input)) {
514 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
515 PyObject * item = PySequence_GetItem($input, i);
516 $1 = ((PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
525 // all supported interfaces
526 %include "ModelHighAPI_Double.h"
527 %include "ModelHighAPI_Dumper.h"
528 %include "ModelHighAPI_Integer.h"
529 %include "ModelHighAPI_Interface.h"
530 %include "ModelHighAPI_Folder.h"
531 %include "ModelHighAPI_RefAttr.h"
532 %include "ModelHighAPI_Reference.h"
533 %include "ModelHighAPI_Selection.h"
534 %include "ModelHighAPI_Services.h"
535 %include "ModelHighAPI_Macro.h"
536 %include "ModelHighAPI_Tools.h"