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_Ellipse::construction;
49 %feature("kwargs") SketchAPI_EllipticArc::construction;
52 %shared_ptr(SketchAPI_Arc)
53 %shared_ptr(SketchAPI_MacroArc)
54 %shared_ptr(SketchAPI_Circle)
55 %shared_ptr(SketchAPI_MacroCircle)
56 %shared_ptr(SketchAPI_Ellipse)
57 %shared_ptr(SketchAPI_MacroEllipse)
58 %shared_ptr(SketchAPI_EllipticArc)
59 %shared_ptr(SketchAPI_MacroEllipticArc)
60 %shared_ptr(SketchAPI_Constraint)
61 %shared_ptr(SketchAPI_ConstraintAngle)
62 %shared_ptr(SketchAPI_IntersectionPoint)
63 %shared_ptr(SketchAPI_Line)
64 %shared_ptr(SketchAPI_Mirror)
65 %shared_ptr(SketchAPI_Sketch)
66 %shared_ptr(SketchAPI_SketchEntity)
67 %shared_ptr(SketchAPI_Point)
68 %shared_ptr(SketchAPI_Projection)
69 %shared_ptr(SketchAPI_Rectangle)
70 %shared_ptr(SketchAPI_Rotation)
71 %shared_ptr(SketchAPI_Translation)
74 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
75 %template(EntityList) std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
76 %template(SketchPointList) std::list<std::shared_ptr<SketchAPI_Point> >;
78 %template(PointRefAttrPair) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>;
80 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
81 std::shared_ptr<ModelAPI_Feature> * temp_feature;
82 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
84 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
91 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
101 %typemap(in) const std::shared_ptr<ModelAPI_Feature> & (std::shared_ptr<ModelAPI_Feature> temp) {
102 std::shared_ptr<ModelAPI_Feature> * temp_feature;
103 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
105 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
107 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
110 temp = (*temp_feature);
111 if (newmem & SWIG_CAST_NEW_MEMORY) {
116 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
117 if (!temp_interface) {
118 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
121 temp = (*temp_interface)->feature();
122 if (newmem & SWIG_CAST_NEW_MEMORY) {
123 delete temp_interface;
127 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
129 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Interface.");
134 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
135 std::shared_ptr<ModelAPI_Object> * temp_object;
136 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
137 ModelHighAPI_Selection* temp_selection;
139 if (PySequence_Check($input)) {
140 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
141 PyObject * item = PySequence_GetItem($input, i);
142 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
143 if (!temp_selection) {
144 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
147 temp.push_back(temp_selection->resultSubShapePair().first);
148 if (newmem & SWIG_CAST_NEW_MEMORY) {
149 delete temp_selection;
152 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
154 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
157 temp.push_back(*temp_object);
158 if (newmem & SWIG_CAST_NEW_MEMORY) {
162 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
163 if (!temp_interface) {
164 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
167 temp.push_back((*temp_interface)->defaultResult());
168 if (newmem & SWIG_CAST_NEW_MEMORY) {
169 delete temp_interface;
176 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
181 %typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>, const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {
182 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
183 std::shared_ptr<ModelAPI_Object> * temp_object;
184 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
185 ModelHighAPI_Selection* temp_selection;
186 std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
187 std::shared_ptr<GeomAPI_Pnt2d> * temp_point;
188 ModelHighAPI_RefAttr temp_refattr;
190 std::list<PyObject*> temp_inputlist;
191 if (PySequence_Check($input)) {
192 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
193 PyObject * temp = PySequence_GetItem($input, i);
194 temp_inputlist.push_back(temp);
197 temp_inputlist.push_back($input);
201 for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end() && $1; ++it) {
202 PyObject* item = *it;
204 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
205 if (temp_selection) {
211 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
212 if (temp_attribute) {
218 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
225 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
226 if (temp_interface) {
232 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
239 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
251 %typemap(in) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & (std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> temp) {
252 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
253 std::shared_ptr<ModelAPI_Object> * temp_object;
254 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
255 ModelHighAPI_Selection* temp_selection;
256 std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>* temp_pair;
257 std::shared_ptr<GeomAPI_Pnt2d> * temp_point = 0;
258 ModelHighAPI_RefAttr temp_refattr;
260 std::list<PyObject*> temp_inputlist;
261 if (PySequence_Check($input)) {
262 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
263 PyObject * temp = PySequence_GetItem($input, i);
264 temp_inputlist.push_back(temp);
267 temp_inputlist.push_back($input);
270 for (std::list<PyObject*>::iterator it = temp_inputlist.begin(); it != temp_inputlist.end(); ++it) {
271 PyObject* item = *it;
273 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
274 if (temp_selection) {
275 temp_refattr = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
276 if (newmem & SWIG_CAST_NEW_MEMORY) {
277 delete temp_selection;
281 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
282 if (temp_attribute) {
283 temp_refattr = ModelHighAPI_RefAttr(*temp_attribute);
284 if (newmem & SWIG_CAST_NEW_MEMORY) {
285 delete temp_attribute;
289 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
291 temp_refattr = ModelHighAPI_RefAttr(*temp_object);
292 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 temp_refattr = ModelHighAPI_RefAttr(*temp_interface);
300 if (newmem & SWIG_CAST_NEW_MEMORY) {
301 delete temp_interface;
305 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pair, $descriptor(std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
307 temp_point = &temp_pair->first;
308 temp_refattr = temp_pair->second;
309 if (newmem & SWIG_CAST_NEW_MEMORY) {
314 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_point, $descriptor(std::shared_ptr<GeomAPI_Pnt2d> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
319 if (temp_point || !temp_refattr.isEmpty()) {
321 temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(*temp_point, temp_refattr);
323 temp = std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>(std::shared_ptr<GeomAPI_Pnt2d>(), temp_refattr);
325 if (temp_point && (newmem & SWIG_CAST_NEW_MEMORY)) {
330 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
335 // fix compilarion error: 'res*' was not declared in this scope
336 %typemap(freearg) const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & {}
338 // all supported interfaces (the order is very important according dependencies: base class first)
339 %include "SketchAPI_SketchEntity.h"
340 %include "SketchAPI_Point.h"
341 %include "SketchAPI_IntersectionPoint.h"
342 %include "SketchAPI_Line.h"
343 %include "SketchAPI_Circle.h"
344 %include "SketchAPI_MacroCircle.h"
345 %include "SketchAPI_Arc.h"
346 %include "SketchAPI_MacroArc.h"
347 %include "SketchAPI_Ellipse.h"
348 %include "SketchAPI_MacroEllipse.h"
349 %include "SketchAPI_EllipticArc.h"
350 %include "SketchAPI_MacroEllipticArc.h"
351 %include "SketchAPI_Projection.h"
352 %include "SketchAPI_Mirror.h"
353 %include "SketchAPI_Translation.h"
354 %include "SketchAPI_Rectangle.h"
355 %include "SketchAPI_Rotation.h"
356 %include "SketchAPI_Sketch.h"
357 %include "SketchAPI_Constraint.h"
358 %include "SketchAPI_ConstraintAngle.h"