Salome HOME
Merge branch 'master' of ssh://git.salome-platform.org/tools/medcoupling
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingMemArray.i
index 2851ccb7d395ce775eea26f002e97963ebb0fb7e..397712f5d8666b668385c02c562585be7fbccc94 100644 (file)
@@ -51,6 +51,7 @@
 %newobject MEDCoupling::DataArray::Aggregate;
 %newobject MEDCoupling::DataArrayInt::New;
 %newobject MEDCoupling::DataArrayInt::__iter__;
+%newobject MEDCoupling::DataArrayInt::selectPartDef;
 %newobject MEDCoupling::DataArrayInt::convertToDblArr;
 %newobject MEDCoupling::DataArrayInt::performCopyOrIncrRef;
 %newobject MEDCoupling::DataArrayInt::subArray;
 %newobject MEDCoupling::DataArrayAsciiCharTuple::buildDAAsciiChar;
 %newobject MEDCoupling::DataArrayDouble::New;
 %newobject MEDCoupling::DataArrayDouble::__iter__;
+%newobject MEDCoupling::DataArrayDouble::selectPartDef;
 %newobject MEDCoupling::DataArrayDouble::convertToIntArr;
 %newobject MEDCoupling::DataArrayDouble::performCopyOrIncrRef;
 %newobject MEDCoupling::DataArrayDouble::Aggregate;
 %newobject MEDCoupling::DataArrayDouble::__rpow__;
 %newobject MEDCoupling::DataArrayDoubleTuple::buildDADouble;
 
+%newobject MEDCoupling::PartDefinition::New;
+%newobject MEDCoupling::PartDefinition::toDAI;
+%newobject MEDCoupling::PartDefinition::__add__;
+%newobject MEDCoupling::PartDefinition::composeWith;
+%newobject MEDCoupling::PartDefinition::tryToSimplify;
+%newobject MEDCoupling::DataArrayPartDefinition::New;
+%newobject MEDCoupling::SlicePartDefinition::New;
+
+
 %feature("unref") DataArray "$this->decrRef();"
 %feature("unref") DataArrayDouble "$this->decrRef();"
 %feature("unref") DataArrayInt "$this->decrRef();"
 %feature("unref") DataArrayAsciiChar "$this->decrRef();"
 %feature("unref") DataArrayByte "$this->decrRef();"
 
+%feature("unref") PartDefinition "$this->decrRef();"
+%feature("unref") DataArrayPartDefinition "$this->decrRef();"
+%feature("unref") SlicePartDefinition "$this->decrRef();"
+
 namespace MEDCoupling
 {
   typedef enum
@@ -218,6 +233,109 @@ namespace MEDCoupling
       AX_SPHER = 5
     } MEDCouplingAxisType;
 
+  class DataArrayInt;
+  
+  class PartDefinition : public RefCountObject, public TimeLabel
+  {
+  public:
+    static PartDefinition *New(int start, int stop, int step) throw(INTERP_KERNEL::Exception);
+    static PartDefinition *New(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception);
+    virtual DataArrayInt *toDAI() const throw(INTERP_KERNEL::Exception);
+    virtual int getNumberOfElems() const throw(INTERP_KERNEL::Exception);
+    virtual std::string getRepr() const throw(INTERP_KERNEL::Exception);
+    virtual PartDefinition *composeWith(const PartDefinition *other) const throw(INTERP_KERNEL::Exception);
+    virtual void checkConsistencyLight() const throw(INTERP_KERNEL::Exception);
+    virtual PartDefinition *tryToSimplify() const throw(INTERP_KERNEL::Exception);
+    %extend
+    {
+      virtual PartDefinition *__add__(const PartDefinition& other) const throw(INTERP_KERNEL::Exception)
+      {
+        return (*self)+other;
+      }
+
+      virtual PyObject *isEqual(const PartDefinition *other) const throw(INTERP_KERNEL::Exception)
+      {
+        std::string ret1;
+        bool ret0(self->isEqual(other,ret1));
+        PyObject *ret=PyTuple_New(2);
+        PyObject *ret0Py=ret0?Py_True:Py_False;
+        Py_XINCREF(ret0Py);
+        PyTuple_SetItem(ret,0,ret0Py);
+        PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
+        return ret;
+      }
+
+      virtual PyObject *deepCopy() const throw(INTERP_KERNEL::Exception)
+      {
+        return convertPartDefinition(self->deepCopy(),SWIG_POINTER_OWN | 0);
+      }
+    }
+  protected:
+    virtual ~PartDefinition();
+  };
+
+  class DataArrayPartDefinition : public PartDefinition
+  {
+  public:
+    static DataArrayPartDefinition *New(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception);
+    %extend
+    {
+      DataArrayPartDefinition(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception)
+      {
+        return DataArrayPartDefinition::New(listOfIds);
+      }
+
+      std::string __str__() const throw(INTERP_KERNEL::Exception)
+      {
+        return self->getRepr();
+      }
+      
+      std::string __repr__() const throw(INTERP_KERNEL::Exception)
+      {
+        std::ostringstream oss; oss << "DataArrayPartDefinition C++ instance at " << self << "." << std::endl;
+        oss << self->getRepr();
+        return oss.str();
+      }
+    }
+  protected:
+    virtual ~DataArrayPartDefinition();
+  };
+
+  class SlicePartDefinition : public PartDefinition
+  {
+  public:
+    static SlicePartDefinition *New(int start, int stop, int step) throw(INTERP_KERNEL::Exception);
+    int getEffectiveStop() const throw(INTERP_KERNEL::Exception);
+    %extend
+    {
+      SlicePartDefinition(int start, int stop, int step) throw(INTERP_KERNEL::Exception)
+      {
+        return SlicePartDefinition::New(start,stop,step);
+      }
+
+      PyObject *getSlice() const throw(INTERP_KERNEL::Exception)
+      {
+        int a,b,c;
+        self->getSlice(a,b,c);
+        return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
+      }
+      
+      std::string __str__() const throw(INTERP_KERNEL::Exception)
+      {
+        return self->getRepr();
+      }
+      
+      std::string __repr__() const throw(INTERP_KERNEL::Exception)
+      {
+        std::ostringstream oss; oss << "SlicePartDefinition C++ instance at " << self << "." << std::endl;
+        oss << self->getRepr();
+        return oss.str();
+      }
+    }
+  protected:
+    virtual ~SlicePartDefinition();
+  };
+  
   class DataArray : public RefCountObject, public TimeLabel
   {
   public:
@@ -250,6 +368,9 @@ namespace MEDCoupling
     virtual DataArray *buildNewEmptyInstance() const throw(INTERP_KERNEL::Exception);
     virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception);
     virtual void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
+    virtual void circularPermutation(int nbOfShift=1) throw(INTERP_KERNEL::Exception);
+    virtual void circularPermutationPerTuple(int nbOfShift=1) throw(INTERP_KERNEL::Exception);
+    virtual void reversePerTuple() throw(INTERP_KERNEL::Exception);
     void checkNbOfTuples(int nbOfTuples, const std::string& msg) const throw(INTERP_KERNEL::Exception);
     void checkNbOfComps(int nbOfCompo, const std::string& msg) const throw(INTERP_KERNEL::Exception);
     void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const throw(INTERP_KERNEL::Exception);
@@ -756,6 +877,12 @@ namespace MEDCoupling
           return MEDCoupling_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2);
         }
 
+      DataArrayDouble *selectPartDef(const PartDefinition* pd) const throw(INTERP_KERNEL::Exception)
+      {
+        MCAuto<DataArrayDouble> ret(self->selectPartDef(pd));
+        return ret.retn();
+      }
+
       void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception)
       {
         double val;
@@ -1116,6 +1243,16 @@ namespace MEDCoupling
         convertPyToNewIntArr3(li,tmp);
         self->setSelectedComponents(a,tmp);
       }
+
+      PyObject *explodeComponents() const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector< MCAuto<DataArrayDouble> > retCpp(self->explodeComponents());
+        std::size_t sz(retCpp.size());
+        PyObject *res(PyList_New(sz));
+        for(std::size_t i=0;i<sz;i++)
+          PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+        return res;
+      }
    
       PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
       {
@@ -2869,6 +3006,12 @@ namespace MEDCoupling
       {
         return self->iterator();
       }
+
+      DataArrayInt *selectPartDef(const PartDefinition* pd) const throw(INTERP_KERNEL::Exception)
+      {
+        MCAuto<DataArrayInt> ret(self->selectPartDef(pd));
+        return ret.retn();
+      }
    
       PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
       {
@@ -3241,6 +3384,16 @@ namespace MEDCoupling
         self->setSelectedComponents(a,tmp);
       }
 
+      PyObject *explodeComponents() const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector< MCAuto<DataArrayInt> > retCpp(self->explodeComponents());
+        std::size_t sz(retCpp.size());
+        PyObject *res(PyList_New(sz));
+        for(std::size_t i=0;i<sz;i++)
+          PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return res;
+      }
+
       PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
       {
         int sz=self->getNumberOfComponents();