X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI.i;h=e5113a5c2fea4df2c8dcad75153abfaab8196014;hb=3f6a02c80da84b8356412858b060ba22e3148fd7;hp=dbcb59eaf3cccc62f13c0bdf06c36dcc3a45a2ea;hpb=af168c107750e3c62fc487ae55b3ac9a1ab67435;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index dbcb59eaf..e5113a5c2 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -1,86 +1,209 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + /* ModelAPI.i */ -%module ModelAPI +%module(directors="1") ModelAPI +%feature("director:except") { + if ($error != NULL) { + PyErr_Print(); + std::cerr << std::endl; + throw Swig::DirectorMethodException(); + } +} + %{ - #include "GeomAPI_Interface.h" - #include "GeomAPI_Shape.h" - #include "ModelAPI.h" - #include "ModelAPI_Document.h" - #include "ModelAPI_PluginManager.h" - #include "ModelAPI_Object.h" - #include "ModelAPI_Feature.h" - #include "ModelAPI_Data.h" - #include "ModelAPI_Attribute.h" - #include "ModelAPI_AttributeDocRef.h" - #include "ModelAPI_AttributeDouble.h" - #include "ModelAPI_AttributeInteger.h" - #include "ModelAPI_AttributeString.h" - #include "ModelAPI_AttributeReference.h" - #include "ModelAPI_AttributeRefAttr.h" - #include "ModelAPI_Validator.h" - #include "ModelAPI_AttributeRefList.h" - #include "ModelAPI_Result.h" - #include "ModelAPI_ResultConstruction.h" - - template boost::shared_ptr castTo(boost::shared_ptr theObject) - { - return boost::dynamic_pointer_cast(theObject); - } - - + #include "ModelAPI_swig.h" + + // fix for SWIG v2.0.4 + #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) %} +// import other modules +%import "GeomAPI.i" + // to avoid error on this #define MODELAPI_EXPORT -#define GEOMAPI_EXPORT // standard definitions %include "typemaps.i" %include "std_string.i" %include "std_list.i" +%include "std_shared_ptr.i" +%include "std_set.i" + +// directors +%feature("director") ModelAPI_Plugin; +%feature("director") ModelAPI_Object; +%feature("director") ModelAPI_Feature; +%feature("director") ModelAPI_CompositeFeature; +%feature("director") ModelAPI_Data; +%feature("director") ModelAPI_Folder; -// boost pointers -%include +// shared pointers // For ModelAPI_ResultConstruction.shape() -%shared_ptr(GeomAPI_Interface) -%shared_ptr(GeomAPI_Shape) +%shared_ptr(ModelAPI_Entity) %shared_ptr(ModelAPI_Document) -%shared_ptr(ModelAPI_PluginManager) +%shared_ptr(ModelAPI_Session) +%shared_ptr(ModelAPI_Plugin) %shared_ptr(ModelAPI_Object) %shared_ptr(ModelAPI_Feature) +%shared_ptr(ModelAPI_CompositeFeature) %shared_ptr(ModelAPI_Data) +%shared_ptr(ModelAPI_Folder) %shared_ptr(ModelAPI_Attribute) %shared_ptr(ModelAPI_AttributeDocRef) %shared_ptr(ModelAPI_AttributeDouble) +%shared_ptr(ModelAPI_AttributeDoubleArray) %shared_ptr(ModelAPI_AttributeInteger) +%shared_ptr(ModelAPI_AttributeIntArray) %shared_ptr(ModelAPI_AttributeString) +%shared_ptr(ModelAPI_AttributeStringArray) %shared_ptr(ModelAPI_AttributeReference) %shared_ptr(ModelAPI_AttributeRefAttr) %shared_ptr(ModelAPI_AttributeRefList) +%shared_ptr(ModelAPI_AttributeRefAttrList) +%shared_ptr(ModelAPI_AttributeBoolean) +%shared_ptr(ModelAPI_AttributeSelection) +%shared_ptr(ModelAPI_AttributeSelectionList) +%shared_ptr(ModelAPI_AttributeTables) +%shared_ptr(ModelAPI_Validator) +%shared_ptr(ModelAPI_AttributeValidator) +%shared_ptr(ModelAPI_FeatureValidator) %shared_ptr(ModelAPI_Result) %shared_ptr(ModelAPI_ResultConstruction) +%shared_ptr(ModelAPI_ResultBody) +%shared_ptr(ModelAPI_ResultPart) +%shared_ptr(ModelAPI_ResultGroup) +%shared_ptr(ModelAPI_ResultField) +%shared_ptr(ModelAPI_ResultParameter) +%shared_ptr(ModelAPI_ResultCompSolid) + +%typecheck(SWIG_TYPECHECK_POINTER) const ModelAPI_AttributeTables::Value { + $1 = (PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input) || PyBool_Check($input)) ? 1 : 0; +} + +// Tables Value reading as int, double, boolean or string +%typemap(in) const ModelAPI_AttributeTables::Value { + if (PyLong_Check($input)) { + $1.myInt = int(PyLong_AsLong($input)); + $1.myDouble = double(PyLong_AsLong($input)); + $1.myBool = PyLong_AsLong($input) != 0; + } else if (PyFloat_Check($input)) { + $1.myInt = int(PyFloat_AsDouble($input)); + $1.myDouble = PyFloat_AsDouble($input); + } else if (PyBool_Check($input)) { + $1.myBool = $input == Py_True; + } else if (PyUnicode_Check($input)) { + $1.myStr = PyUnicode_AsUTF8($input); + } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { + } else { + PyErr_SetString(PyExc_ValueError, "Tables value must be int, double, string or bool."); + return NULL; + } +} + +%apply int& OUTPUT {int& theIndexInFolder}; // all supported interfaces -%include "GeomAPI_Interface.h" -%include "GeomAPI_Shape.h" +%include "ModelAPI_Entity.h" %include "ModelAPI_Document.h" -%include "ModelAPI_PluginManager.h" +%include "ModelAPI_Session.h" +%include "ModelAPI_Plugin.h" %include "ModelAPI_Object.h" %include "ModelAPI_Feature.h" +%include "ModelAPI_CompositeFeature.h" %include "ModelAPI_Data.h" %include "ModelAPI_Attribute.h" %include "ModelAPI_AttributeDocRef.h" %include "ModelAPI_AttributeDouble.h" +%include "ModelAPI_AttributeDoubleArray.h" %include "ModelAPI_AttributeInteger.h" +%include "ModelAPI_AttributeIntArray.h" %include "ModelAPI_AttributeString.h" +%include "ModelAPI_AttributeStringArray.h" %include "ModelAPI_AttributeReference.h" %include "ModelAPI_AttributeRefAttr.h" -%include "ModelAPI_Validator.h" +%include "ModelAPI_AttributeBoolean.h" +%include "ModelAPI_AttributeSelection.h" +%include "ModelAPI_AttributeSelectionList.h" %include "ModelAPI_AttributeRefList.h" +%include "ModelAPI_AttributeRefAttrList.h" +%include "ModelAPI_AttributeTables.h" +%include "ModelAPI_Validator.h" +%include "ModelAPI_AttributeValidator.h" +%include "ModelAPI_FeatureValidator.h" %include "ModelAPI_Result.h" %include "ModelAPI_ResultConstruction.h" +%include "ModelAPI_ResultBody.h" +%include "ModelAPI_ResultPart.h" +%include "ModelAPI_ResultGroup.h" +%include "ModelAPI_ResultField.h" +%include "ModelAPI_ResultParameter.h" +%include "ModelAPI_Tools.h" +%include "ModelAPI_Folder.h" + +// std::list -> [] +%template(StringList) std::list; +%template(ObjectList) std::list >; +%template(FeatureList) std::list >; +%template(ResultList) std::list >; +%template(DocumentList) std::list >; +// std::set -> [] +%template(AttributeSet) std::set >; +%template(FeatureSet) std::set >; + +// std::dynamic_pointer_cast +template std::shared_ptr shared_ptr_cast(std::shared_ptr theObject); +%template(featureToCompositeFeature) shared_ptr_cast; +%template(objectToFeature) shared_ptr_cast; +%template(objectToResult) shared_ptr_cast; +%template(objectToFolder) shared_ptr_cast; +%template(compositeFeatureToFeature) shared_ptr_cast; + +%template(modelAPI_Result) shared_ptr_cast; +%template(modelAPI_ResultConstruction) shared_ptr_cast; +%template(modelAPI_ResultBody) shared_ptr_cast; +%template(modelAPI_ResultPart) shared_ptr_cast; +%template(modelAPI_ResultParameter) shared_ptr_cast; +%template(modelAPI_ResultGroup) shared_ptr_cast; +%template(modelAPI_ResultField) shared_ptr_cast; + +// Attribute casts +%template(modelAPI_AttributeDocRef) shared_ptr_cast; +%template(modelAPI_AttributeDouble) shared_ptr_cast; +%template(modelAPI_AttributeDoubleArray) shared_ptr_cast; +%template(modelAPI_AttributeInteger) shared_ptr_cast; +%template(modelAPI_AttributeIntArray) shared_ptr_cast; +%template(modelAPI_AttributeString) shared_ptr_cast; +%template(modelAPI_AttributeStringArray) shared_ptr_cast; +%template(modelAPI_AttributeReference) shared_ptr_cast; +%template(modelAPI_AttributeRefAttr) shared_ptr_cast; +%template(modelAPI_AttributeBoolean) shared_ptr_cast; +%template(modelAPI_AttributeSelection) shared_ptr_cast; +%template(modelAPI_AttributeSelectionList) shared_ptr_cast; +%template(modelAPI_AttributeRefList) shared_ptr_cast; +%template(modelAPI_AttributeRefAttrList) shared_ptr_cast; +%template(modelAPI_AttributeTables) shared_ptr_cast; -%template(ObjectList) std::list >; -%template(ResultList) std::list >; +%template(PointList) std::list >; +%template(PointSet) std::set >; -template boost::shared_ptr castTo(boost::shared_ptr theObject); -%template(modelAPI_ResultConstruction) castTo; +// Geometry casts +%template(shapeToEdge) shared_ptr_cast;