Salome HOME
Issues #2850, #2860: Change type of angle while Python Dump, because the configuratio...
[modules/shaper.git] / src / SketchAPI / SketchAPI.i
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 /* SketchAPI.i */
22
23 %module SketchAPI
24
25 %{
26   #include "SketchAPI_swig.h"
27   #include "ModelHighAPI_swig.h"
28
29   // fix for SWIG v2.0.4
30   #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
31 %}
32
33 %include "doxyhelp.i"
34
35 // import other modules
36 %import "ModelAPI.i"
37 %import "ModelHighAPI.i"
38
39 // to avoid error on this
40 #define SKETCHAPI_EXPORT
41
42 // standard definitions
43 %include "typemaps.i"
44 %include "std_list.i"
45 %include "std_shared_ptr.i"
46
47 // shared pointers
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_ConstraintAngle)
54 %shared_ptr(SketchAPI_IntersectionPoint)
55 %shared_ptr(SketchAPI_Line)
56 %shared_ptr(SketchAPI_Mirror)
57 %shared_ptr(SketchAPI_Sketch)
58 %shared_ptr(SketchAPI_SketchEntity)
59 %shared_ptr(SketchAPI_Point)
60 %shared_ptr(SketchAPI_Projection)
61 %shared_ptr(SketchAPI_Rectangle)
62 %shared_ptr(SketchAPI_Rotation)
63 %shared_ptr(SketchAPI_Translation)
64
65 // std::list -> []
66 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
67 %template(EntityList)    std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
68
69 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
70   std::shared_ptr<ModelAPI_Feature> * temp_feature;
71   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
72   int newmem = 0;
73   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
74     if (temp_feature) {
75       $1 = 1;
76     } else {
77       $1 = 0;
78     }
79   } else
80   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
81     if (temp_interface) {
82       $1 = 1;
83     } else {
84       $1 = 0;
85     }
86   } else
87     $1 = 0;
88 }
89
90 %typemap(in) const std::shared_ptr<ModelAPI_Feature> & (std::shared_ptr<ModelAPI_Feature> temp) {
91   std::shared_ptr<ModelAPI_Feature> * temp_feature;
92   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
93   int newmem = 0;
94   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
95     if (!temp_feature) {
96       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
97       return NULL;
98     }
99     temp = (*temp_feature);
100     if (newmem & SWIG_CAST_NEW_MEMORY) {
101       delete temp_feature;
102     }
103     $1 = &temp;
104   } else
105   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
106     if (!temp_interface) {
107       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
108       return NULL;
109     }
110     temp = (*temp_interface)->feature();
111     if (newmem & SWIG_CAST_NEW_MEMORY) {
112       delete temp_interface;
113     }
114     $1 = &temp;
115   } else
116   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
117   } else {
118     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Interface.");
119     return NULL;
120   }
121 }
122
123 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
124   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
125   std::shared_ptr<ModelAPI_Object> * temp_object;
126   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
127   ModelHighAPI_Selection* temp_selection;
128   int newmem = 0;
129   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
130     if (!temp_selection) {
131       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
132       return NULL;
133     }
134     temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
135     if (newmem & SWIG_CAST_NEW_MEMORY) {
136       delete temp_selection;
137     }
138     $1 = &temp;
139   } else
140   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
141     if (!temp_attribute) {
142       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
143       return NULL;
144     }
145     temp = ModelHighAPI_RefAttr(*temp_attribute);
146     if (newmem & SWIG_CAST_NEW_MEMORY) {
147       delete temp_attribute;
148     }
149     $1 = &temp;
150   } else
151   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
152     if (!temp_object) {
153       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
154       return NULL;
155     }
156     temp = ModelHighAPI_RefAttr(*temp_object);
157     if (newmem & SWIG_CAST_NEW_MEMORY) {
158       delete temp_object;
159     }
160     $1 = &temp;
161   } else
162   if ((SWIG_ConvertPtrAndOwn($input, (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 ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
165       return NULL;
166     }
167     temp = ModelHighAPI_RefAttr(*temp_interface);
168     if (newmem & SWIG_CAST_NEW_MEMORY) {
169       delete temp_interface;
170     }
171     $1 = &temp;
172   } else
173   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
174   } else {
175     PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
176     return NULL;
177   }
178 }
179
180 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
181   std::shared_ptr<ModelAPI_Object> * temp_object;
182   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
183   ModelHighAPI_Selection* temp_selection;
184   int newmem = 0;
185   if (PySequence_Check($input)) {
186     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
187       PyObject * item = PySequence_GetItem($input, i);
188       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
189         if (!temp_selection) {
190           PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
191           return NULL;
192         }
193         temp.push_back(temp_selection->resultSubShapePair().first);
194         if (newmem & SWIG_CAST_NEW_MEMORY) {
195           delete temp_selection;
196         }
197       } else
198       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
199         if (!temp_object) {
200           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
201           return NULL;
202         }
203         temp.push_back(*temp_object);
204         if (newmem & SWIG_CAST_NEW_MEMORY) {
205           delete temp_object;
206         }
207       } else
208       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
209         if (!temp_interface) {
210           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
211           return NULL;
212         }
213         temp.push_back((*temp_interface)->defaultResult());
214         if (newmem & SWIG_CAST_NEW_MEMORY) {
215           delete temp_interface;
216         }
217       }
218       Py_DECREF(item);
219     }
220     $1 = &temp;
221   } else {
222     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
223     return NULL;
224   }
225 }
226
227 // all supported interfaces (the order is very important according dependencies: base class first)
228 %include "SketchAPI_SketchEntity.h"
229 %include "SketchAPI_Point.h"
230 %include "SketchAPI_IntersectionPoint.h"
231 %include "SketchAPI_Line.h"
232 %include "SketchAPI_Circle.h"
233 %include "SketchAPI_MacroCircle.h"
234 %include "SketchAPI_Arc.h"
235 %include "SketchAPI_MacroArc.h"
236 %include "SketchAPI_Projection.h"
237 %include "SketchAPI_Mirror.h"
238 %include "SketchAPI_Translation.h"
239 %include "SketchAPI_Rectangle.h"
240 %include "SketchAPI_Rotation.h"
241 %include "SketchAPI_Sketch.h"
242 %include "SketchAPI_Constraint.h"
243 %include "SketchAPI_ConstraintAngle.h"