Salome HOME
Windows porting on swig2.0.9
[modules/med.git] / src / MEDLoader / Swig / MEDLoaderCommon.i
index c0b36d9bc16b45e0936ea41a12a458442a1cf1f1..c7686307b90b282b327bc2890807ffdb5fa722c1 100644 (file)
@@ -32,6 +32,7 @@
 #include "MEDFileParameter.hxx"
 #include "MEDFileData.hxx"
 #include "MEDFileMeshReadSelector.hxx"
+#include "MEDFileFieldOverView.hxx"
 #include "MEDLoaderTypemaps.i"
 #include "SauvReader.hxx"
 #include "SauvWriter.hxx"
@@ -63,6 +64,11 @@ using namespace ParaMEDMEM;
   $result=convertMEDFileField1TS($1,$owner);
 }
 
+%typemap(out) ParaMEDMEM::MEDMeshMultiLev*
+{
+  $result=convertMEDMeshMultiLev($1,$owner);
+}
+
 %newobject MEDLoader::ReadUMeshFromFamilies;
 %newobject MEDLoader::ReadUMeshFromGroups;
 %newobject MEDLoader::ReadUMeshFromFile;
@@ -175,6 +181,12 @@ using namespace ParaMEDMEM;
 %newobject ParaMEDMEM::SauvReader::New;
 %newobject ParaMEDMEM::SauvReader::loadInMEDFileDS;
 
+%newobject ParaMEDMEM::MEDFileMeshStruct::New;
+%newobject ParaMEDMEM::MEDMeshMultiLev::prepare;
+%newobject ParaMEDMEM::MEDMeshMultiLev::buildDataArray;
+%newobject ParaMEDMEM::MEDFileFastCellSupportComparator::New;
+%newobject ParaMEDMEM::MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport;
+
 %feature("unref") MEDFileMesh "$this->decrRef();"
 %feature("unref") MEDFileUMesh "$this->decrRef();"
 %feature("unref") MEDFileCMesh "$this->decrRef();"
@@ -196,6 +208,12 @@ using namespace ParaMEDMEM;
 %feature("unref") MEDFileData "$this->decrRef();"
 %feature("unref") SauvReader "$this->decrRef();"
 %feature("unref") SauvWriter "$this->decrRef();"
+%feature("unref") MEDFileFastCellSupportComparator "$this->decrRef();"
+%feature("unref") MEDMeshMultiLev "$this->decrRef();"
+%feature("unref") MEDUMeshMultiLev "$this->decrRef();"
+%feature("unref") MEDCMeshMultiLev "$this->decrRef();"
+%feature("unref") MEDCurveLinearMeshMultiLev "$this->decrRef();"
+%feature("unref") MEDFileMeshStruct "$this->decrRef();"
 
 class MEDLoader
 {
@@ -457,6 +475,7 @@ namespace ParaMEDMEM
     virtual std::vector<int> getFamArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
     virtual std::vector<int> getNumArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
     virtual std::vector<int> getNameArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
+    virtual std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception);
     std::vector<int> getNonEmptyLevels() const throw(INTERP_KERNEL::Exception);
     std::vector<int> getNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
@@ -687,7 +706,6 @@ namespace ParaMEDMEM
     MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
     MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
     MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
-    MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception);
     //
     void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception);
     void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
@@ -769,6 +787,14 @@ namespace ParaMEDMEM
            PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
            return ret;
          }
+         
+         MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception)
+         {
+           MEDCoupling1GTUMesh *ret(self->getDirectUndergroundSingleGeoTypeMesh(gt));
+           if(ret)
+             ret->incrRef();
+           return ret;
+         }
 
          PyObject *getDirectUndergroundSingleGeoTypeMeshes(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception)
          {
@@ -1151,7 +1177,7 @@ namespace ParaMEDMEM
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
     void loadArrays() throw(INTERP_KERNEL::Exception);
     void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
-    void releaseArrays() throw(INTERP_KERNEL::Exception);
+    void unloadArrays() throw(INTERP_KERNEL::Exception);
     int getDimension() const throw(INTERP_KERNEL::Exception);
     int getIteration() const throw(INTERP_KERNEL::Exception);
     int getOrder() const throw(INTERP_KERNEL::Exception);
@@ -1567,7 +1593,7 @@ namespace ParaMEDMEM
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
     void loadArrays() throw(INTERP_KERNEL::Exception);
     void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
-    void releaseArrays() throw(INTERP_KERNEL::Exception);
+    void unloadArrays() throw(INTERP_KERNEL::Exception);
     //
     virtual MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
     MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
@@ -1873,12 +1899,19 @@ namespace ParaMEDMEM
       {
         std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTS;
         convertFromPyObjVectorOfObj<ParaMEDMEM::MEDFileAnyTypeFieldMultiTS *>(li,SWIGTYPE_p_ParaMEDMEM__MEDFileAnyTypeFieldMultiTS,"MEDFileAnyTypeFieldMultiTS",vectFMTS);
-        std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret=MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(vectFMTS,mesh);
+        std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > ret2;
+        std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret=MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(vectFMTS,mesh,ret2);
+        if(ret2.size()!=ret.size())
+          {
+            std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport (PyWrap) : internal error ! Size of 2 vectors must match ! (" << ret.size() << "!=" << ret2.size() << ") !";
+            throw INTERP_KERNEL::Exception(oss.str().c_str());
+          }
         std::size_t sz=ret.size();
         PyObject *retPy=PyList_New(sz);
         for(std::size_t i=0;i<sz;i++)
           {
             std::size_t sz2=ret[i].size();
+            PyObject *ret0Py=PyTuple_New(2);
             PyObject *ret1Py=PyList_New(sz2);
             for(std::size_t j=0;j<sz2;j++)
               {
@@ -1887,7 +1920,9 @@ namespace ParaMEDMEM
                   elt->incrRef();
                 PyList_SetItem(ret1Py,j,convertMEDFileFieldMultiTS(elt,SWIG_POINTER_OWN | 0 ));
               }
-            PyList_SetItem(retPy,i,ret1Py);
+            PyTuple_SetItem(ret0Py,0,ret1Py);
+            PyTuple_SetItem(ret0Py,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret2[i].retn()),SWIGTYPE_p_ParaMEDMEM__MEDFileFastCellSupportComparator, SWIG_POINTER_OWN | 0 ));
+            PyList_SetItem(retPy,i,ret0Py);
           }
         return retPy;
       }
@@ -2142,7 +2177,7 @@ namespace ParaMEDMEM
     MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception);
     void loadArrays() throw(INTERP_KERNEL::Exception);
     void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
-    void releaseArrays() throw(INTERP_KERNEL::Exception);
+    void unloadArrays() throw(INTERP_KERNEL::Exception);
     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
     int getNumberOfFields() const;
     std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
@@ -2756,5 +2791,113 @@ namespace ParaMEDMEM
     void setMEDFileDS(const MEDFileData* medData, unsigned meshIndex = 0) throw(INTERP_KERNEL::Exception);
     void write(const char* fileName) throw(INTERP_KERNEL::Exception);
   };
+  
+  ///////////////
 
+  class MEDFileMeshStruct;
+
+  class MEDFileField1TSStructItem
+  {
+  public:
+    static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
+  };
+
+  class MEDFileMeshStruct : public RefCountObject
+  {
+  public:
+    static MEDFileMeshStruct *New(const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+  protected:
+    ~MEDFileMeshStruct();
+  };
+  
+  class MEDMeshMultiLev : public RefCountObject
+  {
+  public:
+    virtual MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception);
+    DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception);
+  protected:
+    ~MEDMeshMultiLev();
+  };
+
+  class MEDUMeshMultiLev : public MEDMeshMultiLev
+  {
+  protected:
+    ~MEDUMeshMultiLev();
+  public:
+    %extend
+     {
+       PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception)
+       {
+         DataArrayDouble *coords(0); DataArrayByte *types(0); DataArrayInt *cellLocations(0),*cells(0),*faceLocations(0),*faces(0);
+         self->buildVTUArrays(coords,types,cellLocations,cells,faceLocations,faces);
+         PyObject *ret=PyTuple_New(6);
+         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(coords),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(types),SWIGTYPE_p_ParaMEDMEM__DataArrayByte, SWIG_POINTER_OWN | 0 ));
+         PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(cellLocations),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+         PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(cells),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+         PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(faceLocations),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+         PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(faces),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+         return ret;
+       }
+     }
+  };
+
+  class MEDStructuredMeshMultiLev : public MEDMeshMultiLev
+  {
+  protected:
+    ~MEDStructuredMeshMultiLev();
+  };
+
+  class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev
+  {
+  protected:
+    ~MEDCMeshMultiLev();
+  public:
+    %extend
+    {
+      PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector< DataArrayDouble * > objs(self->buildVTUArrays());
+        std::size_t sz(objs.size());
+        PyObject *ret=PyList_New(sz);
+        for(std::size_t i=0;i<sz;i++)
+          PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(objs[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+    }
+  };
+
+  class MEDCurveLinearMeshMultiLev : public MEDStructuredMeshMultiLev
+  {
+  protected:
+    ~MEDCurveLinearMeshMultiLev();
+  public:
+    %extend
+    {
+      PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayDouble *ret0(0);
+        std::vector<int> ret1;
+        self->buildVTUArrays(ret0,ret1);
+        std::size_t sz(ret1.size());
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+        PyObject *ret1Py=PyList_New(sz);
+        for(std::size_t i=0;i<sz;i++)
+          PyList_SetItem(ret1Py,i,SWIG_From_int(ret1[i]));
+        PyTuple_SetItem(ret,1,ret1Py);
+        return ret;
+      }
+    }
+  };
+
+  class MEDFileFastCellSupportComparator : public RefCountObject
+  {
+  public:
+    static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
+    MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
+    bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
+  protected:
+    ~MEDFileFastCellSupportComparator();
+  };
 }