Salome HOME
Improve Model package coverage: remove unused methods, open/save tests improvements
[modules/shaper.git] / src / ModelAPI / ModelAPI.i
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 /* ModelAPI.i */
22 %module(directors="1") ModelAPI
23 %feature("director:except") {
24     if ($error != NULL) {
25       PyErr_Print();
26       std::cerr << std::endl;
27       throw Swig::DirectorMethodException();
28     }
29 }
30
31 %{
32   #include "ModelAPI_swig.h"
33
34   // fix for SWIG v2.0.4
35   #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
36 %}
37
38 // import other modules
39 %import "GeomAPI.i"
40
41 // to avoid error on this
42 #define MODELAPI_EXPORT
43
44 // standard definitions
45 %include "typemaps.i"
46 %include "std_string.i"
47 %include "std_list.i"
48 %include "std_shared_ptr.i"
49 %include "std_set.i"
50
51 // directors
52 %feature("director") ModelAPI_Plugin;
53 %feature("director") ModelAPI_Object;
54 %feature("director") ModelAPI_Feature;
55 %feature("director") ModelAPI_CompositeFeature;
56 %feature("director") ModelAPI_Data;
57 %feature("director") ModelAPI_Folder;
58
59 // shared pointers
60 // For ModelAPI_ResultConstruction.shape()
61 %shared_ptr(ModelAPI_Entity)
62 %shared_ptr(ModelAPI_Document)
63 %shared_ptr(ModelAPI_Session)
64 %shared_ptr(ModelAPI_Plugin)
65 %shared_ptr(ModelAPI_Object)
66 %shared_ptr(ModelAPI_Feature)
67 %shared_ptr(ModelAPI_CompositeFeature)
68 %shared_ptr(ModelAPI_Data)
69 %shared_ptr(ModelAPI_Folder)
70 %shared_ptr(ModelAPI_Attribute)
71 %shared_ptr(ModelAPI_AttributeDocRef)
72 %shared_ptr(ModelAPI_AttributeDouble)
73 %shared_ptr(ModelAPI_AttributeDoubleArray)
74 %shared_ptr(ModelAPI_AttributeInteger)
75 %shared_ptr(ModelAPI_AttributeIntArray)
76 %shared_ptr(ModelAPI_AttributeString)
77 %shared_ptr(ModelAPI_AttributeStringArray)
78 %shared_ptr(ModelAPI_AttributeReference)
79 %shared_ptr(ModelAPI_AttributeRefAttr)
80 %shared_ptr(ModelAPI_AttributeRefList)
81 %shared_ptr(ModelAPI_AttributeRefAttrList)
82 %shared_ptr(ModelAPI_AttributeBoolean)
83 %shared_ptr(ModelAPI_AttributeSelection)
84 %shared_ptr(ModelAPI_AttributeSelectionList)
85 %shared_ptr(ModelAPI_AttributeTables)
86 %shared_ptr(ModelAPI_Validator)
87 %shared_ptr(ModelAPI_AttributeValidator)
88 %shared_ptr(ModelAPI_FeatureValidator)
89 %shared_ptr(ModelAPI_Result)
90 %shared_ptr(ModelAPI_ResultConstruction)
91 %shared_ptr(ModelAPI_ResultBody)
92 %shared_ptr(ModelAPI_ResultPart)
93 %shared_ptr(ModelAPI_ResultGroup)
94 %shared_ptr(ModelAPI_ResultField)
95 %shared_ptr(ModelAPI_ResultParameter)
96 %shared_ptr(ModelAPI_ResultCompSolid)
97
98 %typecheck(SWIG_TYPECHECK_POINTER) const ModelAPI_AttributeTables::Value {
99   $1 = (PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input) || PyBool_Check($input)) ? 1 : 0;
100 }
101
102 // Tables Value reading as int, double, boolean or string
103 %typemap(in) const ModelAPI_AttributeTables::Value {
104   if (PyLong_Check($input)) {
105     $1.myInt = int(PyLong_AsLong($input));
106     $1.myDouble = double(PyLong_AsLong($input));
107     $1.myBool = PyLong_AsLong($input) != 0;
108   } else if (PyFloat_Check($input)) {
109     $1.myInt = int(PyFloat_AsDouble($input));
110     $1.myDouble = PyFloat_AsDouble($input);
111   } else if (PyBool_Check($input)) {
112     $1.myBool = $input == Py_True;
113   } else if (PyUnicode_Check($input)) {
114     $1.myStr = PyUnicode_AsUTF8($input);
115   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
116   } else {
117     PyErr_SetString(PyExc_ValueError, "Tables value must be int, double, string or bool.");
118     return NULL;
119   }
120 }
121
122 %apply int& OUTPUT {int& theIndexInFolder};
123
124 // all supported interfaces
125 %include "ModelAPI_Entity.h"
126 %include "ModelAPI_Document.h"
127 %include "ModelAPI_Session.h"
128 %include "ModelAPI_Plugin.h"
129 %include "ModelAPI_Object.h"
130 %include "ModelAPI_Feature.h"
131 %include "ModelAPI_CompositeFeature.h"
132 %include "ModelAPI_Data.h"
133 %include "ModelAPI_Attribute.h"
134 %include "ModelAPI_AttributeDocRef.h"
135 %include "ModelAPI_AttributeDouble.h"
136 %include "ModelAPI_AttributeDoubleArray.h"
137 %include "ModelAPI_AttributeInteger.h"
138 %include "ModelAPI_AttributeIntArray.h"
139 %include "ModelAPI_AttributeString.h"
140 %include "ModelAPI_AttributeStringArray.h"
141 %include "ModelAPI_AttributeReference.h"
142 %include "ModelAPI_AttributeRefAttr.h"
143 %include "ModelAPI_AttributeBoolean.h"
144 %include "ModelAPI_AttributeSelection.h"
145 %include "ModelAPI_AttributeSelectionList.h"
146 %include "ModelAPI_AttributeRefList.h"
147 %include "ModelAPI_AttributeRefAttrList.h"
148 %include "ModelAPI_AttributeTables.h"
149 %include "ModelAPI_Validator.h"
150 %include "ModelAPI_AttributeValidator.h"
151 %include "ModelAPI_FeatureValidator.h"
152 %include "ModelAPI_Result.h"
153 %include "ModelAPI_ResultConstruction.h"
154 %include "ModelAPI_ResultBody.h"
155 %include "ModelAPI_ResultPart.h"
156 %include "ModelAPI_ResultGroup.h"
157 %include "ModelAPI_ResultField.h"
158 %include "ModelAPI_ResultParameter.h"
159 %include "ModelAPI_Tools.h"
160 %include "ModelAPI_Folder.h"
161
162 // std::list -> []
163 %template(StringList) std::list<std::string>;
164 %template(ObjectList) std::list<std::shared_ptr<ModelAPI_Object> >;
165 %template(FeatureList) std::list<std::shared_ptr<ModelAPI_Feature> >;
166 %template(ResultList) std::list<std::shared_ptr<ModelAPI_Result> >;
167 %template(DocumentList) std::list<std::shared_ptr<ModelAPI_Document> >;
168 // std::set -> []
169 %template(AttributeSet) std::set<std::shared_ptr<ModelAPI_Attribute> >;
170 %template(FeatureSet) std::set<std::shared_ptr<ModelAPI_Feature> >;
171
172 // std::dynamic_pointer_cast
173 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
174 %template(featureToCompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
175 %template(objectToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
176 %template(objectToResult) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
177 %template(objectToFolder) shared_ptr_cast<ModelAPI_Folder, ModelAPI_Object>;
178 %template(compositeFeatureToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_CompositeFeature>;
179
180 %template(modelAPI_Result) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
181 %template(modelAPI_ResultConstruction) shared_ptr_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
182 %template(modelAPI_ResultBody) shared_ptr_cast<ModelAPI_ResultBody, ModelAPI_Result>;
183 %template(modelAPI_ResultPart) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_Result>;
184 %template(modelAPI_ResultParameter) shared_ptr_cast<ModelAPI_ResultParameter, ModelAPI_Result>;
185 %template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultGroup, ModelAPI_Result>;
186 %template(modelAPI_ResultField) shared_ptr_cast<ModelAPI_ResultField, ModelAPI_Result>;
187
188 // Attribute casts
189 %template(modelAPI_AttributeDocRef)        shared_ptr_cast<ModelAPI_AttributeDocRef, ModelAPI_Attribute>;
190 %template(modelAPI_AttributeDouble)        shared_ptr_cast<ModelAPI_AttributeDouble, ModelAPI_Attribute>;
191 %template(modelAPI_AttributeDoubleArray)   shared_ptr_cast<ModelAPI_AttributeDoubleArray, ModelAPI_Attribute>;
192 %template(modelAPI_AttributeInteger)       shared_ptr_cast<ModelAPI_AttributeInteger, ModelAPI_Attribute>;
193 %template(modelAPI_AttributeIntArray)      shared_ptr_cast<ModelAPI_AttributeIntArray, ModelAPI_Attribute>;
194 %template(modelAPI_AttributeString)        shared_ptr_cast<ModelAPI_AttributeString, ModelAPI_Attribute>;
195 %template(modelAPI_AttributeStringArray)   shared_ptr_cast<ModelAPI_AttributeStringArray, ModelAPI_Attribute>;
196 %template(modelAPI_AttributeReference)     shared_ptr_cast<ModelAPI_AttributeReference, ModelAPI_Attribute>;
197 %template(modelAPI_AttributeRefAttr)       shared_ptr_cast<ModelAPI_AttributeRefAttr, ModelAPI_Attribute>;
198 %template(modelAPI_AttributeBoolean)       shared_ptr_cast<ModelAPI_AttributeBoolean, ModelAPI_Attribute>;
199 %template(modelAPI_AttributeSelection)     shared_ptr_cast<ModelAPI_AttributeSelection, ModelAPI_Attribute>;
200 %template(modelAPI_AttributeSelectionList) shared_ptr_cast<ModelAPI_AttributeSelectionList, ModelAPI_Attribute>;
201 %template(modelAPI_AttributeRefList)       shared_ptr_cast<ModelAPI_AttributeRefList, ModelAPI_Attribute>;
202 %template(modelAPI_AttributeRefAttrList)   shared_ptr_cast<ModelAPI_AttributeRefAttrList, ModelAPI_Attribute>;
203 %template(modelAPI_AttributeTables)        shared_ptr_cast<ModelAPI_AttributeTables, ModelAPI_Attribute>;
204
205 %template(PointList) std::list<std::shared_ptr<GeomAPI_Pnt> >;
206 %template(PointSet) std::set<std::shared_ptr<GeomAPI_Pnt> >;
207
208 // Geometry casts
209 %template(shapeToEdge) shared_ptr_cast<GeomAPI_Edge, GeomAPI_Shape>;
210
211 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
212 %template(featureToPresentation) shared_ptr_cast<GeomAPI_IPresentable, ModelAPI_Feature>;