X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI.i;h=4eb97f97904a310c1155ee6d24d81666f14a58e0;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=71c5a05db255f81b91df106cb17bac1aff6e8704;hpb=3958bd83bc41c4c9bddbbbba375dd187e2363044;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI.i b/src/GeomAlgoAPI/GeomAlgoAPI.i index 71c5a05db..4eb97f979 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI.i +++ b/src/GeomAlgoAPI/GeomAlgoAPI.i @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,16 +12,25 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* GeomAPI.i */ %module GeomAlgoAPI %{ #include "GeomAlgoAPI_swig.h" + +// fix for SWIG v4.1.1 +#if PY_VERSION_HEX >= 0x03020000 +# define SWIGPY_SLICEOBJECT PyObject +#else +# define SWIGPY_SLICEOBJECT PySliceObject +#endif + +// fix for SWIG v2.0.4 +#define SWIGPY_SLICE_ARG(obj) ((SWIGPY_SLICEOBJECT*)(obj)) %} // import other modules @@ -35,6 +44,121 @@ %include "std_string.i" %include "std_list.i" %include "std_shared_ptr.i" +%include "std_vector.i" + +%exceptionclass GeomAlgoAPI_Exception; + +%exception { + try { + $action + } + catch (GeomAlgoAPI_Exception exc) { + // Reraise with SWIG_Python_Raise + SWIG_Python_Raise(SWIG_NewPointerObj((new GeomAlgoAPI_Exception(static_cast< const GeomAlgoAPI_Exception& >(exc))), SWIGTYPE_p_GeomAlgoAPI_Exception, SWIG_POINTER_OWN), "GeomAlgoAPI_Exception", SWIGTYPE_p_GeomAlgoAPI_Exception); + SWIG_fail; + } +} + +%typemap(out) std::list< std::shared_ptr< GeomAPI_Shape > >::value_type & { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(*$1)), $descriptor(std::shared_ptr *), SWIG_POINTER_OWN | 0 ); +} + +%template(ShapeList) std::list >; +%template(ValuesList) std::list; +%template(VectorOfDouble) std::vector; + +%typemap(in) std::vector& (std::vector temp) { + if (PyList_Check($input)) { + for (Py_ssize_t i = 0; i < PyList_Size($input); ++i) { + PyObject * item = PySequence_GetItem($input, i); + if (PyNumber_Check(item)) { + temp.push_back(PyFloat_AsDouble(item)); + } else { + PyErr_SetString(PyExc_TypeError, "argument must be double value."); + return NULL; + } + Py_DECREF(item); + } + $1 = &temp; + } else { + PyErr_SetString(PyExc_ValueError, "argument must be a list of double values."); + return NULL; + } +} + +%typemap(argout) std::vector& { + PyObject* outList = PyList_New(0); + int error; + std::vector::iterator it; + for ( it=$1->begin() ; it != $1->end(); it++ ) + { + error = PyList_Append(outList, PyFloat_FromDouble(*it)); + if (error) + SWIG_fail; + } + if ((!$result) || ($result == Py_None)) { + $result = outList; + } else { + PyObject *aObj1, *aObj2; + if (!PyTuple_Check($result)) { + PyObject* aObj = $result; + $result = PyTuple_New(1); + PyTuple_SetItem($result,0,aObj); + } + aObj2 = PyTuple_New(1); + PyTuple_SetItem(aObj2,0,outList); + aObj1 = $result; + $result = PySequence_Concat(aObj1,aObj2); + Py_DECREF(aObj1); + Py_DECREF(aObj2); + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) std::vector, const std::vector& { + if (PyTuple_Check($input)) { + for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) { + PyObject * item = PySequence_GetItem($input, i); + if (PyNumber_Check(item)) { + $1 = 1; + } else { + $1 = 0; + break; + } + Py_DECREF(item); + } + } else { + $1 = 0; + } +} + +%typemap(in) double& (double temp) { + if (PyFloat_Check($input)) { + temp = PyFloat_AsDouble($input); + $1 = &temp; + } else { + PyErr_SetString(PyExc_ValueError, "argument must be a double value."); + return NULL; + } +} + +%typemap(argout) double& { + if ((!$result) || ($result == Py_None)) { + $result = PyFloat_FromDouble(*$1); + } else { + PyObject *aObj1, *aObj2; + if (!PyTuple_Check($result)) { + PyObject* aObj = $result; + $result = PyTuple_New(1); + PyTuple_SetItem($result,0,aObj); + } + aObj2 = PyTuple_New(1); + PyTuple_SetItem(aObj2,0,PyFloat_FromDouble(*$1)); + aObj1 = $result; + $result = PySequence_Concat(aObj1,aObj2); + Py_DECREF(aObj1); + Py_DECREF(aObj2); + } +} // shared pointers %shared_ptr(GeomAlgoAPI_Boolean) @@ -50,6 +174,7 @@ %shared_ptr(GeomAlgoAPI_Revolution) %shared_ptr(GeomAlgoAPI_Rotation) %shared_ptr(GeomAlgoAPI_Sewing) +%shared_ptr(GeomAlgoAPI_SketchBuilder) %shared_ptr(GeomAlgoAPI_ShapeBuilder) %shared_ptr(GeomAlgoAPI_Translation) %shared_ptr(GeomAlgoAPI_Transform) @@ -57,17 +182,22 @@ %shared_ptr(GeomAlgoAPI_ConeSegment) %shared_ptr(GeomAlgoAPI_Copy) %shared_ptr(GeomAlgoAPI_Symmetry) +%shared_ptr(GeomAlgoAPI_MapShapesAndAncestors) +%shared_ptr(GeomAlgoAPI_WireBuilder) // all supported interfaces %include "GeomAlgoAPI_MakeShape.h" %include "GeomAlgoAPI_Boolean.h" +%include "GeomAlgoAPI_Circ2dBuilder.h" %include "GeomAlgoAPI_CompoundBuilder.h" +%include "GeomAlgoAPI_CurveBuilder.h" %include "GeomAlgoAPI_DFLoader.h" %include "GeomAlgoAPI_EdgeBuilder.h" %include "GeomAlgoAPI_FaceBuilder.h" %include "GeomAlgoAPI_MakeShapeCustom.h" %include "GeomAlgoAPI_MakeShapeList.h" %include "GeomAlgoAPI_MakeSweep.h" +%include "GeomAlgoAPI_Transform.h" %include "GeomAlgoAPI_Translation.h" %include "GeomAlgoAPI_Placement.h" %include "GeomAlgoAPI_PointBuilder.h" @@ -83,7 +213,6 @@ %include "GeomAlgoAPI_IGESImport.h" %include "GeomAlgoAPI_STEPImport.h" %include "GeomAlgoAPI_Tools.h" -%include "GeomAlgoAPI_Transform.h" %include "GeomAlgoAPI_PaveFiller.h" %include "GeomAlgoAPI_Intersection.h" %include "GeomAlgoAPI_Pipe.h" @@ -95,8 +224,6 @@ %include "GeomAlgoAPI_Copy.h" %include "GeomAlgoAPI_Symmetry.h" %include "GeomAlgoAPI_Box.h" - -%typemap(out) std::list< std::shared_ptr< GeomAPI_Shape > >::value_type & { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(*$1)), $descriptor(std::shared_ptr *), SWIG_POINTER_OWN | 0 ); -} -%template(ShapeList) std::list >; +%include "GeomAlgoAPI_MapShapesAndAncestors.h" +%include "GeomAlgoAPI_ShapeInfo.h" +%include "GeomAlgoAPI_CanonicalRecognition.h"