Salome HOME
Add Rotation
[modules/shaper.git] / src / SketchAPI / SketchAPI.i
1 /* SketchAPI.i */
2
3 %module SketchAPI
4
5 %{
6   #include "SketchAPI_swig.h"
7 %}
8
9 %include "doxyhelp.i"
10
11 // import other modules
12 %import "ModelHighAPI.i"
13
14 // to avoid error on this
15 #define SKETCHAPI_EXPORT
16
17 // standard definitions
18 %include "typemaps.i"
19 %include "std_list.i"
20 %include "std_shared_ptr.i"
21
22 // shared pointers
23 %shared_ptr(SketchAPI_Arc)
24 %shared_ptr(SketchAPI_Circle)
25 %shared_ptr(SketchAPI_Line)
26 %shared_ptr(SketchAPI_Mirror)
27 %shared_ptr(SketchAPI_Sketch)
28 %shared_ptr(SketchAPI_SketchEntity)
29 %shared_ptr(SketchAPI_Point)
30 %shared_ptr(SketchAPI_Rotation)
31 %shared_ptr(SketchAPI_Translation)
32
33 // TODO(spo): move typemaps into ModelHighAPI package
34
35 // fix compilarion error: ‘res*’ was not declared in this scope
36 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
37 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
38
39 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
40   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
41   int newmem = 0;
42   if (PySequence_Check($input)) {
43     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
44       PyObject * item = PySequence_GetItem($input, i);
45       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
46         if (!temp_attribute) {
47           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
48           return NULL;
49         }
50         temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
51         if (newmem & SWIG_CAST_NEW_MEMORY) {
52           delete temp_attribute;
53         }
54       }
55       Py_DECREF(item);
56     }
57     $1 = &temp;
58   } else {
59     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
60     return NULL;
61   }
62 }
63
64 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
65   std::shared_ptr<ModelAPI_Object> * temp_object;
66   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
67   int newmem = 0;
68   if (PySequence_Check($input)) {
69     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
70       PyObject * item = PySequence_GetItem($input, i);
71       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
72         if (!temp_object) {
73           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
74           return NULL;
75         }
76         temp.push_back(*temp_object);
77         if (newmem & SWIG_CAST_NEW_MEMORY) {
78           delete temp_object;
79         }
80       } else
81       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
82         if (!temp_interface) {
83           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
84           return NULL;
85         }
86         temp.push_back((*temp_interface)->defaultResult());
87         if (newmem & SWIG_CAST_NEW_MEMORY) {
88           delete temp_interface;
89         }
90       }
91       Py_DECREF(item);
92     }
93     $1 = &temp;
94   } else {
95     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
96     return NULL;
97   }
98 }
99
100 // all supported interfaces (the order is very important according dependencies: base class first)
101 %include "SketchAPI_SketchEntity.h"
102 %include "SketchAPI_Point.h"
103 %include "SketchAPI_Line.h"
104 %include "SketchAPI_Circle.h"
105 %include "SketchAPI_Arc.h"
106 %include "SketchAPI_Mirror.h"
107 %include "SketchAPI_Translation.h"
108 %include "SketchAPI_Rotation.h"
109 %include "SketchAPI_Sketch.h"