Salome HOME
Fix for some problems in the arc inversion and added a unit test for it
[modules/shaper.git] / src / ModelAPI / ModelAPI.i
1 /* ModelAPI.i */
2 %module(directors="1") ModelAPI
3 %feature("director:except") {
4     if ($error != NULL) {
5       PyErr_Print();
6       std::cerr << std::endl;
7       throw Swig::DirectorMethodException();
8     }
9 }
10
11 %{
12   #include "ModelAPI_swig.h"
13 %}
14
15 // import other modules
16 %import "GeomAPI.i"
17
18 // to avoid error on this
19 #define MODELAPI_EXPORT
20
21 // standard definitions
22 %include "typemaps.i"
23 %include "std_string.i"
24 %include "std_list.i"
25 %include "std_shared_ptr.i"
26 %include "std_set.i"
27
28 // directors
29 %feature("director") ModelAPI_Plugin;
30 %feature("director") ModelAPI_Object;
31 %feature("director") ModelAPI_Feature;
32 %feature("director") ModelAPI_CompositeFeature;
33 %feature("director") ModelAPI_Data;
34
35 // shared pointers
36 // For ModelAPI_ResultConstruction.shape()
37 %shared_ptr(ModelAPI_Entity)
38 %shared_ptr(ModelAPI_Document)
39 %shared_ptr(ModelAPI_Session)
40 %shared_ptr(ModelAPI_Plugin)
41 %shared_ptr(ModelAPI_Object)
42 %shared_ptr(ModelAPI_Feature)
43 %shared_ptr(ModelAPI_CompositeFeature)
44 %shared_ptr(ModelAPI_Data)
45 %shared_ptr(ModelAPI_Attribute)
46 %shared_ptr(ModelAPI_AttributeDocRef)
47 %shared_ptr(ModelAPI_AttributeDouble)
48 %shared_ptr(ModelAPI_AttributeDoubleArray)
49 %shared_ptr(ModelAPI_AttributeInteger)
50 %shared_ptr(ModelAPI_AttributeIntArray)
51 %shared_ptr(ModelAPI_AttributeString)
52 %shared_ptr(ModelAPI_AttributeStringArray)
53 %shared_ptr(ModelAPI_AttributeReference)
54 %shared_ptr(ModelAPI_AttributeRefAttr)
55 %shared_ptr(ModelAPI_AttributeRefList)
56 %shared_ptr(ModelAPI_AttributeRefAttrList)
57 %shared_ptr(ModelAPI_AttributeBoolean)
58 %shared_ptr(ModelAPI_AttributeSelection)
59 %shared_ptr(ModelAPI_AttributeSelectionList)
60 %shared_ptr(ModelAPI_AttributeTables)
61 %shared_ptr(ModelAPI_Validator)
62 %shared_ptr(ModelAPI_AttributeValidator)
63 %shared_ptr(ModelAPI_FeatureValidator)
64 %shared_ptr(ModelAPI_Result)
65 %shared_ptr(ModelAPI_ResultConstruction)
66 %shared_ptr(ModelAPI_ResultBody)
67 %shared_ptr(ModelAPI_ResultPart)
68 %shared_ptr(ModelAPI_ResultGroup)
69 %shared_ptr(ModelAPI_ResultField)
70 %shared_ptr(ModelAPI_ResultParameter)
71 %shared_ptr(ModelAPI_ResultCompSolid)
72
73 %typecheck(SWIG_TYPECHECK_POINTER) const ModelAPI_AttributeTables::Value {
74   $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input) || PyBool_Check($input)) ? 1 : 0;
75 }
76
77 // Tables Value reading as int, double, boolean or string
78 %typemap(in) const ModelAPI_AttributeTables::Value {
79   if (PyInt_Check($input)) {
80     $1.myInt = int(PyInt_AsLong($input));
81     $1.myDouble = double(PyInt_AsLong($input));
82     $1.myBool = PyInt_AsLong($input) != 0;
83   } else if (PyFloat_Check($input)) {
84     $1.myInt = int(PyFloat_AsDouble($input));
85     $1.myDouble = PyFloat_AsDouble($input);
86   } else if (PyBool_Check($input)) {
87     $1.myBool = $input == Py_True;
88   } else if (PyString_Check($input)) {
89     $1.myStr = PyString_AsString($input);
90   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
91   } else {
92     PyErr_SetString(PyExc_ValueError, "Tables value must be int, double, string or bool.");
93     return NULL;
94   }
95 }
96
97 // all supported interfaces
98 %include "ModelAPI_Entity.h"
99 %include "ModelAPI_Document.h"
100 %include "ModelAPI_Session.h"
101 %include "ModelAPI_Plugin.h"
102 %include "ModelAPI_Object.h"
103 %include "ModelAPI_Feature.h"
104 %include "ModelAPI_CompositeFeature.h"
105 %include "ModelAPI_Data.h"
106 %include "ModelAPI_Attribute.h"
107 %include "ModelAPI_AttributeDocRef.h"
108 %include "ModelAPI_AttributeDouble.h"
109 %include "ModelAPI_AttributeDoubleArray.h"
110 %include "ModelAPI_AttributeInteger.h"
111 %include "ModelAPI_AttributeIntArray.h"
112 %include "ModelAPI_AttributeString.h"
113 %include "ModelAPI_AttributeStringArray.h"
114 %include "ModelAPI_AttributeReference.h"
115 %include "ModelAPI_AttributeRefAttr.h"
116 %include "ModelAPI_AttributeBoolean.h"
117 %include "ModelAPI_AttributeSelection.h"
118 %include "ModelAPI_AttributeSelectionList.h"
119 %include "ModelAPI_AttributeRefList.h"
120 %include "ModelAPI_AttributeRefAttrList.h"
121 %include "ModelAPI_AttributeTables.h"
122 %include "ModelAPI_Validator.h"
123 %include "ModelAPI_AttributeValidator.h"
124 %include "ModelAPI_FeatureValidator.h"
125 %include "ModelAPI_Result.h"
126 %include "ModelAPI_ResultConstruction.h"
127 %include "ModelAPI_ResultBody.h"
128 %include "ModelAPI_ResultPart.h"
129 %include "ModelAPI_ResultGroup.h"
130 %include "ModelAPI_ResultField.h"
131 %include "ModelAPI_ResultParameter.h"
132 %include "ModelAPI_Tools.h"
133 %include "ModelAPI_ResultCompSolid.h"
134
135 // std::list -> []
136 %template(StringList) std::list<std::string>;
137 %template(ObjectList) std::list<std::shared_ptr<ModelAPI_Object> >;
138 %template(ResultList) std::list<std::shared_ptr<ModelAPI_Result> >;
139 %template(DocumentList) std::list<std::shared_ptr<ModelAPI_Document> >;
140 // std::set -> []
141 %template(AttributeSet) std::set<std::shared_ptr<ModelAPI_Attribute> >;
142
143 // std::dynamic_pointer_cast
144 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
145 %template(featureToCompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
146 %template(objectToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
147 %template(objectToResult) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
148 %template(compositeFeatureToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_CompositeFeature>;
149
150 %template(modelAPI_Result) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
151 %template(modelAPI_ResultConstruction) shared_ptr_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
152 %template(modelAPI_ResultBody) shared_ptr_cast<ModelAPI_ResultBody, ModelAPI_Result>;
153 %template(modelAPI_ResultPart) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_Result>;
154 %template(modelAPI_ResultParameter) shared_ptr_cast<ModelAPI_ResultParameter, ModelAPI_Result>;
155 %template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultGroup>;
156 %template(modelAPI_ResultField) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultField>;
157 %template(modelAPI_ResultCompSolid) shared_ptr_cast<ModelAPI_ResultCompSolid, ModelAPI_ResultBody>;
158
159 // Attribute casts
160 %template(modelAPI_AttributeDocRef)        shared_ptr_cast<ModelAPI_AttributeDocRef, ModelAPI_Attribute>;
161 %template(modelAPI_AttributeDouble)        shared_ptr_cast<ModelAPI_AttributeDouble, ModelAPI_Attribute>;
162 %template(modelAPI_AttributeDoubleArray)   shared_ptr_cast<ModelAPI_AttributeDoubleArray, ModelAPI_Attribute>;
163 %template(modelAPI_AttributeInteger)       shared_ptr_cast<ModelAPI_AttributeInteger, ModelAPI_Attribute>;
164 %template(modelAPI_AttributeIntArray)      shared_ptr_cast<ModelAPI_AttributeIntArray, ModelAPI_Attribute>;
165 %template(modelAPI_AttributeString)        shared_ptr_cast<ModelAPI_AttributeString, ModelAPI_Attribute>;
166 %template(modelAPI_AttributeStringArray)   shared_ptr_cast<ModelAPI_AttributeStringArray, ModelAPI_Attribute>;
167 %template(modelAPI_AttributeReference)     shared_ptr_cast<ModelAPI_AttributeReference, ModelAPI_Attribute>;
168 %template(modelAPI_AttributeRefAttr)       shared_ptr_cast<ModelAPI_AttributeRefAttr, ModelAPI_Attribute>;
169 %template(modelAPI_AttributeBoolean)       shared_ptr_cast<ModelAPI_AttributeBoolean, ModelAPI_Attribute>;
170 %template(modelAPI_AttributeSelection)     shared_ptr_cast<ModelAPI_AttributeSelection, ModelAPI_Attribute>;
171 %template(modelAPI_AttributeSelectionList) shared_ptr_cast<ModelAPI_AttributeSelectionList, ModelAPI_Attribute>;
172 %template(modelAPI_AttributeRefList)       shared_ptr_cast<ModelAPI_AttributeRefList, ModelAPI_Attribute>;
173 %template(modelAPI_AttributeRefAttrList)   shared_ptr_cast<ModelAPI_AttributeRefAttrList, ModelAPI_Attribute>;
174 %template(modelAPI_AttributeTables)        shared_ptr_cast<ModelAPI_AttributeTables, ModelAPI_Attribute>;
175
176 // Geometry casts
177 %template(shapeToEdge) shared_ptr_cast<GeomAPI_Edge, GeomAPI_Shape>;