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
25 #include "SketchAPI_swig.h"
26 #include "ModelHighAPI_swig.h"
28 // fix for SWIG v2.0.4
29 #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
34 // import other modules
36 %import "ModelHighAPI.i"
38 // to avoid error on this
39 #define SKETCHAPI_EXPORT
41 // standard definitions
45 %include "std_shared_ptr.i"
47 // function with named parameters
48 %feature("kwargs") SketchAPI_BSpline::controlPoles;
49 %feature("kwargs") SketchAPI_BSpline::controlPolygon;
50 %feature("kwargs") SketchAPI_Ellipse::construction;
51 %feature("kwargs") SketchAPI_EllipticArc::construction;
52 %feature("kwargs") SketchAPI_Sketch::setAngle;
55 %shared_ptr(SketchAPI_Arc)
56 %shared_ptr(SketchAPI_MacroArc)
57 %shared_ptr(SketchAPI_Circle)
58 %shared_ptr(SketchAPI_MacroCircle)
59 %shared_ptr(SketchAPI_Ellipse)
60 %shared_ptr(SketchAPI_MacroEllipse)
61 %shared_ptr(SketchAPI_EllipticArc)
62 %shared_ptr(SketchAPI_MacroEllipticArc)
63 %shared_ptr(SketchAPI_BSpline)
64 %shared_ptr(SketchAPI_Constraint)
65 %shared_ptr(SketchAPI_ConstraintAngle)
66 %shared_ptr(SketchAPI_IntersectionPoint)
67 %shared_ptr(SketchAPI_Line)
68 %shared_ptr(SketchAPI_Mirror)
69 %shared_ptr(SketchAPI_Sketch)
70 %shared_ptr(SketchAPI_SketchEntity)
71 %shared_ptr(SketchAPI_Point)
72 %shared_ptr(SketchAPI_Projection)
73 %shared_ptr(SketchAPI_Rectangle)
74 %shared_ptr(SketchAPI_Rotation)
75 %shared_ptr(SketchAPI_Translation)
78 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
79 %template(EntityList) std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
80 %template(SketchPointList) std::list<std::shared_ptr<SketchAPI_Point> >;
81 %template(GeomPnt2dList) std::list<std::shared_ptr<GeomAPI_Pnt2d> >;
83 %template(PointRefAttrPair) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>;
85 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
86 std::shared_ptr<ModelAPI_Feature> * temp_feature;
87 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
89 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
96 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
106 %typemap(in) const std::shared_ptr<ModelAPI_Feature> & (std::shared_ptr<ModelAPI_Feature> temp) {
107 std::shared_ptr<ModelAPI_Feature> * temp_feature;
108 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
110 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
112 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
115 temp = (*temp_feature);
116 if (newmem & SWIG_CAST_NEW_MEMORY) {
121 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
122 if (!temp_interface) {
123 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
126 temp = (*temp_interface)->feature();
127 if (newmem & SWIG_CAST_NEW_MEMORY) {
128 delete temp_interface;
132 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
134 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Interface.");
139 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
140 std::shared_ptr<ModelAPI_Object> * temp_object;
141 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
142 ModelHighAPI_Selection* temp_selection;
144 if (PySequence_Check($input)) {
145 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
146 PyObject * item = PySequence_GetItem($input, i);
147 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
148 if (!temp_selection) {
149 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
152 temp.push_back(temp_selection->resultSubShapePair().first);
153 if (newmem & SWIG_CAST_NEW_MEMORY) {
154 delete temp_selection;
157 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
159 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
162 temp.push_back(*temp_object);
163 if (newmem & SWIG_CAST_NEW_MEMORY) {
167 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
168 if (!temp_interface) {
169 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
172 temp.push_back((*temp_interface)->defaultResult());
173 if (newmem & SWIG_CAST_NEW_MEMORY) {
174 delete temp_interface;
181 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
186 %typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>, const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {
187 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
188 std::shared_ptr<ModelAPI_Object> * temp_object;
189 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
190 ModelHighAPI_Selection* temp_selection;
191 std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
192 std::shared_ptr<GeomAPI_Pnt2d> * temp_point;
193 ModelHighAPI_RefAttr temp_refattr;
195 std::list<PyObject*> temp_inputlist;
196 if (PySequence_Check($input)) {
197 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
198 PyObject * temp = PySequence_GetItem($input, i);
199 temp_inputlist.push_back(temp);
202 temp_inputlist.push_back($input);
206 for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end() && $1; ++it) {
207 PyObject* item = *it;
209 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
210 if (temp_selection) {
216 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
217 if (temp_attribute) {
223 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
230 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
231 if (temp_interface) {
237 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
244 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
256 %typemap(in) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & (std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> temp) {
257 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
258 std::shared_ptr<ModelAPI_Object> * temp_object;
259 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
260 ModelHighAPI_Selection* temp_selection;
261 std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
262 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
263 ModelHighAPI_RefAttr temp_refattr;
265 std::list<PyObject*> temp_inputlist;
266 if (PySequence_Check($input)) {
267 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
268 PyObject * temp = PySequence_GetItem($input, i);
269 temp_inputlist.push_back(temp);
272 temp_inputlist.push_back($input);
275 for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end(); ++it) {
276 PyObject* item = *it;
278 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
279 if (temp_selection) {
280 temp_refattr = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
281 if (newmem & SWIG_CAST_NEW_MEMORY) {
282 delete temp_selection;
286 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
287 if (temp_attribute) {
288 temp_refattr = ModelHighAPI_RefAttr(*temp_attribute);
289 if (newmem & SWIG_CAST_NEW_MEMORY) {
290 delete temp_attribute;
294 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
296 temp_refattr = ModelHighAPI_RefAttr(*temp_object);
297 if (newmem & SWIG_CAST_NEW_MEMORY) {
302 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
303 if (temp_interface) {
304 temp_refattr = ModelHighAPI_RefAttr(*temp_interface);
305 if (newmem & SWIG_CAST_NEW_MEMORY) {
306 delete temp_interface;
310 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
312 temp_point = &temp_pair->first;
313 temp_refattr = temp_pair->second;
314 if (newmem & SWIG_CAST_NEW_MEMORY) {
319 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
324 if (temp_point || !temp_refattr.isEmpty()) {
326 temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(*temp_point, temp_refattr);
328 temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(std::shared_ptr<GeomAPI_Pnt2d>(), temp_refattr);
330 if (temp_point && (newmem & SWIG_CAST_NEW_MEMORY)) {
335 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
340 // fix compilarion error: 'res*' was not declared in this scope
341 %typemap(freearg) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {}
344 %typemap(in) const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & (std::list<std::shared_ptr<GeomAPI_Pnt2d> > temp) {
345 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
347 if (PySequence_Check($input)) {
348 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
349 PyObject * item = PySequence_GetItem($input, i);
350 if (PyTuple_Check(item)) {
351 if (PyTuple_Size(item) == 2) {
352 double x = (double)PyFloat_AsDouble(PySequence_GetItem(item, 0));
353 double y = (double)PyFloat_AsDouble(PySequence_GetItem(item, 1));
354 temp.push_back(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(x, y)));
356 PyErr_SetString(PyExc_TypeError, "argument must a list of 2D points.");
360 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
361 temp.push_back(*temp_point);
362 if (temp_point && (newmem & SWIG_CAST_NEW_MEMORY)) {
366 PyErr_SetString(PyExc_TypeError, "argument must a list of 2D points.");
373 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of lists.");
378 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<GeomAPI_Pnt2d> >, const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& {
379 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
381 if (PySequence_Check($input)) {
382 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
383 PyObject * item = PySequence_GetItem($input, i);
384 if (PyTuple_Check(item)) {
385 if (PyTuple_Size(item) == 2) {
386 if (PyNumber_Check(PySequence_GetItem(item, 0)) && PyNumber_Check(PySequence_GetItem(item, 1))) {
395 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
409 // fix compilarion error: 'res*' was not declared in this scope
410 %typemap(freearg) const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & {}
413 // all supported interfaces (the order is very important according dependencies: base class first)
414 %include "SketchAPI_SketchEntity.h"
415 %include "SketchAPI_Point.h"
416 %include "SketchAPI_IntersectionPoint.h"
417 %include "SketchAPI_Line.h"
418 %include "SketchAPI_Circle.h"
419 %include "SketchAPI_MacroCircle.h"
420 %include "SketchAPI_Arc.h"
421 %include "SketchAPI_MacroArc.h"
422 %include "SketchAPI_Ellipse.h"
423 %include "SketchAPI_MacroEllipse.h"
424 %include "SketchAPI_EllipticArc.h"
425 %include "SketchAPI_MacroEllipticArc.h"
426 %include "SketchAPI_BSpline.h"
427 %include "SketchAPI_Projection.h"
428 %include "SketchAPI_Mirror.h"
429 %include "SketchAPI_Translation.h"
430 %include "SketchAPI_Rectangle.h"
431 %include "SketchAPI_Rotation.h"
432 %include "SketchAPI_Sketch.h"
433 %include "SketchAPI_Constraint.h"
434 %include "SketchAPI_ConstraintAngle.h"