1 // Copyright (C) 2014-2024 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 %module(directors="1") ModelAPI
22 %feature("director:except") {
25 std::cerr << std::endl;
26 throw Swig::DirectorMethodException();
31 #include "ModelAPI_swig.h"
33 // fix for SWIG v4.1.1
34 #if PY_VERSION_HEX >= 0x03020000
35 # define SWIGPY_SLICEOBJECT PyObject
37 # define SWIGPY_SLICEOBJECT PySliceObject
40 // fix for SWIG v2.0.4
41 #define SWIGPY_SLICE_ARG(obj) ((SWIGPY_SLICEOBJECT*)(obj))
42 #define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj))
45 // import other modules
49 // to avoid error on this
50 #define MODELAPI_EXPORT
52 // standard definitions
54 %include "std_shared_ptr.i"
58 %feature("director") ModelAPI_Plugin;
59 %feature("director") ModelAPI_Object;
60 %feature("director") ModelAPI_Feature;
61 %feature("director") ModelAPI_CompositeFeature;
62 %feature("director") ModelAPI_Data;
63 %feature("director") ModelAPI_Folder;
64 %feature("director") ModelAPI_Filter;
67 // For ModelAPI_ResultConstruction.shape()
68 %shared_ptr(ModelAPI_Entity)
69 %shared_ptr(ModelAPI_Document)
70 %shared_ptr(ModelAPI_Session)
71 %shared_ptr(ModelAPI_Plugin)
72 %shared_ptr(ModelAPI_Object)
73 %shared_ptr(ModelAPI_Feature)
74 %shared_ptr(ModelAPI_CompositeFeature)
75 %shared_ptr(ModelAPI_Data)
76 %shared_ptr(ModelAPI_Filter)
77 %shared_ptr(ModelAPI_FiltersFeature)
78 %shared_ptr(ModelAPI_Folder)
79 %shared_ptr(ModelAPI_Attribute)
80 %shared_ptr(ModelAPI_AttributeDocRef)
81 %shared_ptr(ModelAPI_AttributeDouble)
82 %shared_ptr(ModelAPI_AttributeDoubleArray)
83 %shared_ptr(ModelAPI_AttributeInteger)
84 %shared_ptr(ModelAPI_AttributeIntArray)
85 %shared_ptr(ModelAPI_AttributeString)
86 %shared_ptr(ModelAPI_AttributeStringArray)
87 %shared_ptr(ModelAPI_AttributeReference)
88 %shared_ptr(ModelAPI_AttributeRefAttr)
89 %shared_ptr(ModelAPI_AttributeRefList)
90 %shared_ptr(ModelAPI_AttributeRefAttrList)
91 %shared_ptr(ModelAPI_AttributeBoolean)
92 %shared_ptr(ModelAPI_AttributeSelection)
93 %shared_ptr(ModelAPI_AttributeSelectionList)
94 %shared_ptr(ModelAPI_AttributeTables)
95 %shared_ptr(ModelAPI_Validator)
96 %shared_ptr(ModelAPI_AttributeValidator)
97 %shared_ptr(ModelAPI_FeatureValidator)
98 %shared_ptr(ModelAPI_Result)
99 %shared_ptr(ModelAPI_ResultConstruction)
100 %shared_ptr(ModelAPI_ResultBody)
101 %shared_ptr(ModelAPI_ResultPart)
102 %shared_ptr(ModelAPI_ResultGroup)
103 %shared_ptr(ModelAPI_ResultField)
104 %shared_ptr(ModelAPI_ResultParameter)
105 %shared_ptr(ModelAPI_ResultCompSolid)
107 %typecheck(SWIG_TYPECHECK_POINTER) const ModelAPI_AttributeTables::Value {
108 $1 = (PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input) || PyBool_Check($input)) ? 1 : 0;
111 // Tables Value reading as int, double, boolean or string
112 %typemap(in) const ModelAPI_AttributeTables::Value {
113 if (PyLong_Check($input)) {
114 $1.myInt = int(PyLong_AsLong($input));
115 $1.myDouble = double(PyLong_AsLong($input));
116 $1.myBool = PyLong_AsLong($input) != 0;
117 } else if (PyFloat_Check($input)) {
118 $1.myInt = int(PyFloat_AsDouble($input));
119 $1.myDouble = PyFloat_AsDouble($input);
120 } else if (PyBool_Check($input)) {
121 $1.myBool = $input == Py_True;
122 } else if (PyUnicode_Check($input)) {
123 $1.myStr = PyUnicode_AsUTF8($input);
124 } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
126 PyErr_SetString(PyExc_ValueError, "Tables value must be int, double, string or bool.");
131 %apply int& OUTPUT {int& theIndexInFolder};
133 // all supported interfaces
134 %include "ModelAPI_Entity.h"
135 %include "ModelAPI_Events.h"
136 %include "ModelAPI_Document.h"
137 %include "ModelAPI_Session.h"
138 %include "ModelAPI_Plugin.h"
139 %include "ModelAPI_Object.h"
140 %include "ModelAPI_Feature.h"
141 %include "ModelAPI_CompositeFeature.h"
142 %include "ModelAPI_Data.h"
143 %include "ModelAPI_Attribute.h"
144 %include "ModelAPI_AttributeDocRef.h"
145 %include "ModelAPI_AttributeDouble.h"
146 %include "ModelAPI_AttributeDoubleArray.h"
147 %include "ModelAPI_AttributeInteger.h"
148 %include "ModelAPI_AttributeIntArray.h"
149 %include "ModelAPI_AttributeString.h"
150 %include "ModelAPI_AttributeStringArray.h"
151 %include "ModelAPI_AttributeReference.h"
152 %include "ModelAPI_AttributeRefAttr.h"
153 %include "ModelAPI_AttributeBoolean.h"
154 %include "ModelAPI_AttributeSelection.h"
155 %include "ModelAPI_AttributeSelectionList.h"
156 %include "ModelAPI_AttributeRefList.h"
157 %include "ModelAPI_AttributeRefAttrList.h"
158 %include "ModelAPI_AttributeTables.h"
159 %include "ModelAPI_Validator.h"
160 %include "ModelAPI_AttributeValidator.h"
161 %include "ModelAPI_FeatureValidator.h"
162 %include "ModelAPI_Result.h"
163 %include "ModelAPI_ResultConstruction.h"
164 %include "ModelAPI_ResultBody.h"
165 %include "ModelAPI_ResultPart.h"
166 %include "ModelAPI_ResultGroup.h"
167 %include "ModelAPI_ResultField.h"
168 %include "ModelAPI_ResultParameter.h"
169 %include "ModelAPI_Tools.h"
170 %include "ModelAPI_Folder.h"
171 %include "ModelAPI_Filter.h"
172 %include "ModelAPI_FiltersArgs.h"
173 %include "ModelAPI_FiltersFactory.h"
174 %include "ModelAPI_FiltersFeature.h"
177 %template(StringList) std::list<std::string>;
178 %template(AttributeList) std::list<std::shared_ptr<ModelAPI_Attribute> >;
179 %template(ObjectList) std::list<std::shared_ptr<ModelAPI_Object> >;
180 %template(FeatureList) std::list<std::shared_ptr<ModelAPI_Feature> >;
181 %template(ResultList) std::list<std::shared_ptr<ModelAPI_Result> >;
182 %template(DocumentList) std::list<std::shared_ptr<ModelAPI_Document> >;
183 %template(FilterList) std::list<std::shared_ptr<ModelAPI_Filter> >;
185 %template(AttributeSet) std::set<std::shared_ptr<ModelAPI_Attribute> >;
186 %template(FeatureSet) std::set<std::shared_ptr<ModelAPI_Feature> >;
187 %template(ObjectSet) std::set<std::shared_ptr<ModelAPI_Object> >;
189 // std::dynamic_pointer_cast
190 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
191 %template(featureToCompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
192 %template(objectToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
193 %template(objectToResult) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
194 %template(objectToFolder) shared_ptr_cast<ModelAPI_Folder, ModelAPI_Object>;
195 %template(compositeFeatureToFeature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_CompositeFeature>;
197 %template(modelAPI_Result) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
198 %template(modelAPI_ResultConstruction) shared_ptr_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
199 %template(modelAPI_ResultBody) shared_ptr_cast<ModelAPI_ResultBody, ModelAPI_Result>;
200 %template(modelAPI_ResultPart) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_Result>;
201 %template(modelAPI_ResultParameter) shared_ptr_cast<ModelAPI_ResultParameter, ModelAPI_Result>;
202 %template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultGroup, ModelAPI_Result>;
203 %template(modelAPI_ResultField) shared_ptr_cast<ModelAPI_ResultField, ModelAPI_Result>;
206 ModelAPI_ObjectUpdatedMessage* messageToUpdatedMessage(std::shared_ptr<Events_Message> msg) {
207 return static_cast<ModelAPI_ObjectUpdatedMessage*>(msg.get());
212 %template(modelAPI_AttributeDocRef) shared_ptr_cast<ModelAPI_AttributeDocRef, ModelAPI_Attribute>;
213 %template(modelAPI_AttributeDouble) shared_ptr_cast<ModelAPI_AttributeDouble, ModelAPI_Attribute>;
214 %template(modelAPI_AttributeDoubleArray) shared_ptr_cast<ModelAPI_AttributeDoubleArray, ModelAPI_Attribute>;
215 %template(modelAPI_AttributeInteger) shared_ptr_cast<ModelAPI_AttributeInteger, ModelAPI_Attribute>;
216 %template(modelAPI_AttributeIntArray) shared_ptr_cast<ModelAPI_AttributeIntArray, ModelAPI_Attribute>;
217 %template(modelAPI_AttributeString) shared_ptr_cast<ModelAPI_AttributeString, ModelAPI_Attribute>;
218 %template(modelAPI_AttributeStringArray) shared_ptr_cast<ModelAPI_AttributeStringArray, ModelAPI_Attribute>;
219 %template(modelAPI_AttributeReference) shared_ptr_cast<ModelAPI_AttributeReference, ModelAPI_Attribute>;
220 %template(modelAPI_AttributeRefAttr) shared_ptr_cast<ModelAPI_AttributeRefAttr, ModelAPI_Attribute>;
221 %template(modelAPI_AttributeBoolean) shared_ptr_cast<ModelAPI_AttributeBoolean, ModelAPI_Attribute>;
222 %template(modelAPI_AttributeSelection) shared_ptr_cast<ModelAPI_AttributeSelection, ModelAPI_Attribute>;
223 %template(modelAPI_AttributeSelectionList) shared_ptr_cast<ModelAPI_AttributeSelectionList, ModelAPI_Attribute>;
224 %template(modelAPI_AttributeRefList) shared_ptr_cast<ModelAPI_AttributeRefList, ModelAPI_Attribute>;
225 %template(modelAPI_AttributeRefAttrList) shared_ptr_cast<ModelAPI_AttributeRefAttrList, ModelAPI_Attribute>;
226 %template(modelAPI_AttributeTables) shared_ptr_cast<ModelAPI_AttributeTables, ModelAPI_Attribute>;
228 %template(PointList) std::list<std::shared_ptr<GeomAPI_Pnt> >;
229 %template(PointSet) std::set<std::shared_ptr<GeomAPI_Pnt> >;
231 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
232 %template(featureToPresentation) shared_ptr_cast<GeomAPI_IPresentable, ModelAPI_Feature>;