]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchAPI/SketchAPI.i
Salome HOME
Revert change for MacroArc attribute names
[modules/shaper.git] / src / SketchAPI / SketchAPI.i
1 /* SketchAPI.i */
2
3 %module SketchAPI
4
5 %{
6   #include "SketchAPI_swig.h"
7   #include "ModelHighAPI_swig.h"
8
9   // fix for SWIG v2.0.4
10   #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
11 %}
12
13 %include "doxyhelp.i"
14
15 // import other modules
16 %import "ModelAPI.i"
17 %import "ModelHighAPI.i"
18
19 // to avoid error on this
20 #define SKETCHAPI_EXPORT
21
22 // standard definitions
23 %include "typemaps.i"
24 %include "std_list.i"
25 %include "std_shared_ptr.i"
26
27 // shared pointers
28 %shared_ptr(SketchAPI_Arc)
29 %shared_ptr(SketchAPI_MacroArc)
30 %shared_ptr(SketchAPI_Circle)
31 %shared_ptr(SketchAPI_MacroCircle)
32 %shared_ptr(SketchAPI_Constraint)
33 %shared_ptr(SketchAPI_IntersectionPoint)
34 %shared_ptr(SketchAPI_Line)
35 %shared_ptr(SketchAPI_Mirror)
36 %shared_ptr(SketchAPI_Sketch)
37 %shared_ptr(SketchAPI_SketchEntity)
38 %shared_ptr(SketchAPI_Point)
39 %shared_ptr(SketchAPI_Projection)
40 %shared_ptr(SketchAPI_Rectangle)
41 %shared_ptr(SketchAPI_Rotation)
42 %shared_ptr(SketchAPI_Translation)
43
44 // std::list -> []
45 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
46 %template(EntityList)    std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
47
48 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
49   std::shared_ptr<ModelAPI_Feature> * temp_feature;
50   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
51   int newmem = 0;
52   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
53     if (temp_feature) {
54       $1 = 1;
55     } else {
56       $1 = 0;
57     }
58   } else
59   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
60     if (temp_interface) {
61       $1 = 1;
62     } else {
63       $1 = 0;
64     }
65   } else
66     $1 = 0;
67 }
68
69 %typemap(in) const std::shared_ptr<ModelAPI_Feature> & (std::shared_ptr<ModelAPI_Feature> temp) {
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       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
76       return NULL;
77     }
78     temp = (*temp_feature);
79     if (newmem & SWIG_CAST_NEW_MEMORY) {
80       delete temp_feature;
81     }
82     $1 = &temp;
83   } else
84   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
85     if (!temp_interface) {
86       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
87       return NULL;
88     }
89     temp = (*temp_interface)->feature();
90     if (newmem & SWIG_CAST_NEW_MEMORY) {
91       delete temp_interface;
92     }
93     $1 = &temp;
94   } else
95   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
96   } else {
97     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Interface.");
98     return NULL;
99   }
100 }
101
102 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
103   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
104   std::shared_ptr<ModelAPI_Object> * temp_object;
105   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
106   ModelHighAPI_Selection* temp_selection;
107   int newmem = 0;
108   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
109     if (!temp_selection) {
110       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
111       return NULL;
112     }
113     temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
114     if (newmem & SWIG_CAST_NEW_MEMORY) {
115       delete temp_selection;
116     }
117     $1 = &temp;
118   } else
119   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
120     if (!temp_attribute) {
121       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
122       return NULL;
123     }
124     temp = ModelHighAPI_RefAttr(*temp_attribute);
125     if (newmem & SWIG_CAST_NEW_MEMORY) {
126       delete temp_attribute;
127     }
128     $1 = &temp;
129   } else
130   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
131     if (!temp_object) {
132       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
133       return NULL;
134     }
135     temp = ModelHighAPI_RefAttr(*temp_object);
136     if (newmem & SWIG_CAST_NEW_MEMORY) {
137       delete temp_object;
138     }
139     $1 = &temp;
140   } else
141   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
142     if (!temp_interface) {
143       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
144       return NULL;
145     }
146     temp = ModelHighAPI_RefAttr(*temp_interface);
147     if (newmem & SWIG_CAST_NEW_MEMORY) {
148       delete temp_interface;
149     }
150     $1 = &temp;
151   } else
152   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
153   } else {
154     PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
155     return NULL;
156   }
157 }
158
159 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
160   std::shared_ptr<ModelAPI_Object> * temp_object;
161   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
162   ModelHighAPI_Selection* temp_selection;
163   int newmem = 0;
164   if (PySequence_Check($input)) {
165     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
166       PyObject * item = PySequence_GetItem($input, i);
167       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
168         if (!temp_selection) {
169           PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
170           return NULL;
171         }
172         temp.push_back(temp_selection->resultSubShapePair().first);
173         if (newmem & SWIG_CAST_NEW_MEMORY) {
174           delete temp_selection;
175         }
176       } else
177       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
178         if (!temp_object) {
179           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
180           return NULL;
181         }
182         temp.push_back(*temp_object);
183         if (newmem & SWIG_CAST_NEW_MEMORY) {
184           delete temp_object;
185         }
186       } else
187       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
188         if (!temp_interface) {
189           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
190           return NULL;
191         }
192         temp.push_back((*temp_interface)->defaultResult());
193         if (newmem & SWIG_CAST_NEW_MEMORY) {
194           delete temp_interface;
195         }
196       }
197       Py_DECREF(item);
198     }
199     $1 = &temp;
200   } else {
201     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
202     return NULL;
203   }
204 }
205
206 // all supported interfaces (the order is very important according dependencies: base class first)
207 %include "SketchAPI_SketchEntity.h"
208 %include "SketchAPI_Point.h"
209 %include "SketchAPI_IntersectionPoint.h"
210 %include "SketchAPI_Line.h"
211 %include "SketchAPI_Circle.h"
212 %include "SketchAPI_MacroCircle.h"
213 %include "SketchAPI_Arc.h"
214 %include "SketchAPI_MacroArc.h"
215 %include "SketchAPI_Projection.h"
216 %include "SketchAPI_Mirror.h"
217 %include "SketchAPI_Translation.h"
218 %include "SketchAPI_Rectangle.h"
219 %include "SketchAPI_Rotation.h"
220 %include "SketchAPI_Sketch.h"
221 %include "SketchAPI_Constraint.h"