1 // Copyright (C) 2014-2017 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<mailto: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) ((PySliceObject*)(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)
62 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
63 if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) {
64 temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
66 } else if (PyString_Check($input)) {
67 temp = ModelHighAPI_Double(PyString_AsString($input));
69 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
71 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
75 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
76 $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
79 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
80 if (PyInt_Check($input)) {
81 temp = ModelHighAPI_Integer(static_cast<int>(PyInt_AsLong($input)));
83 } else if (PyString_Check($input)) {
84 temp = ModelHighAPI_Integer(PyString_AsString($input));
86 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
88 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
92 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
93 $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
96 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
97 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
98 std::shared_ptr<ModelAPI_Object> * temp_object;
99 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
101 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
102 if (!temp_attribute) {
103 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
106 temp = ModelHighAPI_RefAttr(*temp_attribute);
107 if (newmem & SWIG_CAST_NEW_MEMORY) {
108 delete temp_attribute;
112 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
114 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
117 temp = ModelHighAPI_RefAttr(*temp_object);
118 if (newmem & SWIG_CAST_NEW_MEMORY) {
123 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
124 if (!temp_interface) {
125 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
128 temp = ModelHighAPI_RefAttr(*temp_interface);
129 if (newmem & SWIG_CAST_NEW_MEMORY) {
130 delete temp_interface;
134 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
136 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
141 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
142 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
143 std::shared_ptr<ModelAPI_Object> * temp_object;
144 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
146 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
147 if (temp_attribute) {
152 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
158 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
159 if (temp_interface) {
169 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
170 std::shared_ptr<ModelAPI_Object> * temp_object;
171 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
173 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
175 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
178 temp = ModelHighAPI_Reference(*temp_object);
179 if (newmem & SWIG_CAST_NEW_MEMORY) {
184 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
185 if (!temp_interface) {
186 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
189 temp = ModelHighAPI_Reference(*temp_interface);
190 if (newmem & SWIG_CAST_NEW_MEMORY) {
191 delete temp_interface;
195 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
197 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
202 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
203 std::shared_ptr<ModelAPI_Object> * temp_object;
204 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
206 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
213 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
214 if (temp_interface) {
224 %typemap(out) const ModelHighAPI_Selection & {
225 $1_basetype * ptr = new $1_basetype(*$1);
226 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
229 %typemap(out) const ModelHighAPI_Reference & {
230 $1_basetype * ptr = new $1_basetype(*$1);
231 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
235 %template(SelectionList) std::list<ModelHighAPI_Selection>;
236 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
237 %template(RefList) std::list<ModelHighAPI_Reference>;
240 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
243 // fix compilarion error: 'res*' was not declared in this scope
244 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
245 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
247 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
248 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
250 if (PySequence_Check($input)) {
251 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
252 PyObject * item = PySequence_GetItem($input, i);
253 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
254 if (!temp_attribute) {
255 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
258 temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
259 if (newmem & SWIG_CAST_NEW_MEMORY) {
260 delete temp_attribute;
267 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
272 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
273 std::shared_ptr<ModelAPI_Object> * temp_object;
274 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
276 if (PySequence_Check($input)) {
277 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
278 PyObject * item = PySequence_GetItem($input, i);
279 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
281 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
284 temp.push_back(*temp_object);
285 if (newmem & SWIG_CAST_NEW_MEMORY) {
289 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
290 if (!temp_interface) {
291 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
294 temp.push_back((*temp_interface)->defaultResult());
295 if (newmem & SWIG_CAST_NEW_MEMORY) {
296 delete temp_interface;
303 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
308 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
309 std::shared_ptr<ModelAPI_Object> * temp_object;
310 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
312 if (PySequence_Check($input)) {
313 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
314 PyObject * item = PySequence_GetItem($input, i);
315 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
323 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
324 if (temp_interface) {
338 // all supported interfaces
339 %include "ModelHighAPI_Double.h"
340 %include "ModelHighAPI_Dumper.h"
341 %include "ModelHighAPI_Integer.h"
342 %include "ModelHighAPI_Interface.h"
343 %include "ModelHighAPI_RefAttr.h"
344 %include "ModelHighAPI_Reference.h"
345 %include "ModelHighAPI_Selection.h"
346 %include "ModelHighAPI_Services.h"
347 %include "ModelHighAPI_Macro.h"
348 %include "ModelHighAPI_Tools.h"