Salome HOME
Load interpolation matrix from the outside
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingMemArray.i
index f814d5a0e579958b8bddca6c2405229d86bc3e0a..ce219c7749ecc698cdec2ba48a863a2a0eed7a90 100644 (file)
@@ -93,6 +93,7 @@
 %newobject MEDCoupling::DataArrayInt::findIdsEqualList;
 %newobject MEDCoupling::DataArrayInt::findIdsNotEqualList;
 %newobject MEDCoupling::DataArrayInt::findIdsEqualTuple;
+%newobject MEDCoupling::DataArrayInt::findIdForEach;
 %newobject MEDCoupling::DataArrayInt::sumPerTuple;
 %newobject MEDCoupling::DataArrayInt::negate;
 %newobject MEDCoupling::DataArrayInt::computeAbs;
@@ -800,31 +801,6 @@ namespace MEDCoupling
         return ToNumPyArray<DataArrayFloat,float>(self,NPY_FLOAT,"DataArrayFloat");
       }
 #endif
-
-      // serialization
-      static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-      {
-        return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayFloat");
-      }
-      
-      PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
-      {
-#ifdef WITH_NUMPY
-        if(!self->isAllocated())
-          throw INTERP_KERNEL::Exception("PyWrap of DataArrayFloat.__getnewargs__ : self is not allocated !");
-        PyObject *ret(PyTuple_New(1));
-        PyObject *ret0(PyDict_New());
-        PyObject *numpyArryObj(MEDCoupling_DataArrayFloat_toNumPyArray(self));
-        {// 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 DataArrayByte.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !");
-#endif
-      }
     }
   };
 
@@ -941,9 +917,8 @@ namespace MEDCoupling
     void checkNoNullValues() const throw(INTERP_KERNEL::Exception);
     DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const throw(INTERP_KERNEL::Exception);
     void recenterForMaxPrecision(double eps) throw(INTERP_KERNEL::Exception);
-    double getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
     double getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
-    double getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
+    double getMaxAbsValueInArray() const throw(INTERP_KERNEL::Exception);
     double getMinValueInArray() const throw(INTERP_KERNEL::Exception);
     int count(double value, double eps) const throw(INTERP_KERNEL::Exception);
     double getAverageValue() const throw(INTERP_KERNEL::Exception);
@@ -1070,6 +1045,22 @@ namespace MEDCoupling
           }
       }
 
+      PyObject *asArcOfCircle() const throw(INTERP_KERNEL::Exception)
+      {
+        double center[2],radius,ang;
+        self->asArcOfCircle(center,radius,ang);
+        PyObject *ret(PyTuple_New(3));
+        {
+          PyObject *ret0(PyList_New(2));
+          PyList_SetItem(ret0,0,PyFloat_FromDouble(center[0]));
+          PyList_SetItem(ret0,1,PyFloat_FromDouble(center[1]));
+          PyTuple_SetItem(ret,0,ret0);
+        }
+        PyTuple_SetItem(ret,1,PyFloat_FromDouble(radius));
+        PyTuple_SetItem(ret,2,PyFloat_FromDouble(ang));        
+        return ret;
+      }
+
       DataArrayDoubleIterator *__iter__() throw(INTERP_KERNEL::Exception)
       {
         return self->iterator();
@@ -1302,6 +1293,16 @@ namespace MEDCoupling
         return ret;
       }
 
+         PyObject *getMaxAbsValue() const throw(INTERP_KERNEL::Exception)
+      {
+        std::size_t tmp;
+        double r1=self->getMaxAbsValue(tmp);
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+        PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+        return ret;
+      }
+
       PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
       {
         DataArrayInt *tmp;
@@ -1938,31 +1939,6 @@ namespace MEDCoupling
         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
         return ret;
       }
-
-      // serialization
-      static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-      {
-        return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayDouble");
-      }
-
-      PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
-      {
-#ifdef WITH_NUMPY
-        if(!self->isAllocated())
-          throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : self is not allocated !");
-        PyObject *ret(PyTuple_New(1));
-        PyObject *ret0(PyDict_New());
-        PyObject *numpyArryObj(MEDCoupling_DataArrayDouble_toNumPyArray(self));
-        {// 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 DataArrayDouble.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !");
-#endif
-      }
     }
   };
 
@@ -2347,9 +2323,8 @@ namespace MEDCoupling
     bool presenceOfValue(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
     int count(int value) const throw(INTERP_KERNEL::Exception);
     int accumulate(int compId) const throw(INTERP_KERNEL::Exception);
-    int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
     int getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
-    int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
+    int getMaxAbsValueInArray() const throw(INTERP_KERNEL::Exception);
     int getMinValueInArray() const throw(INTERP_KERNEL::Exception);
     void abs() throw(INTERP_KERNEL::Exception);
     DataArrayInt *computeAbs() const throw(INTERP_KERNEL::Exception);
@@ -2568,6 +2543,15 @@ namespace MEDCoupling
         return self->findIdsEqualTuple(bg,bg+sz);
       }
 
+      DataArrayInt *findIdForEach(PyObject *vals) const throw(INTERP_KERNEL::Exception)
+      {
+        int sw,sz,val;
+        std::vector<int> val2;
+        const int *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2));
+        MCAuto<DataArrayInt> ret(self->findIdForEach(bg,bg+sz));
+        return ret.retn();
+      }
+
       PyObject *splitInBalancedSlices(int nbOfSlices) const throw(INTERP_KERNEL::Exception)
       {
         std::vector< std::pair<int,int> > slcs(self->splitInBalancedSlices(nbOfSlices));
@@ -2996,6 +2980,16 @@ namespace MEDCoupling
         PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
         return ret;
       }
+    
+      PyObject *getMaxAbsValue(std::size_t& tupleId) const throw(INTERP_KERNEL::Exception)
+      {
+       std::size_t tmp;
+        int r1=self->getMaxAbsValue(tmp);
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
+        PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+        return ret;
+      }
 
       PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
       {
@@ -5062,31 +5056,6 @@ namespace MEDCoupling
       }
 #endif
 
-      // serialization
-      static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
-      {
-        return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayByte");
-      }
-
-      PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
-      {
-#ifdef WITH_NUMPY
-        if(!self->isAllocated())
-          throw INTERP_KERNEL::Exception("PyWrap of DataArrayByte.__getnewargs__ : self is not allocated !");
-        PyObject *ret(PyTuple_New(1));
-        PyObject *ret0(PyDict_New());
-        PyObject *numpyArryObj(MEDCoupling_DataArrayByte_toNumPyArray(self));
-        {// 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 DataArrayByte.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !");
-#endif
-      }
-
       DataArrayByte *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
       {
         self->checkAllocated();
@@ -5952,14 +5921,30 @@ namespace MEDCoupling
 }
 
 %pythoncode %{
-def MEDCouplingDataArrayIntReduceFunct(cls,params):
+def MEDCouplingStdReduceFunct(cls,params):
     a,b=params
-    ret=DataArrayInt.__new__(cls)
+    ret=object.__new__(cls)
     ret.__init__(*a)
     ret.__setstate__(b)
     return ret
+
+def MEDCouplingDataArrayDoubleReduce(self):
+    if not MEDCouplingHasNumPyBindings():
+      raise InterpKernelException("PyWrap of DataArrayDouble.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
+    return MEDCouplingStdReduceFunct,(DataArrayDouble,((self.toNumPyArray(),),(self.__getstate__()),))
+
 def MEDCouplingDataArrayIntReduce(self):
     if not MEDCouplingHasNumPyBindings():
-      raise InterpKernelException("PyWrap of DataArrayInt.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
-    return MEDCouplingDataArrayIntReduceFunct,(DataArrayInt,((self.toNumPyArray(),),(self.__getstate__()),))
+      raise InterpKernelException("PyWrap of DataArrayInt.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
+    return MEDCouplingStdReduceFunct,(DataArrayInt,((self.toNumPyArray(),),(self.__getstate__()),))
+
+def MEDCouplingDataArrayByteReduce(self):
+    if not MEDCouplingHasNumPyBindings():
+      raise InterpKernelException("PyWrap of DataArrayByte.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
+    return MEDCouplingStdReduceFunct,(DataArrayByte,((self.toNumPyArray(),),(self.__getstate__()),))
+
+def MEDCouplingDataArrayFloatReduce(self):
+    if not MEDCouplingHasNumPyBindings():
+      raise InterpKernelException("PyWrap of DataArrayFloat.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !")
+    return MEDCouplingStdReduceFunct,(DataArrayFloat,((self.toNumPyArray(),),(self.__getstate__()),))
 %}