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>
26 #include "SketchAPI_swig.h"
27 #include "ModelHighAPI_swig.h"
29 // fix for SWIG v2.0.4
30 #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
35 // import other modules
37 %import "ModelHighAPI.i"
39 // to avoid error on this
40 #define SKETCHAPI_EXPORT
42 // standard definitions
45 %include "std_shared_ptr.i"
48 %shared_ptr(SketchAPI_Arc)
49 %shared_ptr(SketchAPI_MacroArc)
50 %shared_ptr(SketchAPI_Circle)
51 %shared_ptr(SketchAPI_MacroCircle)
52 %shared_ptr(SketchAPI_Constraint)
53 %shared_ptr(SketchAPI_IntersectionPoint)
54 %shared_ptr(SketchAPI_Line)
55 %shared_ptr(SketchAPI_Mirror)
56 %shared_ptr(SketchAPI_Sketch)
57 %shared_ptr(SketchAPI_SketchEntity)
58 %shared_ptr(SketchAPI_Point)
59 %shared_ptr(SketchAPI_Projection)
60 %shared_ptr(SketchAPI_Rectangle)
61 %shared_ptr(SketchAPI_Rotation)
62 %shared_ptr(SketchAPI_Translation)
65 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
66 %template(EntityList) std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
68 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
69 std::shared_ptr<ModelAPI_Feature> * temp_feature;
70 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
72 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
79 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
89 %typemap(in) const std::shared_ptr<ModelAPI_Feature> & (std::shared_ptr<ModelAPI_Feature> temp) {
90 std::shared_ptr<ModelAPI_Feature> * temp_feature;
91 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
93 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
95 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
98 temp = (*temp_feature);
99 if (newmem & SWIG_CAST_NEW_MEMORY) {
104 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
105 if (!temp_interface) {
106 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
109 temp = (*temp_interface)->feature();
110 if (newmem & SWIG_CAST_NEW_MEMORY) {
111 delete temp_interface;
115 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
117 PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Interface.");
122 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
123 std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
124 std::shared_ptr<ModelAPI_Object> * temp_object;
125 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
126 ModelHighAPI_Selection* temp_selection;
128 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
129 if (!temp_selection) {
130 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
133 temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
134 if (newmem & SWIG_CAST_NEW_MEMORY) {
135 delete temp_selection;
139 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
140 if (!temp_attribute) {
141 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
144 temp = ModelHighAPI_RefAttr(*temp_attribute);
145 if (newmem & SWIG_CAST_NEW_MEMORY) {
146 delete temp_attribute;
150 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
152 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
155 temp = ModelHighAPI_RefAttr(*temp_object);
156 if (newmem & SWIG_CAST_NEW_MEMORY) {
161 if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
162 if (!temp_interface) {
163 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
166 temp = ModelHighAPI_RefAttr(*temp_interface);
167 if (newmem & SWIG_CAST_NEW_MEMORY) {
168 delete temp_interface;
172 if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
174 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
179 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
180 std::shared_ptr<ModelAPI_Object> * temp_object;
181 std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
182 ModelHighAPI_Selection* temp_selection;
184 if (PySequence_Check($input)) {
185 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
186 PyObject * item = PySequence_GetItem($input, i);
187 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
188 if (!temp_selection) {
189 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
192 temp.push_back(temp_selection->resultSubShapePair().first);
193 if (newmem & SWIG_CAST_NEW_MEMORY) {
194 delete temp_selection;
197 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
199 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
202 temp.push_back(*temp_object);
203 if (newmem & SWIG_CAST_NEW_MEMORY) {
207 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
208 if (!temp_interface) {
209 PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
212 temp.push_back((*temp_interface)->defaultResult());
213 if (newmem & SWIG_CAST_NEW_MEMORY) {
214 delete temp_interface;
221 PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
226 // all supported interfaces (the order is very important according dependencies: base class first)
227 %include "SketchAPI_SketchEntity.h"
228 %include "SketchAPI_Point.h"
229 %include "SketchAPI_IntersectionPoint.h"
230 %include "SketchAPI_Line.h"
231 %include "SketchAPI_Circle.h"
232 %include "SketchAPI_MacroCircle.h"
233 %include "SketchAPI_Arc.h"
234 %include "SketchAPI_MacroArc.h"
235 %include "SketchAPI_Projection.h"
236 %include "SketchAPI_Mirror.h"
237 %include "SketchAPI_Translation.h"
238 %include "SketchAPI_Rectangle.h"
239 %include "SketchAPI_Rotation.h"
240 %include "SketchAPI_Sketch.h"
241 %include "SketchAPI_Constraint.h"