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
37 %import "ModelHighAPI.i"
39 // to avoid error on this
40 #define SKETCHAPI_EXPORT
42 // standard definitions
46 %include "std_shared_ptr.i"
48 // function with named parameters
49 %feature("kwargs") SketchAPI_BSpline::controlPoles;
50 %feature("kwargs") SketchAPI_BSpline::controlPolygon;
51 %feature("kwargs") SketchAPI_Ellipse::construction;
52 %feature("kwargs") SketchAPI_EllipticArc::construction;
53 %feature("kwargs") SketchAPI_Sketch::addSpline;
54 %feature("kwargs") SketchAPI_Sketch::setAngle;
57 %shared_ptr(SketchAPI_Arc)
58 %shared_ptr(SketchAPI_MacroArc)
59 %shared_ptr(SketchAPI_Circle)
60 %shared_ptr(SketchAPI_MacroCircle)
61 %shared_ptr(SketchAPI_Ellipse)
62 %shared_ptr(SketchAPI_MacroEllipse)
63 %shared_ptr(SketchAPI_EllipticArc)
64 %shared_ptr(SketchAPI_MacroEllipticArc)
65 %shared_ptr(SketchAPI_BSpline)
66 %shared_ptr(SketchAPI_BSplinePeriodic)
67 %shared_ptr(SketchAPI_Constraint)
68 %shared_ptr(SketchAPI_ConstraintAngle)
69 %shared_ptr(SketchAPI_IntersectionPoint)
70 %shared_ptr(SketchAPI_Line)
71 %shared_ptr(SketchAPI_Mirror)
72 %shared_ptr(SketchAPI_Sketch)
73 %shared_ptr(SketchAPI_SketchEntity)
74 %shared_ptr(SketchAPI_Point)
75 %shared_ptr(SketchAPI_Projection)
76 %shared_ptr(SketchAPI_Rectangle)
77 %shared_ptr(SketchAPI_Rotation)
78 %shared_ptr(SketchAPI_Translation)
81 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
82 %template(EntityList) std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
83 %template(SketchPointList) std::list<std::shared_ptr<SketchAPI_Point> >;
84 %template(GeomPnt2dList) std::list<std::shared_ptr<GeomAPI_Pnt2d> >;
86 %template(PointRefAttrPair) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>;
88 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
89 std::shared_ptr<ModelAPI_Feature> * temp_feature;
90 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
92 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
99 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
100 if (temp_interface) {
109 %typemap(in) const std::shared_ptr<ModelAPI_Feature> & (std::shared_ptr<ModelAPI_Feature> temp) {
110 std::shared_ptr<ModelAPI_Feature> * temp_feature;
111 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
113 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
115 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
118 temp = (*temp_feature);
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_Interface.");
129 temp = (*temp_interface)->feature();
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_Interface.");
142 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
143 std::shared_ptr<ModelAPI_Object> * temp_object;
144 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
145 ModelHighAPI_Selection* temp_selection;
147 if (PySequence_Check($input)) {
148 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
149 PyObject * item = PySequence_GetItem($input, i);
150 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
151 if (!temp_selection) {
152 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
155 temp.push_back(temp_selection->resultSubShapePair().first);
156 if (newmem & SWIG_CAST_NEW_MEMORY) {
157 delete temp_selection;
160 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
162 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
165 temp.push_back(*temp_object);
166 if (newmem & SWIG_CAST_NEW_MEMORY) {
170 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
171 if (!temp_interface) {
172 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
175 temp.push_back((*temp_interface)->defaultResult());
176 if (newmem & SWIG_CAST_NEW_MEMORY) {
177 delete temp_interface;
184 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
189 %typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>, const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {
190 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
191 std::shared_ptr<ModelAPI_Object> * temp_object;
192 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
193 ModelHighAPI_Selection* temp_selection;
194 std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
195 std::shared_ptr<GeomAPI_Pnt2d> * temp_point;
196 ModelHighAPI_RefAttr temp_refattr;
198 std::list<PyObject*> temp_inputlist;
199 if (PySequence_Check($input)) {
200 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
201 PyObject * temp = PySequence_GetItem($input, i);
202 temp_inputlist.push_back(temp);
205 temp_inputlist.push_back($input);
209 for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end() && $1; ++it) {
210 PyObject* item = *it;
212 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
213 if (temp_selection) {
219 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
220 if (temp_attribute) {
226 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
233 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
234 if (temp_interface) {
240 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
247 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
259 %typemap(in) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & (std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> temp) {
260 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
261 std::shared_ptr<ModelAPI_Object> * temp_object;
262 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
263 ModelHighAPI_Selection* temp_selection;
264 std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
265 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
266 ModelHighAPI_RefAttr temp_refattr;
268 std::list<PyObject*> temp_inputlist;
269 if (PySequence_Check($input)) {
270 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
271 PyObject * temp = PySequence_GetItem($input, i);
272 temp_inputlist.push_back(temp);
275 temp_inputlist.push_back($input);
278 for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end(); ++it) {
279 PyObject* item = *it;
281 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
282 if (temp_selection) {
283 temp_refattr = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
284 if (newmem & SWIG_CAST_NEW_MEMORY) {
285 delete temp_selection;
289 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
290 if (temp_attribute) {
291 temp_refattr = ModelHighAPI_RefAttr(*temp_attribute);
292 if (newmem & SWIG_CAST_NEW_MEMORY) {
293 delete temp_attribute;
297 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
299 temp_refattr = ModelHighAPI_RefAttr(*temp_object);
300 if (newmem & SWIG_CAST_NEW_MEMORY) {
305 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
306 if (temp_interface) {
307 temp_refattr = ModelHighAPI_RefAttr(*temp_interface);
308 if (newmem & SWIG_CAST_NEW_MEMORY) {
309 delete temp_interface;
313 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
315 temp_point = &temp_pair->first;
316 temp_refattr = temp_pair->second;
317 if (newmem & SWIG_CAST_NEW_MEMORY) {
322 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
327 if (temp_point || !temp_refattr.isEmpty()) {
329 temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(*temp_point, temp_refattr);
331 temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(std::shared_ptr<GeomAPI_Pnt2d>(), temp_refattr);
333 if (temp_point && (newmem & SWIG_CAST_NEW_MEMORY)) {
338 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
343 // fix compilarion error: 'res*' was not declared in this scope
344 %typemap(freearg) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {}
347 %typemap(in) const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & (std::list<std::shared_ptr<GeomAPI_Pnt2d> > temp) {
348 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
350 if (PySequence_Check($input)) {
351 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
352 PyObject * item = PySequence_GetItem($input, i);
353 if (PyTuple_Check(item)) {
354 if (PyTuple_Size(item) == 2) {
355 double x = (double)PyFloat_AsDouble(PySequence_GetItem(item, 0));
356 double y = (double)PyFloat_AsDouble(PySequence_GetItem(item, 1));
357 temp.push_back(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(x, y)));
359 PyErr_SetString(PyExc_TypeError, "argument must a list of 2D points.");
363 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
364 temp.push_back(*temp_point);
365 if (temp_point && (newmem & SWIG_CAST_NEW_MEMORY)) {
369 PyErr_SetString(PyExc_TypeError, "argument must a list of 2D points.");
376 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of lists.");
381 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<GeomAPI_Pnt2d> >, const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& {
382 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
384 if (PySequence_Check($input)) {
385 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
386 PyObject * item = PySequence_GetItem($input, i);
387 if (PyTuple_Check(item)) {
388 if (PyTuple_Size(item) == 2) {
389 if (PyNumber_Check(PySequence_GetItem(item, 0)) && PyNumber_Check(PySequence_GetItem(item, 1))) {
398 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
412 // fix compilarion error: 'res*' was not declared in this scope
413 %typemap(freearg) const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & {}
416 // all supported interfaces (the order is very important according dependencies: base class first)
417 %include "SketchAPI_SketchEntity.h"
418 %include "SketchAPI_Point.h"
419 %include "SketchAPI_IntersectionPoint.h"
420 %include "SketchAPI_Line.h"
421 %include "SketchAPI_Circle.h"
422 %include "SketchAPI_MacroCircle.h"
423 %include "SketchAPI_Arc.h"
424 %include "SketchAPI_MacroArc.h"
425 %include "SketchAPI_Ellipse.h"
426 %include "SketchAPI_MacroEllipse.h"
427 %include "SketchAPI_EllipticArc.h"
428 %include "SketchAPI_MacroEllipticArc.h"
429 %include "SketchAPI_BSpline.h"
430 %include "SketchAPI_Projection.h"
431 %include "SketchAPI_Mirror.h"
432 %include "SketchAPI_Translation.h"
433 %include "SketchAPI_Rectangle.h"
434 %include "SketchAPI_Rotation.h"
435 %include "SketchAPI_Sketch.h"
436 %include "SketchAPI_Constraint.h"
437 %include "SketchAPI_ConstraintAngle.h"