]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchAPI/SketchAPI.i
Salome HOME
Porting to SALOME_8.2.0 : Debug visualization selection for AIS_Trihedron axes.
[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_Circle)
30 %shared_ptr(SketchAPI_Constraint)
31 %shared_ptr(SketchAPI_IntersectionPoint)
32 %shared_ptr(SketchAPI_Line)
33 %shared_ptr(SketchAPI_Mirror)
34 %shared_ptr(SketchAPI_Sketch)
35 %shared_ptr(SketchAPI_SketchEntity)
36 %shared_ptr(SketchAPI_Point)
37 %shared_ptr(SketchAPI_Projection)
38 %shared_ptr(SketchAPI_Rectangle)
39 %shared_ptr(SketchAPI_Rotation)
40 %shared_ptr(SketchAPI_Translation)
41
42 // std::list -> []
43 %template(InterfaceList) std::list<std::shared_ptr<ModelHighAPI_Interface> >;
44 %template(EntityList)    std::list<std::shared_ptr<SketchAPI_SketchEntity> >;
45
46 %typecheck(SWIG_TYPECHECK_POINTER) std::shared_ptr<ModelAPI_Feature>, const std::shared_ptr<ModelAPI_Feature> & {
47   std::shared_ptr<ModelAPI_Feature> * temp_feature;
48   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
49   int newmem = 0;
50   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
51     if (temp_feature) {
52       $1 = 1;
53     } else {
54       $1 = 0;
55     }
56   } else
57   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
58     if (temp_interface) {
59       $1 = 1;
60     } else {
61       $1 = 0;
62     }
63   } else
64     $1 = 0;
65 }
66
67 %typemap(in) const std::shared_ptr<ModelAPI_Feature> & (std::shared_ptr<ModelAPI_Feature> temp) {
68   std::shared_ptr<ModelAPI_Feature> * temp_feature;
69   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
70   int newmem = 0;
71   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_feature, $descriptor(std::shared_ptr<ModelAPI_Feature> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
72     if (!temp_feature) {
73       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
74       return NULL;
75     }
76     temp = (*temp_feature);
77     if (newmem & SWIG_CAST_NEW_MEMORY) {
78       delete temp_feature;
79     }
80     $1 = &temp;
81   } else
82   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
83     if (!temp_interface) {
84       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface.");
85       return NULL;
86     }
87     temp = (*temp_interface)->feature();
88     if (newmem & SWIG_CAST_NEW_MEMORY) {
89       delete temp_interface;
90     }
91     $1 = &temp;
92   } else
93   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
94   } else {
95     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Interface.");
96     return NULL;
97   }
98 }
99
100 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
101   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
102   std::shared_ptr<ModelAPI_Object> * temp_object;
103   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
104   ModelHighAPI_Selection* temp_selection;
105   int newmem = 0;
106   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
107     if (!temp_selection) {
108       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
109       return NULL;
110     }
111     temp = ModelHighAPI_RefAttr(std::shared_ptr<ModelAPI_Object>(temp_selection->resultSubShapePair().first));
112     if (newmem & SWIG_CAST_NEW_MEMORY) {
113       delete temp_selection;
114     }
115     $1 = &temp;
116   } else
117   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
118     if (!temp_attribute) {
119       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
120       return NULL;
121     }
122     temp = ModelHighAPI_RefAttr(*temp_attribute);
123     if (newmem & SWIG_CAST_NEW_MEMORY) {
124       delete temp_attribute;
125     }
126     $1 = &temp;
127   } else
128   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
129     if (!temp_object) {
130       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
131       return NULL;
132     }
133     temp = ModelHighAPI_RefAttr(*temp_object);
134     if (newmem & SWIG_CAST_NEW_MEMORY) {
135       delete temp_object;
136     }
137     $1 = &temp;
138   } else
139   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
140     if (!temp_interface) {
141       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
142       return NULL;
143     }
144     temp = ModelHighAPI_RefAttr(*temp_interface);
145     if (newmem & SWIG_CAST_NEW_MEMORY) {
146       delete temp_interface;
147     }
148     $1 = &temp;
149   } else
150   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
151   } else {
152     PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Selection, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
153     return NULL;
154   }
155 }
156
157 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
158   std::shared_ptr<ModelAPI_Object> * temp_object;
159   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
160   ModelHighAPI_Selection* temp_selection;
161   int newmem = 0;
162   if (PySequence_Check($input)) {
163     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
164       PyObject * item = PySequence_GetItem($input, i);
165       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
166         if (!temp_selection) {
167           PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
168           return NULL;
169         }
170         temp.push_back(temp_selection->resultSubShapePair().first);
171         if (newmem & SWIG_CAST_NEW_MEMORY) {
172           delete temp_selection;
173         }
174       } else
175       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
176         if (!temp_object) {
177           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
178           return NULL;
179         }
180         temp.push_back(*temp_object);
181         if (newmem & SWIG_CAST_NEW_MEMORY) {
182           delete temp_object;
183         }
184       } else
185       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
186         if (!temp_interface) {
187           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface, ModelHighAPI_Selection or ModelAPI_Object.");
188           return NULL;
189         }
190         temp.push_back((*temp_interface)->defaultResult());
191         if (newmem & SWIG_CAST_NEW_MEMORY) {
192           delete temp_interface;
193         }
194       }
195       Py_DECREF(item);
196     }
197     $1 = &temp;
198   } else {
199     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
200     return NULL;
201   }
202 }
203
204 // all supported interfaces (the order is very important according dependencies: base class first)
205 %include "SketchAPI_SketchEntity.h"
206 %include "SketchAPI_Point.h"
207 %include "SketchAPI_IntersectionPoint.h"
208 %include "SketchAPI_Line.h"
209 %include "SketchAPI_Circle.h"
210 %include "SketchAPI_Arc.h"
211 %include "SketchAPI_Projection.h"
212 %include "SketchAPI_Mirror.h"
213 %include "SketchAPI_Translation.h"
214 %include "SketchAPI_Rectangle.h"
215 %include "SketchAPI_Rotation.h"
216 %include "SketchAPI_Sketch.h"
217 %include "SketchAPI_Constraint.h"