From: Anthony Geay Date: Tue, 7 Mar 2017 16:31:26 +0000 (+0100) Subject: More swig compliant X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f4b976e6d8439d6c322d023bebe7ff8cc354f3d4;p=tools%2Fmedcoupling.git More swig compliant --- diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 80448bf9b..7add2d533 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -171,9 +171,6 @@ def MEDCouplingMEDFileIntFieldMultiTSnew(cls,*args): def MEDCouplingMEDFileParametersnew(cls,*args): import _MEDLoader return _MEDLoader.MEDFileParameters____new___(cls,args) -def ReadField(*args): - import _MEDLoader - return _MEDLoader.ReadFieldSwig(args) %} %include "MEDCouplingFinalize.i" diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index ec163ff93..3725a37ba 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -358,6 +358,7 @@ namespace MEDCoupling %rename (GetTypesOfField) GetTypesOfFieldSwig; %rename (ReadUMeshFromGroups) ReadUMeshFromGroupsSwig; %rename (ReadUMeshFromFamilies) ReadUMeshFromFamiliesSwig; +%rename (ReadField) ReadFieldSwig; %inline { @@ -371,61 +372,29 @@ namespace MEDCoupling PyTuple_SetItem(ret,2,SWIG_From_int(release)); return ret; } + + MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(const std::string& fileName) throw(INTERP_KERNEL::Exception) + { + MCAuto ret(MEDCoupling::ReadField(fileName)); + return ret.retn(); + } + + MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) + { + MCAuto ret(MEDCoupling::ReadField(fileName,fieldName)); + return ret.retn(); + } - MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(PyObject *elt0) throw(INTERP_KERNEL::Exception) + MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(const std::string& fileName, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) { - const char MSG[]="Invalid call ReadField !\n Supported are :\n - ReadField(fileName)\n - ReadField(fileName,fieldName)\n - ReadField(fileName,fieldName,iteration,order)\n - ReadField(type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order)"; - if(!elt0 || !PyTuple_Check(elt0)) - throw INTERP_KERNEL::Exception(MSG); - int sz(PyTuple_Size(elt0)); - if(sz==1) - { - PyObject *o0(PyTuple_GetItem(elt0,0)); - if(PyString_Check(o0)) - { - std::string st(PyString_AsString(o0)); - MCAuto ret(MEDCoupling::ReadField(st)); - return ret.retn(); - } - throw INTERP_KERNEL::Exception(MSG); - } - if(sz==2) - { - PyObject *o0(PyTuple_GetItem(elt0,0)),*o1(PyTuple_GetItem(elt0,1)); - if(PyString_Check(o0) && PyString_Check(o1)) - { - std::string st0(PyString_AsString(o0)),st1(PyString_AsString(o1)); - MCAuto ret(MEDCoupling::ReadField(st0,st1)); - return ret.retn(); - } - throw INTERP_KERNEL::Exception(MSG); - } - if(sz==4) - { - PyObject *o0(PyTuple_GetItem(elt0,0)),*o1(PyTuple_GetItem(elt0,1)),*o2(PyTuple_GetItem(elt0,2)),*o3(PyTuple_GetItem(elt0,3)); - if(PyString_Check(o0) && PyString_Check(o1) && PyInt_Check(o2) && PyInt_Check(o3)) - { - std::string st0(PyString_AsString(o0)),st1(PyString_AsString(o1)); - int a((int)PyInt_AS_LONG(o2)),b((int)PyInt_AS_LONG(o3)); - MCAuto ret(MEDCoupling::ReadField(st0,st1,a,b)); - return ret.retn(); - } - throw INTERP_KERNEL::Exception(MSG); - } - if(sz==7) - { - PyObject *o0(PyTuple_GetItem(elt0,0)),*o1(PyTuple_GetItem(elt0,1)),*o2(PyTuple_GetItem(elt0,2)),*o3(PyTuple_GetItem(elt0,3)),*o4(PyTuple_GetItem(elt0,4)),*o5(PyTuple_GetItem(elt0,5)),*o6(PyTuple_GetItem(elt0,6)); - if(PyInt_Check(o0) && PyString_Check(o1) && PyString_Check(o2) && PyInt_Check(o3) && PyString_Check(o4) && PyInt_Check(o5) && PyInt_Check(o6)) - { - int a((int)PyInt_AS_LONG(o0)),b((int)PyInt_AS_LONG(o3)),c((int)PyInt_AS_LONG(o5)),d((int)PyInt_AS_LONG(o6)); - MEDCoupling::TypeOfField aa((MEDCoupling::TypeOfField)a); - std::string st0(PyString_AsString(o1)),st1(PyString_AsString(o2)),st2(PyString_AsString(o4)); - MCAuto ret(MEDCoupling::ReadField(aa,st0,st1,b,st2,c,d)); - return ret.retn(); - } - throw INTERP_KERNEL::Exception(MSG); - } - throw INTERP_KERNEL::Exception(MSG); + MCAuto ret(MEDCoupling::ReadField(fileName,fieldName,iteration,order)); + return ret.retn(); + } + + MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) + { + MCAuto ret(MEDCoupling::ReadField(type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order)); + return ret.retn(); } PyObject *GetFieldIterationsSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)