]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
More swig compliant agy/EasyReadField
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 7 Mar 2017 16:31:26 +0000 (17:31 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 7 Mar 2017 16:31:26 +0000 (17:31 +0100)
src/MEDLoader/Swig/MEDLoader.i
src/MEDLoader/Swig/MEDLoaderCommon.i

index 80448bf9b5ff4774473729a30bffba8ac6fd9e32..7add2d533890d2d68827860152f3bb48767d9d5a 100644 (file)
@@ -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"
index ec163ff934c889c88191d6d39496e8ae7494b299..3725a37ba68d794e51ce7d4eaeead7770d5ef969 100644 (file)
@@ -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<MEDCoupling::MEDCouplingFieldDouble> ret(MEDCoupling::ReadField(fileName));
+    return ret.retn();
+  }
+
+  MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
+  {
+    MCAuto<MEDCoupling::MEDCouplingFieldDouble> 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<MEDCouplingFieldDouble> 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<MEDCouplingFieldDouble> 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<MEDCouplingFieldDouble> 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<MEDCouplingFieldDouble> ret(MEDCoupling::ReadField(aa,st0,st1,b,st2,c,d));
-            return ret.retn();
-          }
-        throw INTERP_KERNEL::Exception(MSG);
-      }
-    throw INTERP_KERNEL::Exception(MSG);
+    MCAuto<MEDCoupling::MEDCouplingFieldDouble> 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<MEDCoupling::MEDCouplingFieldDouble> 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)