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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
22 %module(directors="1") ModelHighAPI
23 %feature("director:except") {
26 std::cerr << std::endl;
27 throw Swig::DirectorMethodException();
32 #include "ModelHighAPI_swig.h"
34 // fix for SWIG v2.0.4
35 #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
40 // import other modules
43 %import "GeomDataAPI.i"
45 // to avoid error on this
46 #define MODELHIGHAPI_EXPORT
48 // standard definitions
52 %include "std_string.i"
53 %include "std_shared_ptr.i"
56 %feature("director") ModelHighAPI_Dumper;
59 %shared_ptr(ModelHighAPI_Interface)
63 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
64 if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) {
65 temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
67 } else if (PyString_Check($input)) {
68 temp = ModelHighAPI_Double(PyString_AsString($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) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
80 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
81 if (PyInt_Check($input)) {
82 temp = ModelHighAPI_Integer(static_cast<int>(PyInt_AsLong($input)));
84 } else if (PyString_Check($input)) {
85 temp = ModelHighAPI_Integer(PyString_AsString($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 = ((PyInt_Check($input) || PyString_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;
102 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
103 if (!temp_attribute) {
104 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
107 temp = ModelHighAPI_RefAttr(*temp_attribute);
108 if (newmem & SWIG_CAST_NEW_MEMORY) {
109 delete temp_attribute;
113 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
115 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
118 temp = ModelHighAPI_RefAttr(*temp_object);
119 if (newmem & SWIG_CAST_NEW_MEMORY) {
124 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
125 if (!temp_interface) {
126 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
129 temp = ModelHighAPI_RefAttr(*temp_interface);
130 if (newmem & SWIG_CAST_NEW_MEMORY) {
131 delete temp_interface;
135 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
137 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
142 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
143 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
144 std::shared_ptr<ModelAPI_Object> * temp_object;
145 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
146 ModelHighAPI_Selection* temp_selection;
148 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
149 if (temp_attribute) {
154 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
160 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
161 if (temp_interface) {
166 } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
167 if (temp_selection) {
177 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
178 std::shared_ptr<ModelAPI_Object> * temp_object;
179 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
181 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
183 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
186 temp = ModelHighAPI_Reference(*temp_object);
187 if (newmem & SWIG_CAST_NEW_MEMORY) {
192 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
193 if (!temp_interface) {
194 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
197 temp = ModelHighAPI_Reference(*temp_interface);
198 if (newmem & SWIG_CAST_NEW_MEMORY) {
199 delete temp_interface;
203 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
205 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
210 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
211 std::shared_ptr<ModelAPI_Object> * temp_object;
212 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
214 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
221 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
222 if (temp_interface) {
232 %typemap(out) const ModelHighAPI_Selection & {
233 $1_basetype * ptr = new $1_basetype(*$1);
234 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
237 %typemap(out) const ModelHighAPI_Reference & {
238 $1_basetype * ptr = new $1_basetype(*$1);
239 $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
243 %template(SelectionList) std::list<ModelHighAPI_Selection>;
244 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
245 %template(RefList) std::list<ModelHighAPI_Reference>;
248 %template(ResultSubShapePair) std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >;
251 // fix compilarion error: 'res*' was not declared in this scope
252 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
253 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
255 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
256 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
258 if (PySequence_Check($input)) {
259 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
260 PyObject * item = PySequence_GetItem($input, i);
261 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
262 if (!temp_attribute) {
263 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
266 temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
267 if (newmem & SWIG_CAST_NEW_MEMORY) {
268 delete temp_attribute;
275 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
280 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
281 std::shared_ptr<ModelAPI_Object> * temp_object;
282 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
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_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
289 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
292 temp.push_back(*temp_object);
293 if (newmem & SWIG_CAST_NEW_MEMORY) {
297 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
298 if (!temp_interface) {
299 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
302 temp.push_back((*temp_interface)->defaultResult());
303 if (newmem & SWIG_CAST_NEW_MEMORY) {
304 delete temp_interface;
311 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
316 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
317 std::shared_ptr<ModelAPI_Object> * temp_object;
318 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
320 if (PySequence_Check($input)) {
321 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
322 PyObject * item = PySequence_GetItem($input, i);
323 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
331 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
332 if (temp_interface) {
346 // all supported interfaces
347 %include "ModelHighAPI_Double.h"
348 %include "ModelHighAPI_Dumper.h"
349 %include "ModelHighAPI_Integer.h"
350 %include "ModelHighAPI_Interface.h"
351 %include "ModelHighAPI_Folder.h"
352 %include "ModelHighAPI_RefAttr.h"
353 %include "ModelHighAPI_Reference.h"
354 %include "ModelHighAPI_Selection.h"
355 %include "ModelHighAPI_Services.h"
356 %include "ModelHighAPI_Macro.h"
357 %include "ModelHighAPI_Tools.h"