Salome HOME
medcoupling documentation modification
[tools/medcoupling.git] / src / MEDLoader / Swig / MEDLoaderCommon.i
index b2694f7e627b1c1bb1b3256ad5de73f26acb6ea6..c6630e17930354888e81c22febe1931c40f49400 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2017  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
@@ -18,8 +18,6 @@
 //
 // Author : Anthony Geay (EDF R&D)
 
-%module MEDLoader
-
 #define MEDCOUPLING_EXPORT
 #define MEDLOADER_EXPORT
 
@@ -162,6 +160,7 @@ using namespace MEDCoupling;
 %newobject MEDCoupling::MEDFileFields::partOfThisOnStructureElements;
 %newobject MEDCoupling::MEDFileFields::__iter__;
 %newobject MEDCoupling::MEDFileFields::extractPart;
+%newobject MEDCoupling::MEDFileFields::linearToQuadratic;
 
 %newobject MEDCoupling::MEDFileWritableStandAlone::serialize;
 %newobject MEDCoupling::MEDFileAnyTypeFieldMultiTS::New;
@@ -622,24 +621,6 @@ namespace MEDCoupling
          void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception)
          {
          }
-
-         PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
-         {
-#ifdef WITH_NUMPY
-           PyObject *ret(PyTuple_New(1));
-           PyObject *ret0(PyDict_New());
-           DataArrayByte *retCpp(MEDCoupling_MEDFileWritableStandAlone_serialize(self));
-           PyObject *numpyArryObj=SWIG_NewPointerObj(SWIG_as_voidptr(retCpp),SWIGTYPE_p_MEDCoupling__DataArrayByte, SWIG_POINTER_OWN | 0 );
-           {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ...
-             PyObject *tmp1(PyInt_FromLong(0));
-             PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj);
-             PyTuple_SetItem(ret,0,ret0);
-           }
-           return ret;
-#else
-           throw INTERP_KERNEL::Exception("PyWrap of MEDFileData.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !");
-#endif
-         }
        }
   };
   
@@ -1130,6 +1111,7 @@ namespace MEDCoupling
     static std::string GetMagicFamilyStr();
     void assignFamilyNameWithGroupName() throw(INTERP_KERNEL::Exception);
     std::vector<std::string> removeEmptyGroups() throw(INTERP_KERNEL::Exception);
+    void removeGroupAtLevel(int meshDimRelToMaxExt, const std::string& name) throw(INTERP_KERNEL::Exception);
     void removeGroup(const std::string& name) throw(INTERP_KERNEL::Exception);
     void removeFamily(const std::string& name) throw(INTERP_KERNEL::Exception);
     std::vector<std::string> removeOrphanGroups() throw(INTERP_KERNEL::Exception);
@@ -1440,12 +1422,6 @@ namespace MEDCoupling
            return MEDFileUMesh::New();
          }
 
-         // serialization
-         static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-         {
-           return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDFileUMesh");
-         }
-
          static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, PyObject *types, const std::vector<int>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
          {
            std::vector<int> typesCpp1;
@@ -1457,14 +1433,6 @@ namespace MEDCoupling
            return MEDFileUMesh::LoadPartOf(fileName,mName,typesCpp2,slicPerTyp,dt,it,mrs);
          }
 
-         PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
-         {// put an empty dict in input to say to __new__ to call __init__...
-           PyObject *ret(PyTuple_New(1));
-           PyObject *ret0(PyDict_New());
-           PyTuple_SetItem(ret,0,ret0);
-           return ret;
-         }
-
          PyObject *__getstate__() throw(INTERP_KERNEL::Exception)
          {
            std::vector<double> a0;
@@ -1724,12 +1692,6 @@ namespace MEDCoupling
          {
            return MEDFileCMesh::New(db);
          }
-
-         // serialization
-         static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-         {
-           return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileCMesh");
-         }
          
          PyObject *getMesh() const throw(INTERP_KERNEL::Exception)
          {
@@ -1770,12 +1732,6 @@ namespace MEDCoupling
          {
            return MEDFileCurveLinearMesh::New(db);
          }
-
-         // serialization
-         static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-         {
-           return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileCurveLinearMesh");
-         }
          
          PyObject *getMesh() const throw(INTERP_KERNEL::Exception)
          {
@@ -1879,12 +1835,6 @@ namespace MEDCoupling
            return MEDFileMeshes::New(db);
          }
 
-         // serialization
-         static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-         {
-           return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileMeshes");
-         }
-
          std::string __str__() const throw(INTERP_KERNEL::Exception)
            {
              return self->simpleRepr();
@@ -1989,6 +1939,7 @@ namespace MEDCoupling
     void changeLocName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception);
     int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception);
     int getLocalizationId(const std::string& loc) const throw(INTERP_KERNEL::Exception);
+    int getProfileId(const std::string& pfl) const throw(INTERP_KERNEL::Exception);
     void killStructureElementsInGlobs() throw(INTERP_KERNEL::Exception);
   %extend
      {
@@ -2273,6 +2224,7 @@ namespace MEDCoupling
     static MEDFileField1TS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception);
     static MEDFileField1TS *New();
     MEDCoupling::MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
+    void copyTimeInfoFrom(MEDCouplingFieldDouble *mcf) throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
@@ -2282,6 +2234,7 @@ namespace MEDCoupling
     //
     void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
     void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+    void setFieldProfileFlatly(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
     void setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
     void setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
     %extend
@@ -2310,12 +2263,6 @@ namespace MEDCoupling
          {
            return MEDFileField1TS::New();
          }
-
-         // serialization
-         static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-         {
-           return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileField1TS");
-         }
          
          void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
          {
@@ -2379,29 +2326,7 @@ namespace MEDCoupling
 
          PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception)
          {
-           std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > elt1Cpp;
-           DataArrayDouble *elt0=self->getUndergroundDataArrayExt(elt1Cpp);
-           if(elt0)
-             elt0->incrRef();
-           PyObject *ret=PyTuple_New(2);
-           PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elt0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
-           std::size_t sz=elt1Cpp.size();
-           PyObject *elt=PyList_New(sz);
-           for(std::size_t i=0;i<sz;i++)
-             {
-               PyObject *elt1=PyTuple_New(2);
-               PyObject *elt2=PyTuple_New(2);
-               PyTuple_SetItem(elt2,0,SWIG_From_int((int)elt1Cpp[i].first.first));
-               PyTuple_SetItem(elt2,1,SWIG_From_int(elt1Cpp[i].first.second));
-               PyObject *elt3=PyTuple_New(2);
-               PyTuple_SetItem(elt3,0,SWIG_From_int(elt1Cpp[i].second.first));
-               PyTuple_SetItem(elt3,1,SWIG_From_int(elt1Cpp[i].second.second));
-               PyTuple_SetItem(elt1,0,elt2);
-               PyTuple_SetItem(elt1,1,elt3);
-               PyList_SetItem(elt,i,elt1);
-             }
-           PyTuple_SetItem(ret,1,elt);
-           return ret;
+           return MEDFileField1TS_getUndergroundDataArrayExt<double>(self);
          }
        }
   };
@@ -2418,6 +2343,8 @@ namespace MEDCoupling
     //
     void setFieldNoProfileSBT(const MEDCouplingFieldInt *field) throw(INTERP_KERNEL::Exception);
     void setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+    void setFieldProfileFlatly(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+    void copyTimeInfoFrom(MEDCouplingFieldInt *mcf) throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldInt *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
@@ -2451,12 +2378,6 @@ namespace MEDCoupling
         return MEDFileIntField1TS::New(db);
       }
 
-      // serialization
-      static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-      {
-        return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileIntField1TS");
-      }
-
       std::string __str__() const throw(INTERP_KERNEL::Exception)
       {
         return self->simpleRepr();
@@ -2474,6 +2395,11 @@ namespace MEDCoupling
           ret->incrRef();
         return ret;
       }
+
+      PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception)
+      {
+        return MEDFileField1TS_getUndergroundDataArrayExt<int>(self);
+      }
     }
   };
 
@@ -2489,6 +2415,8 @@ namespace MEDCoupling
     //
     void setFieldNoProfileSBT(const MEDCouplingFieldFloat *field) throw(INTERP_KERNEL::Exception);
     void setFieldProfile(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+    void setFieldProfileFlatly(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+    void copyTimeInfoFrom(MEDCouplingFieldFloat *mcf) throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldFloat *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldFloat *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldFloat *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
@@ -2522,12 +2450,6 @@ namespace MEDCoupling
         return MEDFileFloatField1TS::New(db);
       }
 
-      // serialization
-      static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-      {
-        return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFloatField1TS");
-      }
-
       std::string __str__() const throw(INTERP_KERNEL::Exception)
       {
         return self->simpleRepr();
@@ -2545,6 +2467,11 @@ namespace MEDCoupling
           ret->incrRef();
         return ret;
       }
+      
+      PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception)
+      {
+        return MEDFileField1TS_getUndergroundDataArrayExt<float>(self);
+      }
     }
   };
 
@@ -2977,12 +2904,6 @@ namespace MEDCoupling
          {
            return MEDFileFieldMultiTS::New(db);
          }
-         
-         // serialization
-         static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-         {
-           return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFieldMultiTS");
-         }
 
          static MEDFileFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true)
          {
@@ -3140,12 +3061,6 @@ namespace MEDCoupling
         return MEDFileIntFieldMultiTS::New(db);
       }
       
-      // serialization
-      static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-      {
-        return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileIntFieldMultiTS");
-      }
-      
       static MEDFileIntFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true)
       {
         std::vector<std::pair<int,int> > tmp(convertTimePairIdsFromPy(entities));
@@ -3217,12 +3132,6 @@ namespace MEDCoupling
         return MEDFileFloatFieldMultiTS::New(db);
       }
       
-      // serialization
-      static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-      {
-        return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFloatFieldMultiTS");
-      }
-      
       static MEDFileFloatFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true)
       {
         std::vector<std::pair<int,int> > tmp(convertTimePairIdsFromPy(entities));
@@ -3337,12 +3246,6 @@ namespace MEDCoupling
            return MEDFileFields::NewAdv(fileName,loadAll,entities);
          }
          
-         // serialization
-         static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-         {
-           return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFields");
-         }
-         
          std::string __str__() const throw(INTERP_KERNEL::Exception)
          {
            return self->simpleRepr();
@@ -3514,6 +3417,12 @@ namespace MEDCoupling
            convertToMapIntDataArrayInt(extractDef,extractDefCpp);
            return self->extractPart(extractDefCpp,mm);
          }
+
+         MEDFileFields *linearToQuadratic(const MEDFileMeshes *oldLin, const MEDFileMeshes *newQuad) const throw(INTERP_KERNEL::Exception)
+         {
+           MCAuto<MEDFileFields> ret(self->linearToQuadratic(oldLin,newQuad));
+           return ret.retn();
+         }
        }
   };
 
@@ -3832,12 +3741,6 @@ namespace MEDCoupling
       {
         return MEDFileParameters::New(db);
       }
-
-      // serialization
-      static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-      {
-        return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileParameters");
-      }
       
       std::string __str__() const throw(INTERP_KERNEL::Exception)
       {
@@ -3974,12 +3877,6 @@ namespace MEDCoupling
            MCAuto<MEDFileData> ret(MEDFileData::Aggregate(mfdsCpp));
            return ret.retn();
          }
-
-         // serialization
-         static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-         {
-           return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileData");
-         }
        }
   };