Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[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.h"
13   #include "ModelAPI_Document.h"
14   #include "ModelAPI_Session.h"
15   #include "ModelAPI_Object.h"
16   #include "ModelAPI_Feature.h"
17   #include "ModelAPI_Plugin.h"
18   #include "ModelAPI_CompositeFeature.h"
19   #include "ModelAPI_Data.h"
20   #include "ModelAPI_Attribute.h"
21   #include "ModelAPI_AttributeDocRef.h"
22   #include "ModelAPI_AttributeDouble.h"
23   #include "ModelAPI_AttributeInteger.h"
24   #include "ModelAPI_AttributeString.h"
25   #include "ModelAPI_AttributeReference.h"
26   #include "ModelAPI_AttributeRefAttr.h"
27   #include "ModelAPI_AttributeSelection.h"
28   #include "ModelAPI_AttributeSelectionList.h"
29   #include "ModelAPI_AttributeValidator.h"
30   #include "ModelAPI_Validator.h"
31   #include "ModelAPI_FeatureValidator.h"
32   #include "ModelAPI_AttributeRefList.h"
33   #include "ModelAPI_AttributeBoolean.h"
34   #include "ModelAPI_Result.h"
35   #include "ModelAPI_ResultConstruction.h"
36   #include "ModelAPI_ResultBody.h"
37   #include "ModelAPI_ResultPart.h"
38   #include "ModelAPI_ResultParameter.h"
39   #include "ModelAPI_ResultGroup.h"
40   #include "ModelAPI_Tools.h"
41
42   #include <memory>
43   #include <string>
44   
45   template<class T1, class T2> 
46   std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject)
47   { 
48     return std::dynamic_pointer_cast<T1>(theObject); 
49   }
50
51 %}
52
53 // to avoid error on this
54 #define MODELAPI_EXPORT
55
56 // standard definitions
57 %include "GeomAPI.i"
58 %include "typemaps.i"
59 %include "std_string.i"
60 %include "std_list.i"
61 %include "std_shared_ptr.i"
62
63 // directors
64 %feature("director") ModelAPI_Plugin;
65 %feature("director") ModelAPI_Object;
66 %feature("director") ModelAPI_Feature;
67 %feature("director") ModelAPI_CompositeFeature;
68 %feature("director") ModelAPI_Data;
69
70 // shared pointers
71 // For ModelAPI_ResultConstruction.shape()
72 %shared_ptr(ModelAPI_Document)
73 %shared_ptr(ModelAPI_Session)
74 %shared_ptr(ModelAPI_Plugin)
75 %shared_ptr(ModelAPI_Object)
76 %shared_ptr(ModelAPI_Feature)
77 %shared_ptr(ModelAPI_CompositeFeature)
78 %shared_ptr(ModelAPI_Data)
79 %shared_ptr(ModelAPI_Attribute)
80 %shared_ptr(ModelAPI_AttributeDocRef)
81 %shared_ptr(ModelAPI_AttributeDouble)
82 %shared_ptr(ModelAPI_AttributeInteger)
83 %shared_ptr(ModelAPI_AttributeString)
84 %shared_ptr(ModelAPI_AttributeReference)
85 %shared_ptr(ModelAPI_AttributeRefAttr)
86 %shared_ptr(ModelAPI_AttributeRefList)
87 %shared_ptr(ModelAPI_AttributeBoolean)
88 %shared_ptr(ModelAPI_AttributeSelection)
89 %shared_ptr(ModelAPI_AttributeSelectionList)
90 %shared_ptr(ModelAPI_Validator)
91 %shared_ptr(ModelAPI_AttributeValidator)
92 %shared_ptr(ModelAPI_FeatureValidator)
93 %shared_ptr(ModelAPI_Result)
94 %shared_ptr(ModelAPI_ResultConstruction)
95 %shared_ptr(ModelAPI_ResultBody)
96 %shared_ptr(ModelAPI_ResultPart)
97 %shared_ptr(ModelAPI_ResultGroup)
98 %shared_ptr(ModelAPI_ResultParameter)
99
100 // all supported interfaces
101 %include "ModelAPI_Document.h"
102 %include "ModelAPI_Session.h"
103 %include "ModelAPI_Plugin.h"
104 %include "ModelAPI_Object.h"
105 %include "ModelAPI_Feature.h"
106 %include "ModelAPI_CompositeFeature.h"
107 %include "ModelAPI_Data.h"
108 %include "ModelAPI_Attribute.h"
109 %include "ModelAPI_AttributeDocRef.h"
110 %include "ModelAPI_AttributeDouble.h"
111 %include "ModelAPI_AttributeInteger.h"
112 %include "ModelAPI_AttributeString.h"
113 %include "ModelAPI_AttributeReference.h"
114 %include "ModelAPI_AttributeRefAttr.h"
115 %include "ModelAPI_AttributeBoolean.h"
116 %include "ModelAPI_AttributeSelection.h"
117 %include "ModelAPI_AttributeSelectionList.h"
118 %include "ModelAPI_AttributeRefList.h"
119 %include "ModelAPI_Validator.h"
120 %include "ModelAPI_AttributeValidator.h"
121 %include "ModelAPI_FeatureValidator.h"
122 %include "ModelAPI_Result.h"
123 %include "ModelAPI_ResultConstruction.h"
124 %include "ModelAPI_ResultBody.h"
125 %include "ModelAPI_ResultPart.h"
126 %include "ModelAPI_ResultGroup.h"
127 %include "ModelAPI_ResultParameter.h"
128 %include "ModelAPI_Tools.h"
129
130 // std::list -> [] 
131 %template(ObjectList) std::list<std::shared_ptr<ModelAPI_Object> >;
132 %template(ResultList) std::list<std::shared_ptr<ModelAPI_Result> >;
133 %template(DocumentList) std::list<std::shared_ptr<ModelAPI_Document> >;
134
135 // std::dynamic_pointer_cast
136 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
137 %template(featureToCompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
138 %template(objectToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
139 %template(compositeFeatureToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_CompositeFeature>;
140
141 %template(modelAPI_Result) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
142 %template(modelAPI_ResultConstruction) shared_ptr_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
143 %template(modelAPI_ResultBody) shared_ptr_cast<ModelAPI_ResultBody, ModelAPI_Result>;
144 %template(modelAPI_ResultPart) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_Result>;
145 %template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultGroup>;
146
147 // Attribute casts
148 %template(modelAPI_AttributeDocRef)        shared_ptr_cast<ModelAPI_AttributeDocRef, ModelAPI_Attribute>;
149 %template(modelAPI_AttributeDouble)        shared_ptr_cast<ModelAPI_AttributeDouble, ModelAPI_Attribute>;
150 %template(modelAPI_AttributeInteger)       shared_ptr_cast<ModelAPI_AttributeInteger, ModelAPI_Attribute>;
151 %template(modelAPI_AttributeString)        shared_ptr_cast<ModelAPI_AttributeString, ModelAPI_Attribute>;
152 %template(modelAPI_AttributeReference)     shared_ptr_cast<ModelAPI_AttributeReference, ModelAPI_Attribute>;
153 %template(modelAPI_AttributeRefAttr)       shared_ptr_cast<ModelAPI_AttributeRefAttr, ModelAPI_Attribute>;
154 %template(modelAPI_AttributeBoolean)       shared_ptr_cast<ModelAPI_AttributeBoolean, ModelAPI_Attribute>;
155 %template(modelAPI_AttributeSelection)     shared_ptr_cast<ModelAPI_AttributeSelection, ModelAPI_Attribute>;
156 %template(modelAPI_AttributeSelectionList) shared_ptr_cast<ModelAPI_AttributeSelectionList, ModelAPI_Attribute>;
157 %template(modelAPI_AttributeRefList)       shared_ptr_cast<ModelAPI_AttributeRefList, ModelAPI_Attribute>;