X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingDataArrayTypemaps.i;h=27c4949e0fbc94bc154c93e601adee5dfb28b753;hb=e95ee11e7df126315ffd11c2518b648a6915ad51;hp=f6d8969d489dd95a3809bc1f58b162e0b05fb437;hpb=ffb8188e28b2b60ee207a8644286821bc4e8fcdc;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i index f6d8969d4..27c4949e0 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2020 CEA/DEN, EDF R&D +// Copyright (C) 2007-2021 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 @@ -681,6 +681,27 @@ static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair > >& arr) +{ + const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !"; + if(PyList_Check(pyLi)) + { + std::size_t size=PyList_Size(pyLi); + arr.resize(size); + for(std::size_t i = 0 ; i < size ; ++i) + convertPyToVectorPairInt(PyList_GetItem(pyLi,i),arr[i]); + } + else if(PyTuple_Check(pyLi)) + { + std::size_t size=PyTuple_Size(pyLi); + arr.resize(size); + for(std::size_t i = 0 ; i < size ; ++i) + convertPyToVectorPairInt(PyTuple_GetItem(pyLi,i),arr[i]); + } + else + throw INTERP_KERNEL::Exception(msg); +} + static void convertPyToVectorPairStringInt(PyObject *pyLi, std::vector< std::pair >& arr) { const char msg[]="convertPyToVectorPairStringInt : list must contain tuples of 2 integers only or tuple must contain tuples of 1 string and 1 integer only !"; @@ -1389,6 +1410,17 @@ static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, cons throw INTERP_KERNEL::Exception("convertFromPyObjVectorOfObj : not a list nor a tuple"); } +//convertFromVectorAutoObjToPyObj(inpv,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh) +template +static PyObject *convertFromVectorAutoObjToPyObj(std::vector< MCAuto >& inpVector, swig_type_info *ty) +{ + std::size_t sz(inpVector.size()); + PyObject *ret = PyList_New(sz); + for(std::size_t i=0;i cpp int sw=1 * if python list[int] -> cpp vector sw=2 @@ -2033,7 +2065,7 @@ static void convertObjToPossibleCpp6(PyObject *value, mcIdType& sw, char& cTyp, { vsType[i]=convertPyObjectToStr(o); } - catch(INTERP_KERNEL::Exception& e) + catch(INTERP_KERNEL::Exception& ) { std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not a string ! only tuples of strings accepted !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -2053,7 +2085,7 @@ static void convertObjToPossibleCpp6(PyObject *value, mcIdType& sw, char& cTyp, { vsType[i]=convertPyObjectToStr(o); } - catch(INTERP_KERNEL::Exception& e) + catch(INTERP_KERNEL::Exception& ) { std::ostringstream oss; oss << "List as been detected but element #" << i << " is not a string ! only tuples of strings accepted !"; throw INTERP_KERNEL::Exception(oss.str().c_str());