1 // Copyright (C) 2014-2019 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 %shared_ptr(ModelHighAPI_Interface)
59 %shared_ptr(ModelHighAPI_Folder)
63 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
64 if (PyFloat_Check($input) || PyLong_Check($input)) {
65 temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
67 } else if (PyUnicode_Check($input)) {
68 temp = ModelHighAPI_Double(PyUnicode_AsUTF8($input));
70 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
72 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
76 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
77 $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
80 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
81 if (PyLong_Check($input)) {
82 temp = ModelHighAPI_Integer(static_cast<int>(PyLong_AsLong($input)));
84 } else if (PyUnicode_Check($input)) {
85 temp = ModelHighAPI_Integer(PyUnicode_AsUTF8($input));
87 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
89 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
93 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
94 $1 = ((PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
97 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
98 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
99 std::shared_ptr<ModelAPI_Object> * temp_object;
100 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
101 ModelHighAPI_Selection* temp_selection;
103 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
104 if (!temp_selection) {
105 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
108 temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
109 if (newmem & SWIG_CAST_NEW_MEMORY) {
110 delete temp_selection;
114 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
115 if (!temp_attribute) {
116 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
119 temp = ModelHighAPI_RefAttr(*temp_attribute);
120 if (newmem & SWIG_CAST_NEW_MEMORY) {
121 delete temp_attribute;
125 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
127 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
130 temp = ModelHighAPI_RefAttr(*temp_object);
131 if (newmem & SWIG_CAST_NEW_MEMORY) {
136 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
137 if (!temp_interface) {
138 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
141 temp = ModelHighAPI_RefAttr(*temp_interface);
142 if (newmem & SWIG_CAST_NEW_MEMORY) {
143 delete temp_interface;
147 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
149 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
154 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
155 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
156 std::shared_ptr<ModelAPI_Object> * temp_object;
157 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
158 ModelHighAPI_Selection* temp_selection;
160 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
161 if (temp_attribute) {
166 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
172 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
173 if (temp_interface) {
178 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
179 if (temp_selection) {
189 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
190 std::shared_ptr<ModelAPI_Object> * temp_object;
191 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
193 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
195 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
198 temp = ModelHighAPI_Reference(*temp_object);
199 if (newmem & SWIG_CAST_NEW_MEMORY) {
204 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
205 if (!temp_interface) {
206 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
209 temp = ModelHighAPI_Reference(*temp_interface);
210 if (newmem & SWIG_CAST_NEW_MEMORY) {
211 delete temp_interface;
215 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
217 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
222 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
223 std::shared_ptr<ModelAPI_Object> * temp_object;
224 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
226 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
233 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
234 if (temp_interface) {
244 %typemap(out) const ModelHighAPI_Selection & {
245 $1_basetype * ptr = new $1_basetype(*$1);
246 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
249 %typemap(out) const ModelHighAPI_Reference & {
250 $1_basetype * ptr = new $1_basetype(*$1);
251 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
254 %typemap(out) const ModelHighAPI_RefAttr & {
255 $1_basetype * ptr = new $1_basetype(*$1);
256 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
260 %template(SelectionList) std::list<ModelHighAPI_Selection>;
261 %template(SelectionListList) std::list<std::list<ModelHighAPI_Selection> >;
262 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
263 %template(RefList) std::list<ModelHighAPI_Reference>;
266 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
267 %template(StringsPair) std::pair<std::string, std::string>;
270 // fix compilarion error: 'res*' was not declared in this scope
271 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
272 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
274 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
275 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
277 if (PySequence_Check($input)) {
278 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
279 PyObject * item = PySequence_GetItem($input, i);
280 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
281 if (!temp_attribute) {
282 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
285 temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
286 if (newmem & SWIG_CAST_NEW_MEMORY) {
287 delete temp_attribute;
294 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
299 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
300 std::shared_ptr<ModelAPI_Object> * temp_object;
301 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
303 if (PySequence_Check($input)) {
304 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
305 PyObject * item = PySequence_GetItem($input, i);
306 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
308 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
311 temp.push_back(*temp_object);
312 if (newmem & SWIG_CAST_NEW_MEMORY) {
316 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
317 if (!temp_interface) {
318 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
321 temp.push_back((*temp_interface)->defaultResult());
322 if (newmem & SWIG_CAST_NEW_MEMORY) {
323 delete temp_interface;
330 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
335 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
336 std::shared_ptr<ModelAPI_Object> * temp_object;
337 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
339 if (PySequence_Check($input)) {
340 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
341 PyObject * item = PySequence_GetItem($input, i);
342 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
350 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
351 if (temp_interface) {
365 %typemap(in) const std::list<double> & (std::list<double> temp) {
366 double * temp_attribute;
368 if (PyTuple_Check($input)) {
369 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
370 PyObject * item = PySequence_GetItem($input, i);
371 if (PyNumber_Check(item)) {
372 temp.push_back((double)PyFloat_AsDouble(item));
374 PyErr_SetString(PyExc_TypeError, "argument must double value.");
381 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of double values.");
386 %typecheck(SWIG_TYPECHECK_POINTER) std::list<double>, const std::list<double>& {
387 double * temp_object;
388 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
390 if (PyTuple_Check($input)) {
391 for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) {
392 PyObject * item = PySequence_GetItem($input, i);
393 if (PyNumber_Check(item)) {
406 // all supported interfaces
407 %include "ModelHighAPI_Double.h"
408 %include "ModelHighAPI_Dumper.h"
409 %include "ModelHighAPI_Integer.h"
410 %include "ModelHighAPI_Interface.h"
411 %include "ModelHighAPI_Folder.h"
412 %include "ModelHighAPI_RefAttr.h"
413 %include "ModelHighAPI_Reference.h"
414 %include "ModelHighAPI_Selection.h"
415 %include "ModelHighAPI_Services.h"
416 %include "ModelHighAPI_Macro.h"
417 %include "ModelHighAPI_Tools.h"