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;
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)) {
70 temp = ModelHighAPI_Double(PyUnicode_AsWideCharString($input, &size));
72 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
74 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
78 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
79 $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
82 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
83 if (PyLong_Check($input)) {
84 temp = ModelHighAPI_Integer(static_cast<int>(PyLong_AsLong($input)));
86 } else if (PyUnicode_Check($input)) {
88 temp = ModelHighAPI_Integer(PyUnicode_AsWideCharString($input, &size));
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>;
271 %template(StringWStringPair) std::pair<std::string, std::wstring>;
274 // fix compilarion error: 'res*' was not declared in this scope
275 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
276 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
278 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
279 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
281 if (PySequence_Check($input)) {
282 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
283 PyObject * item = PySequence_GetItem($input, i);
284 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
285 if (!temp_attribute) {
286 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
289 temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
290 if (newmem & SWIG_CAST_NEW_MEMORY) {
291 delete temp_attribute;
298 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
303 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
304 std::shared_ptr<ModelAPI_Object> * temp_object;
305 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
307 if (PySequence_Check($input)) {
308 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
309 PyObject * item = PySequence_GetItem($input, i);
310 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
312 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
315 temp.push_back(*temp_object);
316 if (newmem & SWIG_CAST_NEW_MEMORY) {
320 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
321 if (!temp_interface) {
322 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
325 temp.push_back((*temp_interface)->defaultResult());
326 if (newmem & SWIG_CAST_NEW_MEMORY) {
327 delete temp_interface;
334 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
339 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
340 std::shared_ptr<ModelAPI_Object> * temp_object;
341 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
343 if (PySequence_Check($input)) {
344 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
345 PyObject * item = PySequence_GetItem($input, i);
346 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
354 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
355 if (temp_interface) {
370 %typemap(in) const std::list<int> & (std::list<int> temp) {
371 if (PySequence_Check($input)) {
372 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
373 PyObject * item = PySequence_GetItem($input, i);
374 if (PyLong_Check(item)) {
375 temp.push_back((int)PyLong_AsLong(item));
377 PyErr_SetString(PyExc_TypeError, "argument must integet value.");
384 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of integer values.");
389 %typecheck(SWIG_TYPECHECK_POINTER) std::list<int>, const std::list<int>& {
390 if (PySequence_Check($input)) {
391 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
392 PyObject * item = PySequence_GetItem($input, i);
393 if (PyLong_Check(item)) {
407 %typemap(in) const std::list<double> & (std::list<double> temp) {
408 if (PyTuple_Check($input)) {
409 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
410 PyObject * item = PySequence_GetItem($input, i);
411 if (PyNumber_Check(item)) {
412 temp.push_back((double)PyFloat_AsDouble(item));
414 PyErr_SetString(PyExc_TypeError, "argument must double value.");
421 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of double values.");
426 %typecheck(SWIG_TYPECHECK_POINTER) std::list<double>, const std::list<double>& {
427 if (PyTuple_Check($input)) {
428 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
429 PyObject * item = PySequence_GetItem($input, i);
430 if (PyNumber_Check(item)) {
444 %typemap(in) const std::list<ModelHighAPI_Double> & (std::list<ModelHighAPI_Double> temp) {
445 ModelHighAPI_Double * temp_double;
446 if (PySequence_Check($input)) {
447 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
448 PyObject * item = PySequence_GetItem($input, i);
449 if (PyFloat_Check(item) || PyLong_Check(item)) {
450 temp.push_back(ModelHighAPI_Double(PyFloat_AsDouble(item)));
451 } else if (PyUnicode_Check(item)) {
453 temp.push_back(ModelHighAPI_Double(PyUnicode_AsWideCharString(item, &size)));
454 } else if ((SWIG_ConvertPtr(item, (void **)&temp_double, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
455 temp.push_back(*temp_double);
457 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
464 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Double, float, int or string.");
469 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Double>, const std::list<ModelHighAPI_Double> & {
470 if (PySequence_Check($input)) {
472 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
473 PyObject * item = PySequence_GetItem($input, i);
474 $1 = ((PyFloat_Check(item) || PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
483 %typemap(in) const std::list<ModelHighAPI_Integer> & (std::list<ModelHighAPI_Integer> temp) {
484 ModelHighAPI_Integer * temp_int;
485 if (PySequence_Check($input)) {
486 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
487 PyObject * item = PySequence_GetItem($input, i);
488 if (PyLong_Check(item)) {
489 temp.push_back(ModelHighAPI_Integer(PyLong_AsLong(item)));
490 } else if (PyUnicode_Check(item)) {
492 temp.push_back(ModelHighAPI_Integer(PyUnicode_AsWideCharString(item, &size)));
493 } else if ((SWIG_ConvertPtr(item, (void **)&temp_int, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
494 temp.push_back(*temp_int);
496 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
503 PyErr_SetString(PyExc_ValueError, "argument must be a list of ModelHighAPI_Integer, int or string.");
508 %typecheck(SWIG_TYPECHECK_POINTER) std::list<ModelHighAPI_Integer>, const std::list<ModelHighAPI_Integer> & {
509 if (PySequence_Check($input)) {
511 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
512 PyObject * item = PySequence_GetItem($input, i);
513 $1 = ((PyLong_Check(item) || PyUnicode_Check(item)) && !PyBool_Check(item)) ? 1 : 0;
522 // all supported interfaces
523 %include "ModelHighAPI_Double.h"
524 %include "ModelHighAPI_Dumper.h"
525 %include "ModelHighAPI_Integer.h"
526 %include "ModelHighAPI_Interface.h"
527 %include "ModelHighAPI_Folder.h"
528 %include "ModelHighAPI_RefAttr.h"
529 %include "ModelHighAPI_Reference.h"
530 %include "ModelHighAPI_Selection.h"
531 %include "ModelHighAPI_Services.h"
532 %include "ModelHighAPI_Macro.h"
533 %include "ModelHighAPI_Tools.h"