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::addSpline;
53 %feature("kwargs") SketchAPI_Sketch::setAngle;
56 %shared_ptr(SketchAPI_Arc)
57 %shared_ptr(SketchAPI_MacroArc)
58 %shared_ptr(SketchAPI_Circle)
59 %shared_ptr(SketchAPI_MacroCircle)
60 %shared_ptr(SketchAPI_Ellipse)
61 %shared_ptr(SketchAPI_MacroEllipse)
62 %shared_ptr(SketchAPI_EllipticArc)
63 %shared_ptr(SketchAPI_MacroEllipticArc)
64 %shared_ptr(SketchAPI_BSpline)
65 %shared_ptr(SketchAPI_BSplinePeriodic)
66 %shared_ptr(SketchAPI_Constraint)
67 %shared_ptr(SketchAPI_ConstraintAngle)
68 %shared_ptr(SketchAPI_IntersectionPoint)
69 %shared_ptr(SketchAPI_Line)
70 %shared_ptr(SketchAPI_Mirror)
71 %shared_ptr(SketchAPI_Sketch)
72 %shared_ptr(SketchAPI_SketchEntity)
73 %shared_ptr(SketchAPI_Point)
74 %shared_ptr(SketchAPI_Projection)
75 %shared_ptr(SketchAPI_Rectangle)
76 %shared_ptr(SketchAPI_Rotation)
77 %shared_ptr(SketchAPI_Translation)
80 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
81 %template(EntityList) std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
82 %template(SketchPointList) std::list<std::shared_ptr<SketchAPI_Point> >;
83 %template(GeomPnt2dList) std::list<std::shared_ptr<GeomAPI_Pnt2d> >;
85 %template(PointRefAttrPair) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>;
87 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
88 std::shared_ptr<ModelAPI_Feature> * temp_feature;
89 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
91 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
98 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
108 %typemap(in) const std::shared_ptr<ModelAPI_Feature> & (std::shared_ptr<ModelAPI_Feature> temp) {
109 std::shared_ptr<ModelAPI_Feature> * temp_feature;
110 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
112 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
114 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
117 temp = (*temp_feature);
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_Interface.");
128 temp = (*temp_interface)->feature();
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_Interface.");
141 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
142 std::shared_ptr<ModelAPI_Object> * temp_object;
143 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
144 ModelHighAPI_Selection* temp_selection;
146 if (PySequence_Check($input)) {
147 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
148 PyObject * item = PySequence_GetItem($input, i);
149 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
150 if (!temp_selection) {
151 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
154 temp.push_back(temp_selection->resultSubShapePair().first);
155 if (newmem & SWIG_CAST_NEW_MEMORY) {
156 delete temp_selection;
159 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
161 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
164 temp.push_back(*temp_object);
165 if (newmem & SWIG_CAST_NEW_MEMORY) {
169 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
170 if (!temp_interface) {
171 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
174 temp.push_back((*temp_interface)->defaultResult());
175 if (newmem & SWIG_CAST_NEW_MEMORY) {
176 delete temp_interface;
183 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
188 %typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>, const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {
189 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
190 std::shared_ptr<ModelAPI_Object> * temp_object;
191 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
192 ModelHighAPI_Selection* temp_selection;
193 std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
194 std::shared_ptr<GeomAPI_Pnt2d> * temp_point;
195 ModelHighAPI_RefAttr temp_refattr;
197 std::list<PyObject*> temp_inputlist;
198 if (PySequence_Check($input)) {
199 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
200 PyObject * temp = PySequence_GetItem($input, i);
201 temp_inputlist.push_back(temp);
204 temp_inputlist.push_back($input);
208 for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end() && $1; ++it) {
209 PyObject* item = *it;
211 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
212 if (temp_selection) {
218 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
219 if (temp_attribute) {
225 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
232 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
233 if (temp_interface) {
239 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
246 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
258 %typemap(in) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & (std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> temp) {
259 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
260 std::shared_ptr<ModelAPI_Object> * temp_object;
261 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
262 ModelHighAPI_Selection* temp_selection;
263 std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
264 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
265 ModelHighAPI_RefAttr temp_refattr;
267 std::list<PyObject*> temp_inputlist;
268 if (PySequence_Check($input)) {
269 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
270 PyObject * temp = PySequence_GetItem($input, i);
271 temp_inputlist.push_back(temp);
274 temp_inputlist.push_back($input);
277 for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end(); ++it) {
278 PyObject* item = *it;
280 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
281 if (temp_selection) {
282 temp_refattr = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
283 if (newmem & SWIG_CAST_NEW_MEMORY) {
284 delete temp_selection;
288 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
289 if (temp_attribute) {
290 temp_refattr = ModelHighAPI_RefAttr(*temp_attribute);
291 if (newmem & SWIG_CAST_NEW_MEMORY) {
292 delete temp_attribute;
296 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
298 temp_refattr = ModelHighAPI_RefAttr(*temp_object);
299 if (newmem & SWIG_CAST_NEW_MEMORY) {
304 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
305 if (temp_interface) {
306 temp_refattr = ModelHighAPI_RefAttr(*temp_interface);
307 if (newmem & SWIG_CAST_NEW_MEMORY) {
308 delete temp_interface;
312 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
314 temp_point = &temp_pair->first;
315 temp_refattr = temp_pair->second;
316 if (newmem & SWIG_CAST_NEW_MEMORY) {
321 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
326 if (temp_point || !temp_refattr.isEmpty()) {
328 temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(*temp_point, temp_refattr);
330 temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(std::shared_ptr<GeomAPI_Pnt2d>(), temp_refattr);
332 if (temp_point && (newmem & SWIG_CAST_NEW_MEMORY)) {
337 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
342 // fix compilarion error: 'res*' was not declared in this scope
343 %typemap(freearg) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {}
346 %typemap(in) const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & (std::list<std::shared_ptr<GeomAPI_Pnt2d> > temp) {
347 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
349 if (PySequence_Check($input)) {
350 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
351 PyObject * item = PySequence_GetItem($input, i);
352 if (PyTuple_Check(item)) {
353 if (PyTuple_Size(item) == 2) {
354 double x = (double)PyFloat_AsDouble(PySequence_GetItem(item, 0));
355 double y = (double)PyFloat_AsDouble(PySequence_GetItem(item, 1));
356 temp.push_back(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(x, y)));
358 PyErr_SetString(PyExc_TypeError, "argument must a list of 2D points.");
362 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
363 temp.push_back(*temp_point);
364 if (temp_point && (newmem & SWIG_CAST_NEW_MEMORY)) {
368 PyErr_SetString(PyExc_TypeError, "argument must a list of 2D points.");
375 PyErr_SetString(PyExc_ValueError, "argument must be a tuple of lists.");
380 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<GeomAPI_Pnt2d> >, const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& {
381 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
383 if (PySequence_Check($input)) {
384 for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
385 PyObject * item = PySequence_GetItem($input, i);
386 if (PyTuple_Check(item)) {
387 if (PyTuple_Size(item) == 2) {
388 if (PyNumber_Check(PySequence_GetItem(item, 0)) && PyNumber_Check(PySequence_GetItem(item, 1))) {
397 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
411 // fix compilarion error: 'res*' was not declared in this scope
412 %typemap(freearg) const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & {}
415 // all supported interfaces (the order is very important according dependencies: base class first)
416 %include "SketchAPI_SketchEntity.h"
417 %include "SketchAPI_Point.h"
418 %include "SketchAPI_IntersectionPoint.h"
419 %include "SketchAPI_Line.h"
420 %include "SketchAPI_Circle.h"
421 %include "SketchAPI_MacroCircle.h"
422 %include "SketchAPI_Arc.h"
423 %include "SketchAPI_MacroArc.h"
424 %include "SketchAPI_Ellipse.h"
425 %include "SketchAPI_MacroEllipse.h"
426 %include "SketchAPI_EllipticArc.h"
427 %include "SketchAPI_MacroEllipticArc.h"
428 %include "SketchAPI_BSpline.h"
429 %include "SketchAPI_Projection.h"
430 %include "SketchAPI_Mirror.h"
431 %include "SketchAPI_Translation.h"
432 %include "SketchAPI_Rectangle.h"
433 %include "SketchAPI_Rotation.h"
434 %include "SketchAPI_Sketch.h"
435 %include "SketchAPI_Constraint.h"
436 %include "SketchAPI_ConstraintAngle.h"