1 // Copyright (C) 2014-2023 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 v4.1.1
34 #if PY_VERSION_HEX >= 0x03020000
35 # define SWIGPY_SLICEOBJECT PyObject
37 # define SWIGPY_SLICEOBJECT PySliceObject
40 // fix for SWIG v2.0.4
41 #define SWIGPY_SLICE_ARG(obj) ((SWIGPY_SLICEOBJECT*)(obj))
42 #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
47 // import other modules
50 %import "GeomDataAPI.i"
52 // to avoid error on this
53 #define MODELHIGHAPI_EXPORT
55 // standard definitions
59 %feature("director") ModelHighAPI_Dumper;
61 // functions with named parameters
62 %feature("kwargs") setColor;
65 %rename(__print__) ModelHighAPI_Dumper::operator<<;
68 %shared_ptr(ModelHighAPI_Interface)
69 %shared_ptr(ModelHighAPI_Folder)
73 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
74 if (PyFloat_Check($input) || PyLong_Check($input)) {
75 temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
77 } else if (PyUnicode_Check($input)) {
79 temp = ModelHighAPI_Double(PyUnicode_AsWideCharString($input, &size));
81 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
83 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
87 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
88 $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
91 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
92 if (PyLong_Check($input)) {
93 temp = ModelHighAPI_Integer(static_cast<int>(PyLong_AsLong($input)));
95 } else if (PyUnicode_Check($input)) {
97 temp = ModelHighAPI_Integer(PyUnicode_AsWideCharString($input, &size));
99 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
101 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
105 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
106 $1 = ((PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
109 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
110 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
111 std::shared_ptr<ModelAPI_Object> * temp_object;
112 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
113 ModelHighAPI_Selection* temp_selection;
115 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
116 if (!temp_selection) {
117 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
120 temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
121 if (newmem & SWIG_CAST_NEW_MEMORY) {
122 delete temp_selection;
126 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
127 if (!temp_attribute) {
128 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
131 temp = ModelHighAPI_RefAttr(*temp_attribute);
132 if (newmem & SWIG_CAST_NEW_MEMORY) {
133 delete temp_attribute;
137 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
139 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
142 temp = ModelHighAPI_RefAttr(*temp_object);
143 if (newmem & SWIG_CAST_NEW_MEMORY) {
148 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
149 if (!temp_interface) {
150 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
153 temp = ModelHighAPI_RefAttr(*temp_interface);
154 if (newmem & SWIG_CAST_NEW_MEMORY) {
155 delete temp_interface;
159 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
161 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
166 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
167 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
168 std::shared_ptr<ModelAPI_Object> * temp_object;
169 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
170 ModelHighAPI_Selection* temp_selection;
172 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
173 if (temp_attribute) {
178 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
184 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
185 if (temp_interface) {
190 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
191 if (temp_selection) {
201 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
202 std::shared_ptr<ModelAPI_Object> * temp_object;
203 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
205 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
207 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
210 temp = ModelHighAPI_Reference(*temp_object);
211 if (newmem & SWIG_CAST_NEW_MEMORY) {
216 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
217 if (!temp_interface) {
218 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
221 temp = ModelHighAPI_Reference(*temp_interface);
222 if (newmem & SWIG_CAST_NEW_MEMORY) {
223 delete temp_interface;
227 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
229 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
234 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
235 std::shared_ptr<ModelAPI_Object> * temp_object;
236 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
238 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
245 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
246 if (temp_interface) {
256 %typemap(out) const ModelHighAPI_Selection & {
257 $1_basetype * ptr = new $1_basetype(*$1);
258 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
261 %typemap(out) const ModelHighAPI_Reference & {
262 $1_basetype * ptr = new $1_basetype(*$1);
263 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
266 %typemap(out) const ModelHighAPI_RefAttr & {
267 $1_basetype * ptr = new $1_basetype(*$1);
268 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
272 %template(SelectionList) std::list<ModelHighAPI_Selection>;
273 %template(SelectionListList) std::list<std::list<ModelHighAPI_Selection> >;
274 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
275 %template(RefList) std::list<ModelHighAPI_Reference>;
278 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
279 %template(StringsPair) std::pair<std::string, std::string>;
280 %template(StringWStringPair) std::pair<std::string, std::wstring>;
283 // fix compilarion error: 'res*' was not declared in this scope
284 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
285 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
287 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
288 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
290 if (PySequence_Check($input)) {
291 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
292 PyObject * item = PySequence_GetItem($input, i);
293 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
294 if (!temp_attribute) {
295 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
298 temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
299 if (newmem & SWIG_CAST_NEW_MEMORY) {
300 delete temp_attribute;
307 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
312 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
313 std::shared_ptr<ModelAPI_Object> * temp_object;
314 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
316 if (PySequence_Check($input)) {
317 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
318 PyObject * item = PySequence_GetItem($input, i);
319 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
321 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
324 temp.push_back(*temp_object);
325 if (newmem & SWIG_CAST_NEW_MEMORY) {
329 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
330 if (!temp_interface) {
331 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
334 temp.push_back((*temp_interface)->defaultResult());
335 if (newmem & SWIG_CAST_NEW_MEMORY) {
336 delete temp_interface;
343 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
348 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
349 std::shared_ptr<ModelAPI_Object> * temp_object;
350 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
352 if (PySequence_Check($input)) {
353 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
354 PyObject * item = PySequence_GetItem($input, i);
355 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
363 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
364 if (temp_interface) {
379 %typemap(in) const std::list<int> & (std::list<int> temp) {
380 if (PySequence_Check($input)) {
381 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
382 PyObject * item = PySequence_GetItem($input, i);
383 if (PyLong_Check(item)) {
384 temp.push_back((int)PyLong_AsLong(item));
386 PyErr_SetString(PyExc_TypeError, "argument must integet value.");
393 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of integer values.");
398 %typecheck(SWIG_TYPECHECK_POINTER) std::list<int>, const std::list<int>& {
399 if (PySequence_Check($input)) {
400 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
401 PyObject * item = PySequence_GetItem($input, i);
402 if (PyLong_Check(item)) {
416 %typemap(in) const std::list<double> & (std::list<double> temp) {
417 if (PyTuple_Check($input)) {
418 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
419 PyObject * item = PySequence_GetItem($input, i);
420 if (PyNumber_Check(item)) {
421 temp.push_back((double)PyFloat_AsDouble(item));
423 PyErr_SetString(PyExc_TypeError, "argument must double value.");
430 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of double values.");
435 %typecheck(SWIG_TYPECHECK_POINTER) std::list<double>, const std::list<double>& {
436 if (PyTuple_Check($input)) {
437 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
438 PyObject * item = PySequence_GetItem($input, i);
439 if (PyNumber_Check(item)) {
453 %typemap(in) const std::list<ModelHighAPI_Double> & (std::list<ModelHighAPI_Double> temp) {
454 ModelHighAPI_Double * temp_double;
455 if (PySequence_Check($input)) {
456 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
457 PyObject * item = PySequence_GetItem($input, i);
458 if (PyFloat_Check(item) || PyLong_Check(item)) {
459 temp.push_back(ModelHighAPI_Double(PyFloat_AsDouble(item)));
460 } else if (PyUnicode_Check(item)) {
462 temp.push_back(ModelHighAPI_Double(PyUnicode_AsWideCharString(item, &size)));
463 } else if ((SWIG_ConvertPtr(item, (void **)&temp_double, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
464 temp.push_back(*temp_double);
466 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
473 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
478 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Double>, const std::list<ModelHighAPI_Double> & {
479 if (PySequence_Check($input)) {
481 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
482 PyObject * item = PySequence_GetItem($input, i);
483 $1 = ((PyFloat_Check(item) || PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
492 %typemap(in) const std::list<ModelHighAPI_Integer> & (std::list<ModelHighAPI_Integer> temp) {
493 ModelHighAPI_Integer * temp_int;
494 if (PySequence_Check($input)) {
495 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
496 PyObject * item = PySequence_GetItem($input, i);
497 if (PyLong_Check(item)) {
498 temp.push_back(ModelHighAPI_Integer(PyLong_AsLong(item)));
499 } else if (PyUnicode_Check(item)) {
501 temp.push_back(ModelHighAPI_Integer(PyUnicode_AsWideCharString(item, &size)));
502 } else if ((SWIG_ConvertPtr(item, (void **)&temp_int, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
503 temp.push_back(*temp_int);
505 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
512 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
517 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Integer>, const std::list<ModelHighAPI_Integer> & {
518 if (PySequence_Check($input)) {
520 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
521 PyObject * item = PySequence_GetItem($input, i);
522 $1 = ((PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
531 // all supported interfaces
532 %include "ModelHighAPI_Double.h"
533 %include "ModelHighAPI_Dumper.h"
534 %include "ModelHighAPI_Integer.h"
535 %include "ModelHighAPI_Interface.h"
536 %include "ModelHighAPI_Folder.h"
537 %include "ModelHighAPI_RefAttr.h"
538 %include "ModelHighAPI_Reference.h"
539 %include "ModelHighAPI_Selection.h"
540 %include "ModelHighAPI_Services.h"
541 %include "ModelHighAPI_Macro.h"
542 %include "ModelHighAPI_Tools.h"