X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingRemapperCommon.i;h=7f3ce423991857c16baca20c425feb2a7966266b;hb=5b299d506fcc63ff652df59a13f5b082fd45dabf;hp=a88c0b46892197dde0560c4bc7f5dfdb5539bb8e;hpb=698359a588c085076572d21169c675da74f12e48;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperCommon.i b/src/MEDCoupling_Swig/MEDCouplingRemapperCommon.i index a88c0b468..7f3ce4239 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperCommon.i @@ -88,11 +88,34 @@ namespace MEDCoupling return ToCSRMatrix(self->getCrudeMatrix(),self->getNumberOfColsOfMatrix()); } #endif - void setMatrix(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method, PyObject *m) throw(INTERP_KERNEL::Exception) + void setCrudeMatrix(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method, PyObject *m) throw(INTERP_KERNEL::Exception) + { + std::vector > mCpp; + if(isCSRMatrix(m)) + { +#if defined(WITH_NUMPY) && defined(WITH_SCIPY) + PyObject *indptr(PyObject_GetAttrString(m,"indptr")); + PyObject *indices(PyObject_GetAttrString(m,"indices")); + PyObject *data(PyObject_GetAttrString(m,"data")); + MCAuto indptrPtr(MEDCoupling_DataArrayInt_New__SWIG_1(indptr,NULL,NULL)); + MCAuto indicesPtr(MEDCoupling_DataArrayInt_New__SWIG_1(indices,NULL,NULL)); + MCAuto dataPtr(MEDCoupling_DataArrayDouble_New__SWIG_1(data,NULL,NULL)); + convertCSR_MCDataToVectMapIntDouble(indptrPtr,indicesPtr,dataPtr,mCpp); + Py_XDECREF(data); Py_XDECREF(indptr); Py_XDECREF(indices); +#else + throw INTERP_KERNEL::Exception("pywrap of MEDCouplingRemapper::setCrudeMatrix : unexpected situation regarding numpy/scipy !"); +#endif + } + else + convertToVectMapIntDouble(m,mCpp); + self->setCrudeMatrix(srcMesh,targetMesh,method,mCpp); + } + + void setCrudeMatrixEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target, PyObject *m) throw(INTERP_KERNEL::Exception) { std::vector > mCpp; convertToVectMapIntDouble(m,mCpp); - self->setMatrix(srcMesh,targetMesh,method,mCpp); + self->setCrudeMatrixEx(src,target,mCpp); } } };