Salome HOME
Indices are stored as mcIdType type instead of int to support switch to 64bits indexing
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingTypemaps.i
index 7a1a8eb018efd92c10d9790436c0508c97a627af..080def392e194fdb24ac8161717d7251b2596e22 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2019  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
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// Author : Anthony Geay (CEA/DEN)
 
-#ifdef WITH_NUMPY2
-#include <numpy/arrayobject.h>
-#endif
+#ifndef __MEDCOUPLINGTYPEMAPS_I__
+#define __MEDCOUPLINGTYPEMAPS_I__
+
+#include "MEDCouplingDataArrayTypemaps.i"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingIMesh.hxx"
+#include "MEDCouplingCurveLinearMesh.hxx"
+#include "MEDCouplingMappedExtrudedMesh.hxx"
+#include "MEDCoupling1GTUMesh.hxx"
+#include "MEDCouplingFieldDiscretization.hxx"
+#include "MEDCouplingMultiFields.hxx"
+#include "MEDCouplingPartDefinition.hxx"
+#include "MEDCouplingCartesianAMRMesh.hxx"
 
-static PyObject *convertMesh(ParaMEDMEM::MEDCouplingMesh *mesh, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertMesh(MEDCoupling::MEDCouplingMesh *mesh, int owner)
 {
   PyObject *ret=0;
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
-    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner);
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingExtrudedMesh *>(mesh))
-    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingExtrudedMesh,owner);
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingCMesh *>(mesh))
-    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh,owner);
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingCurveLinearMesh *>(mesh))
-    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCurveLinearMesh,owner);
+  if(!mesh)
+    {
+      Py_XINCREF(Py_None);
+      return Py_None;
+    }
+  if(dynamic_cast<MEDCoupling::MEDCouplingUMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,owner);
+  if(dynamic_cast<MEDCoupling::MEDCoupling1SGTUMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCoupling1SGTUMesh,owner);
+  if(dynamic_cast<MEDCoupling::MEDCoupling1DGTUMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCoupling1DGTUMesh,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingMappedExtrudedMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingMappedExtrudedMesh,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingCMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingCMesh,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingCurveLinearMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingCurveLinearMesh,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingIMesh *>(mesh))
+    ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingIMesh,owner);
   if(!ret)
     throw INTERP_KERNEL::Exception("Not recognized type of mesh on downcast !");
   return ret;
 }
 
-static PyObject *convertFieldDiscretization(ParaMEDMEM::MEDCouplingFieldDiscretization *fd, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertFieldDiscretization(MEDCoupling::MEDCouplingFieldDiscretization *fd, int owner)
 {
   PyObject *ret=0;
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationP0 *>(fd))
-    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationP0,owner);
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationP1 *>(fd))
-    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationP1,owner);
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationGauss *>(fd))
-    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationGauss,owner);
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationGaussNE *>(fd))
-    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationGaussNE,owner);
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationKriging *>(fd))
-    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationKriging,owner);
+  if(!fd)
+    {
+      Py_XINCREF(Py_None);
+      return Py_None;
+    }
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationP0 *>(fd))
+    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationP0,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationP1 *>(fd))
+    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationP1,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationGauss *>(fd))
+    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationGauss,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationGaussNE *>(fd))
+    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationGaussNE,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationKriging *>(fd))
+    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationKriging,owner);
   if(!ret)
     throw INTERP_KERNEL::Exception("Not recognized type of field discretization on downcast !");
   return ret;
 }
 
-static PyObject* convertMultiFields(ParaMEDMEM::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception)
-{
-  PyObject *ret=0;
-  if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldOverTime *>(mfs))
-    ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldOverTime,owner);
-  else
-    ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingMultiFields,owner);
-  return ret;
-}
-
-static PyObject *convertIntArrToPyList(const int *ptr, int size) throw(INTERP_KERNEL::Exception)
-{
-#ifndef WITH_NUMPY2
-  PyObject *ret=PyList_New(size);
-  for(int i=0;i<size;i++)
-    PyList_SetItem(ret,i,PyInt_FromLong(ptr[i]));
-  return ret;
-#else
-  npy_intp dim = (npy_intp) size;
-  int *tmp=new int[size];
-  std::copy(ptr,ptr+size,tmp);
-  return PyArray_SimpleNewFromData(1,&dim,NPY_INT,const_cast<int *>(tmp));
-#endif
-}
-
-static PyObject *convertIntArrToPyList2(const std::vector<int>& v) throw(INTERP_KERNEL::Exception)
-{
-#ifndef WITH_NUMPY2
-  int size=v.size();
-  PyObject *ret=PyList_New(size);
-  for(int i=0;i<size;i++)
-    PyList_SetItem(ret,i,PyInt_FromLong(v[i]));
-  return ret;
-#else
-  npy_intp dim = (npy_intp) v.size();
-  int *tmp=new int[v.size()];
-  std::copy(v.begin(),v.end(),tmp);
-  return PyArray_SimpleNewFromData(1,&dim,NPY_INT,tmp);
-#endif
-}
-
-static PyObject *convertIntArrToPyList3(const std::set<int>& v) throw(INTERP_KERNEL::Exception)
+static PyObject *convertField(MEDCoupling::MEDCouplingField *f, int owner)
 {
-  int size=v.size();
-  PyObject *ret=PyList_New(size);
-  std::set<int>::const_iterator it=v.begin();
-  for(int i=0;i<size;i++,it++)
-    PyList_SetItem(ret,i,PyInt_FromLong(*it));
-  return ret;
-}
-
-static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
-{
-  PyObject *ret=PyList_New(nbOfTuples);
-  for(int i=0;i<nbOfTuples;i++)
+  PyObject *ret(NULL);
+  if(!f)
     {
-      PyObject *t=PyTuple_New(nbOfComp);
-      for(int j=0;j<nbOfComp;j++)
-        PyTuple_SetItem(t,j,PyInt_FromLong(vals[i*nbOfComp+j]));
-      PyList_SetItem(ret,i,t);
+      Py_XINCREF(Py_None);
+      return Py_None;
     }
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldDouble *>(f))
+    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(f),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldInt *>(f))
+    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(f),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldInt,owner);
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldFloat *>(f))
+    ret=SWIG_NewPointerObj(reinterpret_cast<void*>(f),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldFloat,owner);
+  if(!ret)
+    throw INTERP_KERNEL::Exception("Not recognized type of field on downcast !");
   return ret;
 }
 
-static int *convertPyToNewIntArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
+static PyObject* convertMultiFields(MEDCoupling::MEDCouplingMultiFields *mfs, int owner)
 {
-  if(PyList_Check(pyLi))
-    {
-      *size=PyList_Size(pyLi);
-      int *tmp=new int[*size];
-      for(int i=0;i<*size;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          if(PyInt_Check(o))
-            {
-              int val=(int)PyInt_AS_LONG(o);
-              tmp[i]=val;
-            }
-          else
-            {
-              delete [] tmp;
-              throw INTERP_KERNEL::Exception("list must contain integers only");
-            }
-        }
-      return tmp;
-    }
-  else if(PyTuple_Check(pyLi))
+  PyObject *ret=0;
+  if(!mfs)
     {
-      *size=PyTuple_Size(pyLi);
-      int *tmp=new int[*size];
-      for(int i=0;i<*size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          if(PyInt_Check(o))
-            {
-              int val=(int)PyInt_AS_LONG(o);
-              tmp[i]=val;
-            }
-          else
-            {
-              delete [] tmp;
-              throw INTERP_KERNEL::Exception("tuple must contain integers only");
-            }
-        }
-      return tmp;
+      Py_XINCREF(Py_None);
+      return Py_None;
     }
+  if(dynamic_cast<MEDCoupling::MEDCouplingFieldOverTime *>(mfs))
+    ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldOverTime,owner);
   else
-    {
-#ifndef WITH_NUMPY2
-      throw INTERP_KERNEL::Exception("convertPyToNewIntArr2 : not a list");
-#else
-      if(PyArray_Check(pyLi))
-        {
-          npy_intp mySize = PyArray_SIZE(pyLi);
-          int *ret=(int *)PyArray_BYTES(pyLi);
-          *size=mySize;
-          return ret;
-        }
-      else
-        {
-          throw INTERP_KERNEL::Exception("convertPyToNewIntArr2 : not a list nor PyArray");
-        }
-#endif
-    }
+    ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_MEDCoupling__MEDCouplingMultiFields,owner);
+  return ret;
 }
 
-static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair<int,int> >& arr) throw(INTERP_KERNEL::Exception)
+static PyObject *convertCartesianAMRMesh(MEDCoupling::MEDCouplingCartesianAMRMeshGen *mesh, int owner)
 {
-  const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !";
-  if(PyList_Check(pyLi))
+  if(!mesh)
     {
-      int size=PyList_Size(pyLi);
-      arr.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          if(PyTuple_Check(o))
-            {
-              int sz2=PyTuple_Size(o);
-              if(sz2!=2)
-                throw INTERP_KERNEL::Exception(msg);
-              PyObject *o_0=PyTuple_GetItem(o,0);
-              if(!PyInt_Check(o_0))
-                throw INTERP_KERNEL::Exception(msg);
-              PyObject *o_1=PyTuple_GetItem(o,1);
-              if(!PyInt_Check(o_1))
-                throw INTERP_KERNEL::Exception(msg);
-              arr[i].first=(int)PyInt_AS_LONG(o_0);
-              arr[i].second=(int)PyInt_AS_LONG(o_1);
-            }
-          else
-            throw INTERP_KERNEL::Exception(msg);
-        }
+      Py_XINCREF(Py_None);
+      return Py_None;
     }
-  else if(PyTuple_Check(pyLi))
+  if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRMeshSub *>(mesh))
     {
-      int size=PyTuple_Size(pyLi);
-      arr.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          if(PyTuple_Check(o))
-            {
-              int sz2=PyTuple_Size(o);
-              if(sz2!=2)
-                throw INTERP_KERNEL::Exception(msg);
-              PyObject *o_0=PyTuple_GetItem(o,0);
-              if(!PyInt_Check(o_0))
-                throw INTERP_KERNEL::Exception(msg);
-              PyObject *o_1=PyTuple_GetItem(o,1);
-              if(!PyInt_Check(o_1))
-                throw INTERP_KERNEL::Exception(msg);
-              arr[i].first=(int)PyInt_AS_LONG(o_0);
-              arr[i].second=(int)PyInt_AS_LONG(o_1);
-            }
-          else
-            throw INTERP_KERNEL::Exception(msg);
-        }
+      return SWIG_NewPointerObj(reinterpret_cast<void*>(mesh),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRMeshSub,owner);
     }
-  else
-    throw INTERP_KERNEL::Exception(msg);
-}
-
-static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
-{
-  if(PyList_Check(pyLi))
+  if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRMesh *>(mesh))
     {
-      int size=PyList_Size(pyLi);
-      arr.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          if(PyInt_Check(o))
-            {
-              int val=(int)PyInt_AS_LONG(o);
-              arr[i]=val;
-            }
-          else
-            throw INTERP_KERNEL::Exception("list must contain integers only");
-        }
-    }
-  else if(PyTuple_Check(pyLi))
-    {
-      int size=PyTuple_Size(pyLi);
-      arr.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          if(PyInt_Check(o))
-            {
-              int val=(int)PyInt_AS_LONG(o);
-              arr[i]=val;
-            }
-          else
-            throw INTERP_KERNEL::Exception("tuple must contain integers only");
-        }
-    }
-  else
-    {
-#ifndef WITH_NUMPY2
-      throw INTERP_KERNEL::Exception("convertPyToNewIntArr3 : not a list nor a tuple");
-#else
-      if(PyArray_Check(pyLi))
-        {
-          npy_intp mySize = PyArray_SIZE(pyLi);
-          int *ret=(int *)PyArray_BYTES(pyLi);
-          arr.resize(mySize);
-          std::copy(ret,ret+mySize,arr.begin());
-          return ;
-        }
-      else
-        throw INTERP_KERNEL::Exception("convertPyToNewIntArr3 : not a list nor a tuple nor PyArray");
-#endif
+      return SWIG_NewPointerObj(reinterpret_cast<void*>(mesh),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRMesh,owner);
     }
+  throw INTERP_KERNEL::Exception("convertCartesianAMRMesh wrap : unrecognized type of cartesian AMR mesh !");
 }
 
-static void convertPyToNewIntArr4(PyObject *pyLi, int recurseLev, int nbOfSubPart, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
+static PyObject *convertDataForGodFather(MEDCoupling::MEDCouplingDataForGodFather *data, int owner)
 {
-  if(recurseLev<0)
-    throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : invalid list of integers level of recursion !");
-  arr.clear();
-  if(PyList_Check(pyLi))
+  if(!data)
     {
-      int size=PyList_Size(pyLi);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          if(PyInt_Check(o))
-            {
-              int val=(int)PyInt_AS_LONG(o);
-              arr.push_back(val);
-            }
-          else
-            {
-              std::vector<int> arr2;
-              convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
-              if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
-                  {
-                    std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " <<  recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
-                    throw INTERP_KERNEL::Exception(oss.str().c_str());
-                  }
-              arr.insert(arr.end(),arr2.begin(),arr2.end());
-            }
-        }
+      Py_XINCREF(Py_None);
+      return Py_None;
     }
-  else if(PyTuple_Check(pyLi))
+  if(dynamic_cast<MEDCoupling::MEDCouplingAMRAttribute *>(data))
     {
-      int size=PyTuple_Size(pyLi);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          if(PyInt_Check(o))
-            {
-              int val=(int)PyInt_AS_LONG(o);
-              arr.push_back(val);
-            }
-          else
-            {
-              std::vector<int> arr2;
-              convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
-              if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
-                  {
-                    std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " <<  recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
-                    throw INTERP_KERNEL::Exception(oss.str().c_str());
-                  }
-              arr.insert(arr.end(),arr2.begin(),arr2.end());
-            }
-        }
+      return SWIG_NewPointerObj(reinterpret_cast<void*>(data),SWIGTYPE_p_MEDCoupling__MEDCouplingAMRAttribute,owner);
     }
-  else
-    throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : not a list nor a tuple recursively !");
+  throw INTERP_KERNEL::Exception("convertDataForGodFather wrap : unrecognized data type for AMR !");
 }
 
-static void checkFillArrayWithPyList(int size1, int size2, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
+static PyObject *convertCartesianAMRPatch(MEDCoupling::MEDCouplingCartesianAMRPatchGen *patch, int owner)
 {
-  if(nbOfTuples==-1)
+  if(!patch)
     {
-      if(nbOfComp==-1) { nbOfTuples=size1; nbOfComp=size2; }
-      else { if(nbOfComp==size2) { nbOfTuples=size1; } else
-          {
-            std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
-            oss << " whereas nb of components expected is " << nbOfComp << " !";
-            throw INTERP_KERNEL::Exception(oss.str().c_str());
-          } }
+      Py_XINCREF(Py_None);
+      return Py_None;
     }
-  else
+  if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRPatchGF *>(patch))
     {
-      if(nbOfComp!=-1)
-        {
-          if((nbOfTuples!=size1 || nbOfComp!=size2))
-            {
-              if(size2!=1 || size1!=nbOfComp*nbOfTuples)
-                {
-                  std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
-                  oss << " whereas nb of tuples expected is " << nbOfTuples << " and number of components expected is " << nbOfComp << " !";
-                  throw INTERP_KERNEL::Exception(oss.str().c_str());
-                }
-            }
-        }
-      else
-        {
-          if(nbOfTuples==size1)
-            nbOfComp=size2;
-          else
-            {
-              std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
-              oss << " whereas nb of tuples expected is " << nbOfTuples << " !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
+      return SWIG_NewPointerObj(reinterpret_cast<void*>(patch),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRPatchGF,owner);
     }
-}
-
-static void fillArrayWithPyListInt3(PyObject *pyLi, int& nbOfElt, std::vector<int>& ret)
-{
-  static const char MSG[]="fillArrayWithPyListInt3 : It appears that the input list or tuple is composed by elts having different sizes !";
-  if(PyInt_Check(pyLi))
+  if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRPatch *>(patch))
     {
-      long val=PyInt_AS_LONG(pyLi);
-      if(nbOfElt==-1)
-        nbOfElt=1;
-      else
-        if(nbOfElt!=1)
-          throw INTERP_KERNEL::Exception(MSG);
-      ret.push_back(val);
+      return SWIG_NewPointerObj(reinterpret_cast<void*>(patch),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRPatch,owner);
     }
-  else if(PyList_Check(pyLi))
-    {
-      int size=PyList_Size(pyLi);
-      int tmp=0;
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          int tmp1=-1;
-          fillArrayWithPyListInt3(o,tmp1,ret);
-          tmp+=tmp1;
-        }
-      if(nbOfElt==-1)
-        nbOfElt=tmp;
-      else
-        {
-          if(nbOfElt!=tmp)
-            throw INTERP_KERNEL::Exception(MSG);
-        }
-    }
-  else if(PyTuple_Check(pyLi))
-    {
-      int size=PyTuple_Size(pyLi);
-      int tmp=0;
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          int tmp1=-1;
-          fillArrayWithPyListInt3(o,tmp1,ret);
-          tmp+=tmp1;
-        }
-      if(nbOfElt==-1)
-        nbOfElt=tmp;
-      else
-        {
-          if(nbOfElt!=tmp)
-            throw INTERP_KERNEL::Exception(MSG);
-        }
-    }
-  else
-    throw INTERP_KERNEL::Exception("fillArrayWithPyListInt3 : Unrecognized type ! Should be a composition of tuple,list,int !");
+  throw INTERP_KERNEL::Exception("convertCartesianAMRPatch wrap : unrecognized type of cartesian AMR patch !");
 }
 
-static std::vector<int> fillArrayWithPyListInt2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
+static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___add__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj)
 {
-  std::vector<int> ret;
-  int size1=-1,size2=-1;
-  if(PyList_Check(pyLi))
-    {
-      size1=PyList_Size(pyLi);
-      for(int i=0;i<size1;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          fillArrayWithPyListInt3(o,size2,ret);
-        }
-      if(size1==0)
-        size2=1;
-    }
-  else if(PyTuple_Check(pyLi))
-    {
-      size1=PyTuple_Size(pyLi);
-      for(int i=0;i<size1;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          fillArrayWithPyListInt3(o,size2,ret);
-        }
-      if(size1==0)
-        size2=1;
-    }
-  else
-    throw INTERP_KERNEL::Exception("fillArrayWithPyListInt2 : Unrecognized type ! Should be a tuple or a list !");
+  const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__add__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
+  const char msg2[]="in MEDCouplingFieldDouble.__add__ : self field has no Array of values set !";
+  void *argp;
   //
-  checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
-  return ret;
-}
-
-static PyObject *convertDblArrToPyList(const double *ptr, int size) throw(INTERP_KERNEL::Exception)
-{
-  PyObject *ret=PyList_New(size);
-  for(int i=0;i<size;i++)
-    PyList_SetItem(ret,i,PyFloat_FromDouble(ptr[i]));
-  return ret;
-}
-
-static PyObject *convertDblArrToPyList2(const std::vector<double>& v) throw(INTERP_KERNEL::Exception)
-{
-  int size=v.size();
-  PyObject *ret=PyList_New(size);
-  for(int i=0;i<size;i++)
-    PyList_SetItem(ret,i,PyFloat_FromDouble(v[i]));
-  return ret;
-}
-
-static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
-{
-  PyObject *ret=PyList_New(nbOfTuples);
-  for(int i=0;i<nbOfTuples;i++)
-    {
-      PyObject *t=PyTuple_New(nbOfComp);
-      for(int j=0;j<nbOfComp;j++)
-        PyTuple_SetItem(t,j,PyFloat_FromDouble(vals[i*nbOfComp+j]));
-      PyList_SetItem(ret,i,t);
-    }
-  return ret;
-}
-
-static double *convertPyToNewDblArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
-{
-  if(PyList_Check(pyLi))
-    {
-      *size=PyList_Size(pyLi);
-      double *tmp=new double[*size];
-      for(int i=0;i<*size;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          if(PyFloat_Check(o))
-            {
-              double val=PyFloat_AS_DOUBLE(o);
-              tmp[i]=val;
-            }
-          else if(PyInt_Check(o))
-            {
-              long val0=PyInt_AS_LONG(o);
-              double val=val0;
-              tmp[i]=val;
-            }
-          else
-            {
-              delete [] tmp;
-              throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : list must contain floats/integers only");
-            }
-        }
-      return tmp;
-    }
-  else if(PyTuple_Check(pyLi))
-    {
-      *size=PyTuple_Size(pyLi);
-      double *tmp=new double[*size];
-      for(int i=0;i<*size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          if(PyFloat_Check(o))
-            {
-              double val=PyFloat_AS_DOUBLE(o);
-              tmp[i]=val;
-            }
-          else if(PyInt_Check(o))
-            {
-              long val0=PyInt_AS_LONG(o);
-              double val=val0;
-              tmp[i]=val;
-            }
-          else
-            {
-              delete [] tmp;
-              throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : tuple must contain floats/integers only");
-            }
-        }
-      return tmp;
-    }
-  else
-    throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : not a list");
-}
-
-static void fillArrayWithPyListDbl3(PyObject *pyLi, int& nbOfElt, std::vector<double>& ret)
-{
-  static const char MSG[]="fillArrayWithPyListDbl3 : It appears that the input list or tuple is composed by elts having different sizes !";
-  if(PyFloat_Check(pyLi))
+  if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
     {
-      if(nbOfElt==-1)
-        nbOfElt=1;
+      MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
+      if(other)
+        return (*self)+(*other);
       else
-        if(nbOfElt!=1)
-          throw INTERP_KERNEL::Exception(MSG);
-      double val=PyFloat_AS_DOUBLE(pyLi);
-      ret.push_back(val);
-    }
-  else if(PyInt_Check(pyLi))
-    {
-      long val0=PyInt_AS_LONG(pyLi);
-      double val=val0;
-      if(nbOfElt==-1)
-        nbOfElt=1;
-      else
-        if(nbOfElt!=1)
-          throw INTERP_KERNEL::Exception(MSG);
-      ret.push_back(val);
-    }
-  else if(PyList_Check(pyLi))
-    {
-      int size=PyList_Size(pyLi);
-      int tmp=0;
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          int tmp1=-1;
-          fillArrayWithPyListDbl3(o,tmp1,ret);
-          tmp+=tmp1;
-        }
-      if(nbOfElt==-1)
-        nbOfElt=tmp;
-      else
-        {
-          if(nbOfElt!=tmp)
-            throw INTERP_KERNEL::Exception(MSG);
-        }
+        throw INTERP_KERNEL::Exception(msg);
     }
-  else if(PyTuple_Check(pyLi))
+  //
+  double val;
+  MEDCoupling::DataArrayDouble *a;
+  MEDCoupling::DataArrayDoubleTuple *aa;
+  std::vector<double> bb;
+  mcIdType sw;
+  convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
+  switch(sw)
+    {
+    case 1:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
+        ret->applyLin(1.,val);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 2:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),a);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 3:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),aaa);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 4:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),aaa);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    default:
+      { throw INTERP_KERNEL::Exception(msg); }
+    }
+}
+
+static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___radd__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj)
+{
+  return MEDCoupling_MEDCouplingFieldDouble___add__Impl(self,obj);
+}
+
+static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rsub__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj)
+{
+  const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__rsub__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
+  const char msg2[]="in MEDCouplingFieldDouble.__rsub__ : self field has no Array of values set !";
+  void *argp;
+  //
+  if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
     {
-      int size=PyTuple_Size(pyLi);
-      int tmp=0;
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          int tmp1=-1;
-          fillArrayWithPyListDbl3(o,tmp1,ret);
-          tmp+=tmp1;
-        }
-      if(nbOfElt==-1)
-        nbOfElt=tmp;
+      MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
+      if(other)
+        return (*other)-(*self);
       else
-        {
-          if(nbOfElt!=tmp)
-            throw INTERP_KERNEL::Exception(MSG);
-        }
+        throw INTERP_KERNEL::Exception(msg);
     }
-  else
-    throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl3 : Unrecognized type ! Should be a composition of tuple,list,int and float !");
-}
-
-static std::vector<double> fillArrayWithPyListDbl2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
-{
-  std::vector<double> ret;
-  int size1=-1,size2=-1;
-  if(PyList_Check(pyLi))
-    {
-      size1=PyList_Size(pyLi);
-      for(int i=0;i<size1;i++)
-        {
-          PyObject *o=PyList_GetItem(pyLi,i);
-          fillArrayWithPyListDbl3(o,size2,ret);
-        }
-      if(size1==0)
-        size2=1;
-    }
-  else if(PyTuple_Check(pyLi))
-    {
-      size1=PyTuple_Size(pyLi);
-      for(int i=0;i<size1;i++)
-        {
-          PyObject *o=PyTuple_GetItem(pyLi,i);
-          fillArrayWithPyListDbl3(o,size2,ret);
-        }
-      if(size1==0)
-        size2=1;
-    }
-  else
-    throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !");
   //
-  checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
-  return ret;
-}
-
-//convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(pyLi,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh")
-template<class T>
-static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, const char *typeStr, typename std::vector<T>& ret)
-{
-  void *argp=0;
-  if(PyList_Check(pyLi))
-    {
-      int size=PyList_Size(pyLi);
-      ret.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *obj=PyList_GetItem(pyLi,i);
-          int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
-          if(!SWIG_IsOK(status))
-            throw INTERP_KERNEL::Exception("list must contain only MEDCouplingUMesh");
-          T arg=reinterpret_cast< T >(argp);
-          ret[i]=arg;
-        }
-    }
-  else if(PyTuple_Check(pyLi))
-    {
-      int size=PyTuple_Size(pyLi);
-      ret.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *obj=PyTuple_GetItem(pyLi,i);
-          int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
-          if(!SWIG_IsOK(status))
-            {
-              std::ostringstream oss; oss << "tuple must contain only " << typeStr;
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-          T arg=reinterpret_cast< T >(argp);
-          ret[i]=arg;
-        }
-    }
-  else if(SWIG_IsOK(SWIG_ConvertPtr(pyLi,&argp,ty,0|0)))
-    {
-      ret.resize(1);
-      T arg=reinterpret_cast< T >(argp);
-      ret[0]=arg;
-    }
-  else
-    throw INTERP_KERNEL::Exception("convertFromPyObjVectorOfObj : not a list nor a tuple");
-}
-
-/*!
- * if python int -> cpp int sw=1
- * if python list[int] -> cpp vector<int> sw=2
- * if python tuple[int] -> cpp vector<int> sw=2
- * if python DataArrayInt -> cpp DataArrayInt sw=3
- * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
- *
- * switch between (int,vector<int>,DataArrayInt)
- */
-static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, ParaMEDMEM::DataArrayInt *& daIntTyypp, ParaMEDMEM::DataArrayIntTuple *&daIntTuple) throw(INTERP_KERNEL::Exception)
-{
-  sw=-1;
-  if(PyInt_Check(value))
-    {
-      iTyypp=(int)PyInt_AS_LONG(value);
-      sw=1;
-      return;
-    }
-  if(PyTuple_Check(value))
-    {
-      int size=PyTuple_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyInt_Check(o))
-            stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
-    }
-  if(PyList_Check(value))
-    {
-      int size=PyList_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyInt_Check(o))
-            stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
-    }
+  double val;
+  MEDCoupling::DataArrayDouble *a;
+  MEDCoupling::DataArrayDoubleTuple *aa;
+  std::vector<double> bb;
+  mcIdType sw;
+  convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
+  switch(sw)
+    {
+    case 1:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
+        ret->applyLin(-1.,val);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 2:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(a,self->getArray());
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 3:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(aaa,self->getArray());
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 4:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(aaa,self->getArray());
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    default:
+      { throw INTERP_KERNEL::Exception(msg); }
+    }
+}
+
+static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___mul__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj)
+{
+  const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__mul__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
+  const char msg2[]="in MEDCouplingFieldDouble.__mul__ : self field has no Array of values set !";
   void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
-  if(SWIG_IsOK(status))
-    {
-      daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
-      sw=3;
-      return;
-    }
-  status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      daIntTuple=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
-      sw=4;
-      return ;
-    }
-  throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
-}
-
-/*!
- * if python double -> cpp double sw=1
- * if python int -> cpp double sw=1
- * if python list[double] -> cpp vector<double> sw=2
- * if python list[int] -> cpp vector<double> sw=2
- * if python tuple[double] -> cpp vector<double> sw=2
- * if python tuple[int] -> cpp vector<double> sw=2
- * if python DataArrayDouble -> cpp DataArrayDouble sw=3
- *
- * switch between (int,vector<int>,DataArrayInt)
- */
-static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, ParaMEDMEM::DataArrayDouble *& daIntTyypp) throw(INTERP_KERNEL::Exception)
-{
-  sw=-1;
-  if(PyFloat_Check(value))
-    {
-      iTyypp=PyFloat_AS_DOUBLE(value);
-      sw=1;
-      return;
-    }
-  if(PyInt_Check(value))
-    {
-      iTyypp=(double)PyInt_AS_LONG(value);
-      sw=1;
-      return;
-    }
-  if(PyTuple_Check(value))
-    {
-      int size=PyTuple_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyFloat_Check(o))
-            stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
-    }
-  if(PyList_Check(value))
+  //
+  if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
     {
-      int size=PyList_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyFloat_Check(o))
-            stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
+      MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
+      if(other)
+        return (*self)*(*other);
+      else
+        throw INTERP_KERNEL::Exception(msg);
     }
+  //
+  double val;
+  MEDCoupling::DataArrayDouble *a;
+  MEDCoupling::DataArrayDoubleTuple *aa;
+  std::vector<double> bb;
+  mcIdType sw;
+  convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
+  switch(sw)
+    {
+    case 1:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
+        ret->applyLin(val,0.);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 2:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),a);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 3:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),aaa);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 4:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),aaa);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    default:
+      { throw INTERP_KERNEL::Exception(msg); }
+    }
+}
+
+MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rmul__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj)
+{
+  return MEDCoupling_MEDCouplingFieldDouble___mul__Impl(self,obj);
+}
+
+MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rdiv__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj)
+{
+  const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__rdiv__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
+  const char msg2[]="in MEDCouplingFieldDouble.__div__ : self field has no Array of values set !";
   void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
-  if(!SWIG_IsOK(status))
-    throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
-  daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
-  sw=3;
-}
-
-/*!
- * if python double -> cpp double sw=1
- * if python int -> cpp double sw=1
- * if python list[double] -> cpp vector<double> sw=2
- * if python list[int] -> cpp vector<double> sw=2
- * if python tuple[double] -> cpp vector<double> sw=2
- * if python tuple[int] -> cpp vector<double> sw=2
- * if python DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
- *
- * switch between (int,vector<int>,DataArrayInt)
- */
-static void convertObjToPossibleCpp44(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, ParaMEDMEM::DataArrayDoubleTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
-{
-  sw=-1;
-  if(PyFloat_Check(value))
-    {
-      iTyypp=PyFloat_AS_DOUBLE(value);
-      sw=1;
-      return;
-    }
-  if(PyInt_Check(value))
-    {
-      iTyypp=(double)PyInt_AS_LONG(value);
-      sw=1;
-      return;
-    }
-  if(PyTuple_Check(value))
+  //
+  if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
     {
-      int size=PyTuple_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyFloat_Check(o))
-            stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
+      MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
+      if(other)
+        return (*other)/(*self);
+      else
+        throw INTERP_KERNEL::Exception(msg);
     }
-  if(PyList_Check(value))
-    {
-      int size=PyList_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyFloat_Check(o))
-            stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
+  //
+  double val;
+  MEDCoupling::DataArrayDouble *a;
+  MEDCoupling::DataArrayDoubleTuple *aa;
+  std::vector<double> bb;
+  mcIdType sw;
+  convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb);
+  switch(sw)
+    {
+    case 1:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
+        ret->applyInv(val);
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 2:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(a,self->getArray());
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 3:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(aaa,self->getArray());
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    case 4:
+      {
+        if(!self->getArray())
+          throw INTERP_KERNEL::Exception(msg2);
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
+        MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(aaa,self->getArray());
+        MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
+        ret2->setArray(ret);
+        return ret2.retn();
+      }
+    default:
+      { throw INTERP_KERNEL::Exception(msg); }
     }
-  void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
-  if(!SWIG_IsOK(status))
-    throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDoubleTuple");
-  daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
-  sw=3;
 }
 
-/*!
- * if python int -> cpp int sw=1
- * if python list[int] -> cpp vector<int> sw=2
- * if python tuple[int] -> cpp vector<int> sw=2
- * if python slicp -> cpp pair sw=3
- * if python DataArrayInt -> cpp DataArrayInt sw=4
- *
- * switch between (int,vector<int>,DataArrayInt)
- */
-static void convertObjToPossibleCpp2(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
-{
-  const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple";
-  sw=-1;
-  if(PyInt_Check(value))
-    {
-      iTyypp=(int)PyInt_AS_LONG(value);
-      sw=1;
-      return;
-    }
-  if(PyTuple_Check(value))
-    {
-      int size=PyTuple_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyInt_Check(o))
-            stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
-    }
-  if(PyList_Check(value))
-    {
-      int size=PyList_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyInt_Check(o))
-            stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
-    }
-  if(PySlice_Check(value))
-    {
-      Py_ssize_t strt=2,stp=2,step=2;
-      PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
-      if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
-        if(nbelem!=0 || strt!=0 || stp!=0)
+template<class T>
+typename MEDCoupling::Traits<T>::FieldType *fieldT_buildSubPart(const MEDCoupling::MEDCouplingFieldT<T> *self, PyObject *li)
+{
+  mcIdType sw;
+  mcIdType singleVal;
+  std::vector<mcIdType> multiVal;
+  std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
+  MEDCoupling::DataArrayIdType *daIntTyypp=0;
+  const MEDCoupling::MEDCouplingMesh *mesh=self->getMesh();
+  if(!mesh)
+    throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : field lies on a null mesh !");
+  mcIdType nbc=mesh->getNumberOfCells();
+  convertIntStarOrSliceLikePyObjToCpp(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+  switch(sw)
+    {
+    case 1:
+      {
+        if(singleVal>=nbc)
           {
-            std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elements is : " << nbelem;
+            std::ostringstream oss;
+            oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
             throw INTERP_KERNEL::Exception(oss.str().c_str());
           }
-      p.first=strt;
-      p.second.first=stp;
-      p.second.second=step;
-      sw=3;
-      return ;
-    }
-  void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
-  if(SWIG_IsOK(status))
-    {
-      daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
-      if(!daIntTyypp)
-        {
-          std::ostringstream oss; oss << msg << " Instance in null !";
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-      sw=4;
-      return ;
-    }
-  status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);;
-  if(SWIG_IsOK(status))
-    {
-      ParaMEDMEM::DataArrayIntTuple *tmp=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
-      if(!tmp)
-        {
-          std::ostringstream oss; oss << msg << " Instance in null !";
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-      stdvecTyypp.resize(tmp->getNumberOfCompo());
-      std::copy(tmp->getConstPointer(),tmp->getConstPointer()+tmp->getNumberOfCompo(),stdvecTyypp.begin());
-      sw=2;
-      return ;
-    }
-  throw INTERP_KERNEL::Exception(msg);
-}
-
-static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayIntTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
-{
-  sw=-1;
-  if(PyInt_Check(value))
-    {
-      iTyypp=(int)PyInt_AS_LONG(value);
-      sw=1;
-      return;
-    }
-  if(PyTuple_Check(value))
-    {
-      int size=PyTuple_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyInt_Check(o))
-            stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
-    }
-  if(PyList_Check(value))
-    {
-      int size=PyList_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyInt_Check(o))
-            stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2;
-      return;
-    }
-  if(PySlice_Check(value))
-    {
-      Py_ssize_t strt=2,stp=2,step=2;
-      PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
-      if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
-        if(nbelem!=0 || strt!=0 || stp!=0)
+        if(singleVal>=0)
+          return self->buildSubPart(&singleVal,&singleVal+1);
+        else
           {
-            std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elements is : " << nbelem;
-            throw INTERP_KERNEL::Exception(oss.str().c_str());
+            if(nbc+singleVal>0)
+              {
+                mcIdType tmp=nbc+singleVal;
+                return self->buildSubPart(&tmp,&tmp+1);
+              }
+            else
+              {
+                std::ostringstream oss;
+                oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+                throw INTERP_KERNEL::Exception(oss.str().c_str());
+              }
           }
-      p.first=strt;
-      p.second.first=stp;
-      p.second.second=step;
-      sw=3;
-      return ;
+      }
+    case 2:
+      {
+        return self->buildSubPart(&multiVal[0],&multiVal[0]+multiVal.size());
+      }
+    case 3:
+      {
+        return self->buildSubPartRange(slic.first,slic.second.first,slic.second.second);
+      }
+    case 4:
+      {
+        if(!daIntTyypp)
+          throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : null instance has been given in input !");
+        daIntTyypp->checkAllocated();
+        return self->buildSubPart(daIntTyypp->begin(),daIntTyypp->end());
+      }
+    default:
+      throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : unrecognized type in input ! Possibilities are : int, list or tuple of int DataArrayIdType instance !");
     }
-  void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
-  if(!SWIG_IsOK(status))
-    throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayIntTuple");
-  daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
-  sw=4;
 }
 
-/*!
- * if value int -> cpp it sw=1
- * if value list[int] -> vt sw=2
- * if value tuple[int] -> vt sw=2
- * if value slice -> pt sw=3
- * if value DataArrayInt -> dt sw=4
- * if value tuple [int,int] -> cpp it,ip sw=5
- * if value tuple [list[int],int] -> cpp vt,ip sw=6
- * if value tuple [tuple[int],int] -> cpp vt,ip sw=6
- * if value tuple [slice,int] -> cpp pt,ip sw=7
- * if value tuple [DaI,int] -> cpp dt,ip sw=8
- * if value tuple [int,list[int]] -> cpp it,vc sw=9
- * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10
- * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10
- * if value tuple [slice,list[int]] -> cpp pt,vc sw=11
- * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12
- * if value tuple [int,tuple[int]] -> cpp it,vc sw=9
- * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10
- * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10
- * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11
- * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12
- * if value tuple [int,slice] -> cpp it,pc sw=13
- * if value tuple [list[int],slice] -> cpp vt,pc sw=14
- * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14
- * if value tuple [slice,slice] -> cpp pt,pc sw=15
- * if value tuple [DaI,slice] -> cpp dt,pc sw=16
- *
- * switch between (int,vector<int>,DataArrayInt)
- */
-static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
-                                     std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
-                                     ParaMEDMEM::DataArrayInt *&dt, ParaMEDMEM::DataArrayInt *&dc) throw(INTERP_KERNEL::Exception)
+template<class T>
+typename MEDCoupling::Traits<T>::FieldType *fieldT__getitem__(const MEDCoupling::MEDCouplingFieldT<T> *self, PyObject *li)
 {
-  if(!PyTuple_Check(value))
-    {
-      convertObjToPossibleCpp2(value,nbTuple,sw,it,vt,pt,dt);
-      return ;
-    }
-  else
+  const char msg[]="MEDCouplingFieldDouble::__getitem__ : invalid call  Available API are : \n-myField[DataArrayIdType]\n-myField[slice]\n-myField[pythonListOfCellIds]\n-myField[integer]\n-myField[DataArrayIdType,1]\n-myField[slice,1]\n-myField[pythonListOfCellIds,1]\n-myField[integer,1]\n";
+  if(PyTuple_Check(li))
     {
-      int sz=PyTuple_Size(value);
+      Py_ssize_t sz=PyTuple_Size(li);
       if(sz!=2)
-        throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
-      PyObject *ob0=PyTuple_GetItem(value,0);
-      int sw1,sw2;
-      convertObjToPossibleCpp2(ob0,nbTuple,sw1,it,vt,pt,dt);
-      PyObject *ob1=PyTuple_GetItem(value,1);
-      convertObjToPossibleCpp2(ob1,nbCompo,sw2,ic,vc,pc,dc);
-      sw=4*sw2+sw1;
+        throw INTERP_KERNEL::Exception(msg);
+      PyObject *elt0=PyTuple_GetItem(li,0),*elt1=PyTuple_GetItem(li,1);
+      mcIdType sw;
+      std::size_t singleVal;
+      std::vector<std::size_t> multiVal;
+      std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
+      MEDCoupling::DataArrayIdType *daIntTyypp=0;
+      if(!self->getArray())
+        throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::__getitem__ : no array set on field to deduce number of components !");
+      try
+      { convertIntStarOrSliceLikePyObjToCpp(elt1,ToIdType(self->getArray()->getNumberOfComponents()),sw,singleVal,multiVal,slic,daIntTyypp); }
+      catch(INTERP_KERNEL::Exception& e)
+        { std::ostringstream oss; oss << "MEDCouplingFieldDouble::__getitem__ : invalid type in 2nd parameter (compo) !" << e.what(); throw INTERP_KERNEL::Exception(oss.str().c_str()); }
+      typename MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::FieldType > ret0(fieldT_buildSubPart<T>(self,elt0));
+      typename MEDCoupling::Traits<T>::ArrayType *ret0Arr=ret0->getArray();
+      if(!ret0Arr)
+        throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::__getitem__ : no array exists to apply restriction on component on it !");
+      switch(sw)
+        {
+        case 1:
+          {
+            std::vector<std::size_t> v2(1,singleVal);
+            MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aarr(ret0Arr->keepSelectedComponents(v2));
+            ret0->setArray(aarr);
+            return ret0.retn();
+          }
+        case 2:
+          {
+            MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aarr(ret0Arr->keepSelectedComponents(multiVal));
+            ret0->setArray(aarr);
+            return ret0.retn();
+          }
+        case 3:
+          {
+            mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(slic.first,slic.second.first,slic.second.second,"MEDCouplingFieldDouble::__getitem__ : invalid range in 2nd parameter (components) !"));
+            std::vector<std::size_t> v2(nbOfComp);
+            for(mcIdType i=0;i<nbOfComp;i++)
+              v2[i]=slic.first+i*slic.second.second;
+            MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aarr(ret0Arr->keepSelectedComponents(v2));
+            ret0->setArray(aarr);
+            return ret0.retn();
+          }
+        default:
+          throw INTERP_KERNEL::Exception(msg);
+        }
     }
+  else
+    return fieldT_buildSubPart<T>(self,li);
 }
 
-/*!
- * if value int -> cpp val sw=1
- * if value double -> cpp val sw=1
- * if value DataArrayDouble -> cpp DataArrayDouble sw=2
- * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
- * if value list[int,double] -> cpp std::vector<double> sw=4
- * if value tuple[int,double] -> cpp std::vector<double> sw=4
- */
-static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f)
+template<class FIELDT>
+PyObject *field_getTinySerializationInformation(const FIELDT *self)
 {
-  sw=-1;
-  if(PyFloat_Check(value))
-    {
-      val=PyFloat_AS_DOUBLE(value);
-      sw=1;
-      return;
-    }
-  if(PyInt_Check(value))
-    {
-      val=(double)PyInt_AS_LONG(value);
-      sw=1;
-      return;
-    }
-  if(PyTuple_Check(value))
-    {
-      int size=PyTuple_Size(value);
-      f.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyFloat_Check(o))
-            f[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            f[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=4;
-      return;
-    }
-  if(PyList_Check(value))
-    {
-      int size=PyList_Size(value);
-      f.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyFloat_Check(o))
-            f[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            f[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=4;
-      return;
-    }
-  void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
-      sw=2;
-      return ;
-    }
-  status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
-      sw=3;
-      return ;
-    }
-  throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
+  std::vector<double> a0;
+  std::vector<mcIdType> a1;
+  std::vector<std::string> a2;
+  self->getTinySerializationDbleInformation(a0);
+  self->getTinySerializationIntInformation(a1);
+  self->getTinySerializationStrInformation(a2);
+  //
+  PyObject *ret(PyTuple_New(3));
+  PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0));
+  PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1));
+  std::size_t sz(a2.size());
+  PyObject *ret2(PyList_New(sz));
+  {
+    for(std::size_t i=0;i<sz;i++)
+      PyList_SetItem(ret2,i,PyString_FromString(a2[i].c_str()));
+  }
+  PyTuple_SetItem(ret,2,ret2);
+  return ret;
 }
 
-/*!
- * if value int -> cpp val sw=1
- * if value double -> cpp val sw=1
- * if value DataArrayDouble -> cpp DataArrayDouble sw=2
- * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
- * if value list[int,double] -> cpp std::vector<double> sw=4
- * if value tuple[int,double] -> cpp std::vector<double> sw=4
- */
-static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f,
-                                                   const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt) throw(INTERP_KERNEL::Exception)
-{
-  sw=-1;
-  if(PyFloat_Check(value))
-    {
-      val=PyFloat_AS_DOUBLE(value);
-      sw=1;
-      if(nbTuplesExpected*nbCompExpected!=1)
-        {
-          std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyFloat) !"; 
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-      return &val;
-    }
-  if(PyInt_Check(value))
-    {
-      val=(double)PyInt_AS_LONG(value);
-      sw=1;
-      if(nbTuplesExpected*nbCompExpected!=1)
-        {
-          std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !"; 
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-      return &val;
-    }
-  if(PyTuple_Check(value) || PyList_Check(value))
-    {
-      try
-        {
-          int tmp1=nbTuplesExpected,tmp2=nbCompExpected;
-          std::vector<double> ret=fillArrayWithPyListDbl2(value,tmp1,tmp2);
-          sw=4;
-          f=ret;
-          return &f[0];
-        }
-      catch(INTERP_KERNEL::Exception& e) { throw e; }
-    }
-  void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
-      sw=2;
-      if(d)
-        {
-          if(d->getNumberOfTuples()==nbTuplesExpected)
-            {
-              if(d->getNumberOfComponents()==nbCompExpected)
-                {
-                  return d->getConstPointer();
-                }
-              else
-                {
-                  std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
-                  throw INTERP_KERNEL::Exception(oss.str().c_str());
-                }
-            }
-          else
-            {
-              std::ostringstream oss; oss << msg << " input DataArrayDouble should have a number of tuples equal to " << nbTuplesExpected << " and there are " << d->getNumberOfTuples() << " tuples !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      else
-        {
-          if(throwIfNullPt)
-            {
-              std::ostringstream oss; oss << msg << " null pointer not accepted!";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-          else
-            return 0;
-        }
-    }
-  status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
-      sw=3;
-      if(e->getNumberOfCompo()==nbCompExpected)
-        {
-          if(nbTuplesExpected==1)
-            return e->getConstPointer();
-          else
-            {
-              std::ostringstream oss; oss << msg << "nb of tuples expected to be " << nbTuplesExpected << " , and input DataArrayDoubleTuple has always one tuple by contruction !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      else
-        {
-          std::ostringstream oss; oss << msg << "nb of components expected to be " <<  nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-    }
-  throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
+template<class T>
+PyObject *field_serialize(const typename MEDCoupling::Traits<T>::FieldType *self)
+{
+  MEDCoupling::DataArrayIdType *ret0(0);
+  std::vector<typename MEDCoupling::Traits<T>::ArrayType *> ret1;
+  self->serialize(ret0,ret1);
+  if(ret0)
+    ret0->incrRef();
+  std::size_t sz(ret1.size());
+  PyObject *ret(PyTuple_New(2));
+  PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
+  PyObject *ret1Py(PyList_New(sz));
+  for(std::size_t i=0;i<sz;i++)
+    {
+      if(ret1[i])
+        ret1[i]->incrRef();
+      PyList_SetItem(ret1Py,i,convertArray(ret1[i],SWIG_POINTER_OWN | 0));
+    }
+  PyTuple_SetItem(ret,1,ret1Py);
+  return ret;
 }
 
-/*!
- * if value int -> cpp val sw=1
- * if value double -> cpp val sw=1
- * if value DataArrayDouble -> cpp DataArrayDouble sw=2
- * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
- * if value list[int,double] -> cpp std::vector<double> sw=4
- * if value tuple[int,double] -> cpp std::vector<double> sw=4
- */
-static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f,
-                                                    const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
+template<class FIELDT>
+PyObject *field__getnewargs__(FIELDT *self)
 {
-  sw=-1;
-  if(PyFloat_Check(value))
-    {
-      val=PyFloat_AS_DOUBLE(value);
-      sw=1;
-      if(nbCompExpected!=1)
-        {
-          std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyFloat) !"; 
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-      nbTuples=1;
-      return &val;
-    }
-  if(PyInt_Check(value))
-    {
-      val=(double)PyInt_AS_LONG(value);
-      sw=1;
-      if(nbCompExpected!=1)
-        {
-          std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyInt) !"; 
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-      nbTuples=1;
-      return &val;
-    }
-  if(PyTuple_Check(value))
-    {
-      int size=PyTuple_Size(value);
-      f.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyFloat_Check(o))
-            f[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            f[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=4;
-      if(size%nbCompExpected!=0)
-        {
-          std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !"; 
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-      nbTuples=size/nbCompExpected;
-      return &f[0];
-    }
-  if(PyList_Check(value))
-    {
-      int size=PyList_Size(value);
-      f.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyFloat_Check(o))
-            f[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            f[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=4;
-      if(size%nbCompExpected!=0)
-        {
-          std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !"; 
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-      nbTuples=size/nbCompExpected;
-      return &f[0];
-    }
-  void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
-      sw=2;
-      if(d)
-        {
-          if(d->getNumberOfComponents()==nbCompExpected)
-            {
-              nbTuples=d->getNumberOfTuples();
-              return d->getConstPointer();
-            }
-          else
-            {
-              std::ostringstream oss; oss << msg << "nb of components expected to be a multiple of " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      else
-        {
-          if(throwIfNullPt)
-            {
-              std::ostringstream oss; oss << msg << " null pointer not accepted!";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-          else
-            { nbTuples=0; return 0; }
-        }
-    }
-  status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
-      sw=3;
-      if(e)
-        {
-          if(e->getNumberOfCompo()==nbCompExpected)
-            {
-              nbTuples=1;
-              return e->getConstPointer();
-            }
-          else
-            {
-              std::ostringstream oss; oss << msg << "nb of components expected to be " <<  nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      else
-        {
-          if(throwIfNullPt)
-            {
-              std::ostringstream oss; oss << msg << " null pointer not accepted!";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-          else
-            { nbTuples=0; return 0; }
-        }
-    }
-  throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
+  self->checkConsistencyLight();
+  PyObject *ret(PyTuple_New(1));
+  PyObject *ret0(PyDict_New());
+  {
+    PyObject *a(PyInt_FromLong(0)),*b(PyInt_FromLong(self->getTypeOfField())),*c(PyInt_FromLong(self->getTimeDiscretization()));
+    PyObject *d(PyTuple_New(2)); PyTuple_SetItem(d,0,b); PyTuple_SetItem(d,1,c);
+    PyDict_SetItem(ret0,a,d);
+    Py_DECREF(a); Py_DECREF(d);
+  }
+  PyTuple_SetItem(ret,0,ret0);
+  return ret;
 }
 
-/*!
- * if value int -> cpp val sw=1
- * if value double -> cpp val sw=1
- * if value DataArrayDouble -> cpp DataArrayDouble sw=2
- * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
- * if value list[int,double] -> cpp std::vector<double> sw=4
- * if value tuple[int,double] -> cpp std::vector<double> sw=4
- */
-static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
-                                                          const char *msg, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
+template<class FIELDT>
+PyObject *field__getstate__(const FIELDT *self, PyObject *(*tinyserial)(const FIELDT *), PyObject *(*bigserial)(const FIELDT *))
 {
-  ParaMEDMEM::DataArrayDouble *d=0;
-  ParaMEDMEM::DataArrayDoubleTuple *e=0;
-  sw=-1;
-  if(PyFloat_Check(value))
-    {
-      val=PyFloat_AS_DOUBLE(value);
-      sw=1;
-      nbTuples=1;
-      return &val;
-    }
-  if(PyInt_Check(value))
-    {
-      val=(double)PyInt_AS_LONG(value);
-      sw=1;
-      nbTuples=1;
-      return &val;
-    }
-  if(PyTuple_Check(value))
-    {
-      int size=PyTuple_Size(value);
-      f.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyFloat_Check(o))
-            f[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            f[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=4;
-      nbTuples=size;
-      return &f[0];
-    }
-  if(PyList_Check(value))
-    {
-      int size=PyList_Size(value);
-      f.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyFloat_Check(o))
-            f[i]=PyFloat_AS_DOUBLE(o);
-          else if(PyInt_Check(o))
-            f[i]=(double)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=4;
-      nbTuples=size;
-      return &f[0];
-    }
-  void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
-      sw=2;
-      if(d)
-        {
-          if(d->getNumberOfComponents()==1)
-            {
-              nbTuples=d->getNumberOfTuples();
-              return d->getConstPointer();
-            }
-          else
-            {
-              std::ostringstream oss; oss << msg << "nb of components expected to be one, and input has " << d->getNumberOfComponents() << " components !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      else
-        {
-          if(throwIfNullPt)
-            {
-              std::ostringstream oss; oss << msg << " null pointer not accepted!";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-          else
-            { nbTuples=0; return 0; }
-        }
-    }
-  status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
-      sw=3;
-      if(e)
-        {
-          nbTuples=e->getNumberOfCompo();
-          return e->getConstPointer();
-        }
-      else
-        {
-          if(throwIfNullPt)
-            {
-              std::ostringstream oss; oss << msg << " null pointer not accepted!";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-          else
-            { nbTuples=0; return 0; }
-        }
-    }
-  throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
+  self->checkConsistencyLight();
+  PyObject *ret0(tinyserial(self));
+  PyObject *ret1(bigserial(self));
+  const MEDCoupling::MEDCouplingMesh *mesh(self->getMesh());
+  if(mesh)
+    mesh->incrRef();
+  PyObject *ret(PyTuple_New(3));
+  PyTuple_SetItem(ret,0,ret0);
+  PyTuple_SetItem(ret,1,ret1);
+  PyTuple_SetItem(ret,2,convertMesh(const_cast<MEDCoupling::MEDCouplingMesh *>(mesh),SWIG_POINTER_OWN | 0 ));
+  return ret;
 }
 
-/*!
- * if python int -> cpp int sw=1
- * if python list[int] -> cpp vector<int> sw=2
- * if python tuple[int] -> cpp vector<int> sw=2
- * if python DataArrayInt -> cpp DataArrayInt sw=3
- * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
- *
- * switch between (int,vector<int>,DataArrayInt)
- */
-static const int *convertObjToPossibleCpp1_Safe(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector<int>& stdvecTyypp) throw(INTERP_KERNEL::Exception)
-{
-  sw=-1;
-  if(PyInt_Check(value))
-    {
-      iTyypp=(int)PyInt_AS_LONG(value);
-      sw=1; sz=1;
-      return &iTyypp;
-    }
-  if(PyTuple_Check(value))
-    {
-      int size=PyTuple_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyTuple_GetItem(value,i);
-          if(PyInt_Check(o))
-            stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2; sz=size;
-      return &stdvecTyypp[0];
-    }
-  if(PyList_Check(value))
-    {
-      int size=PyList_Size(value);
-      stdvecTyypp.resize(size);
-      for(int i=0;i<size;i++)
-        {
-          PyObject *o=PyList_GetItem(value,i);
-          if(PyInt_Check(o))
-            stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
-          else
-            {
-              std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      sw=2; sz=size;
-      return &stdvecTyypp[0];
+template<class T>
+void field__setstate__(typename MEDCoupling::Traits<T>::FieldType *self, PyObject *inp)
+{
+  static const char MSG[]="MEDCouplingFieldDouble.__setstate__ : expected input is a tuple of size 3 !";
+  if(!PyTuple_Check(inp))
+    throw INTERP_KERNEL::Exception(MSG);
+  std::size_t sz(PyTuple_Size(inp));
+  if(sz!=3)
+    throw INTERP_KERNEL::Exception(MSG);
+  // mesh
+  PyObject *elt2(PyTuple_GetItem(inp,2));
+  void *argp=0;
+  int status(SWIG_ConvertPtr(elt2,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingMesh,0|0));
+  if(!SWIG_IsOK(status))
+    throw INTERP_KERNEL::Exception(MSG);
+  self->setMesh(reinterpret_cast< const MEDCoupling::MEDCouplingMesh * >(argp));
+  //
+  PyObject *elt0(PyTuple_GetItem(inp,0));
+  PyObject *elt1(PyTuple_GetItem(inp,1));
+  std::vector<double> a0;
+  std::vector<mcIdType> a1;
+  std::vector<std::string> a2;
+  MEDCoupling::DataArrayIdType *b0(0);
+  std::vector<typename MEDCoupling::Traits<T>::ArrayType *>b1;
+  {
+    if(!PyTuple_Check(elt0) && PyTuple_Size(elt0)!=3)
+      throw INTERP_KERNEL::Exception(MSG);
+    PyObject *a0py(PyTuple_GetItem(elt0,0)),*a1py(PyTuple_GetItem(elt0,1)),*a2py(PyTuple_GetItem(elt0,2));
+    mcIdType tmp(-1);
+    fillArrayWithPyListDbl3(a0py,tmp,a0);
+    convertPyToNewIntArr3(a1py,a1);
+    fillStringVector(a2py,a2);
+  }
+  {
+    if(!PyTuple_Check(elt1) && PyTuple_Size(elt1)!=2)
+      throw INTERP_KERNEL::Exception(MSG);
+    PyObject *b0py(PyTuple_GetItem(elt1,0)),*b1py(PyTuple_GetItem(elt1,1));
+    void *argp(0);
+    int status(SWIG_ConvertPtr(b0py,&argp,SWIGTITraits<mcIdType>::TI,0|0));
+    if(!SWIG_IsOK(status))
+      throw INTERP_KERNEL::Exception(MSG);
+    b0=reinterpret_cast<MEDCoupling::DataArrayIdType *>(argp);
+    convertFromPyObjVectorOfObj<typename MEDCoupling::Traits<T>::ArrayType *>(b1py,SWIGTITraits<T>::TI,MEDCoupling::Traits<T>::ArrayTypeName,b1);
+  }
+  self->checkForUnserialization(a1,b0,b1);
+  // useless here to call resizeForUnserialization because arrays are well resized.
+  self->finishUnserialization(a1,a0,a2);
+}
+
+PyObject *Mesh_getCellsContainingPointsLike(PyObject *p, double eps, const MEDCoupling::MEDCouplingMesh *self, std::function<void(const double *,mcIdType,double,MEDCoupling::MCAuto<MEDCoupling::DataArrayIdType>&,MEDCoupling::MCAuto<MEDCoupling::DataArrayIdType>&)> func)
+{
+  MEDCoupling::MCAuto<MEDCoupling::DataArrayIdType> elts,eltsIndex;
+  int spaceDim=self->getSpaceDimension();
+  void *da=0;
+  int res1=SWIG_ConvertPtr(p,&da,SWIGTYPE_p_MEDCoupling__DataArrayDouble, 0 |  0 );
+  if (!SWIG_IsOK(res1))
+    {
+      mcIdType size;
+      INTERP_KERNEL::AutoCPtr<double> tmp=convertPyToNewDblArr2(p,&size);
+      mcIdType nbOfPoints=size/spaceDim;
+      if(size%spaceDim!=0)
+        {
+          throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Invalid list length ! Must be a multiple of self.getSpaceDimension() !");
+        }
+      func(tmp,nbOfPoints,eps,elts,eltsIndex);
     }
-  void *argp;
-  int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
-  if(SWIG_IsOK(status))
+  else
     {
-      ParaMEDMEM::DataArrayInt *daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
-      if(daIntTyypp)
-        {
-          sw=3; sz=daIntTyypp->getNbOfElems();
-          return daIntTyypp->begin();
-        }
-      else
+      MEDCoupling::DataArrayDouble *da2=reinterpret_cast< MEDCoupling::DataArrayDouble * >(da);
+      if(!da2)
+        throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Not null DataArrayDouble instance expected !");
+      da2->checkAllocated();
+      mcIdType size=da2->getNumberOfTuples();
+      mcIdType nbOfCompo=ToIdType(da2->getNumberOfComponents());
+      if(nbOfCompo!=spaceDim)
         {
-          sz=0;
-          return 0;
+          throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Invalid DataArrayDouble nb of components ! Expected same as self.getSpaceDimension() !");
         }
+      func(da2->getConstPointer(),size,eps,elts,eltsIndex);
     }
-  status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
-  if(SWIG_IsOK(status))
-    {  
-      ParaMEDMEM::DataArrayIntTuple *daIntTuple=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
-      sw=4; sz=daIntTuple->getNumberOfCompo();
-      return daIntTuple->getConstPointer();
-    }
-  throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
+  PyObject *ret=PyTuple_New(2);
+  PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elts.retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
+  PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(eltsIndex.retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
+  return ret;
 }
+
+#endif