Salome HOME
Step 7 : start of filtering structure elements in fields
[tools/medcoupling.git] / src / MEDLoader / Swig / MEDLoaderCommon.i
index 810045d926a6fdd69010a99af1d2b3158edf8f4a..da768d905e040efd06ec8020567539abc056cf98 100644 (file)
@@ -150,6 +150,7 @@ using namespace MEDCoupling;
 %newobject MEDCoupling::MEDFileFields::partOfThisLyingOnSpecifiedMeshName;
 %newobject MEDCoupling::MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps;
 %newobject MEDCoupling::MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps;
+%newobject MEDCoupling::MEDFileFields::partOfThisOnStructureElements;
 %newobject MEDCoupling::MEDFileFields::__iter__;
 %newobject MEDCoupling::MEDFileFields::extractPart;
 
@@ -299,7 +300,7 @@ using namespace MEDCoupling;
 namespace MEDCoupling
 {
   bool HasXDR();
-  std::string MEDFileVersionStr();
+  std::string MEDFileVersionStr() throw(INTERP_KERNEL::Exception);
   std::string MEDFileVersionOfFileStr(const std::string& fileName) throw(INTERP_KERNEL::Exception);
   void SetEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
   void SetCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
@@ -353,7 +354,7 @@ namespace MEDCoupling
 
 %inline
 {
-  PyObject *MEDFileVersionSwig()
+  PyObject *MEDFileVersionSwig() throw(INTERP_KERNEL::Exception)
   {
     int major,minor,release;
     MEDCoupling::MEDFileVersion(major,minor,release);
@@ -364,7 +365,7 @@ namespace MEDCoupling
     return ret;
   }
 
-  PyObject *GetFieldIterationsSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName)
+  PyObject *GetFieldIterationsSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
   {
     std::vector< std::pair<int,int> > res=MEDCoupling::GetFieldIterations(type,fileName,meshName,fieldName);
     PyObject *ret=PyList_New(res.size());
@@ -546,6 +547,34 @@ namespace MEDCoupling
            MCAuto<DataArrayByte> ret(self->serialize());
            return ret.retn();
          }
+
+         PyObject *__getstate__() throw(INTERP_KERNEL::Exception)
+         {
+           PyObject *ret(PyList_New(0));
+           return ret;
+         }
+
+         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
+         }
        }
   };
   
@@ -1055,6 +1084,8 @@ namespace MEDCoupling
     void setJoints( MEDFileJoints* joints );
     void initializeEquivalences();
     void killEquivalences();
+    bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
+    void killStructureElements() throw(INTERP_KERNEL::Exception);
     %extend
        {
          std::string __str__() const throw(INTERP_KERNEL::Exception)
@@ -1587,6 +1618,12 @@ 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)
          {
@@ -1627,6 +1664,12 @@ 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)
          {
@@ -1711,6 +1754,8 @@ namespace MEDCoupling
     void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
     void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
     void cartesianizeMe() throw(INTERP_KERNEL::Exception);
+    bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
+    void killStructureElements() throw(INTERP_KERNEL::Exception);
     %extend
        {
          MEDFileMeshes()
@@ -1728,6 +1773,12 @@ 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();
@@ -2134,6 +2185,12 @@ 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)
          {
            const DataArrayDouble *arr=0;
@@ -2273,6 +2330,12 @@ 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();
@@ -2694,6 +2757,7 @@ namespace MEDCoupling
     static MEDFileFieldMultiTS *New() throw(INTERP_KERNEL::Exception);
     static MEDFileFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
     static MEDFileFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+    static MEDFileFieldMultiTS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception);
     //
     MEDCouplingFieldDouble *field(int iteration, int order, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
@@ -2721,6 +2785,17 @@ namespace MEDCoupling
          {
            return MEDFileFieldMultiTS::New(fileName,fieldName,loadAll);
          }
+         
+         MEDFileFieldMultiTS(DataArrayByte *db) throw(INTERP_KERNEL::Exception)
+         {
+           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)
          {
@@ -2877,7 +2952,13 @@ 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));
@@ -2940,6 +3021,8 @@ namespace MEDCoupling
     MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
     MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
     MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const throw(INTERP_KERNEL::Exception);
+    bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
+    void killStructureElements() throw(INTERP_KERNEL::Exception);
     void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
     bool removeFieldsWithoutAnyTimeStep() throw(INTERP_KERNEL::Exception);
     %extend
@@ -2959,11 +3042,23 @@ namespace MEDCoupling
            return MEDFileFields::New(db);
          }
          
+         // 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();
          }
-
+         
+         MEDFileFields *partOfThisOnStructureElements() const throw(INTERP_KERNEL::Exception)
+         {
+           MCAuto<MEDFileFields> ret(self->partOfThisOnStructureElements());
+           return ret.retn();
+         }
+         
          static MEDFileFields *LoadSpecificEntities(const std::string& fileName, PyObject *entities, bool loadAll=true) throw(INTERP_KERNEL::Exception)
          {
            std::vector<std::pair<int,int> > tmp(convertTimePairIdsFromPy(entities));
@@ -3430,6 +3525,12 @@ 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)
       {
@@ -3507,6 +3608,8 @@ namespace MEDCoupling
     //
     bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName) throw(INTERP_KERNEL::Exception);
     bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception);
+    std::string getHeader() const throw(INTERP_KERNEL::Exception);
+    void setHeader(const std::string& header) throw(INTERP_KERNEL::Exception);
     //
     %extend
        {
@@ -3567,6 +3670,12 @@ 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");
+         }
        }
   };