Salome HOME
Merge from MrgToV7main1804
[modules/med.git] / src / MEDCoupling_Swig / MEDCouplingTypemaps.i
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "InterpKernelAutoPtr.hxx"
21
22 #ifdef WITH_NUMPY
23 #include <numpy/arrayobject.h>
24
25 void numarrdeal(void *pt, void *wron)
26 {
27   void **wronc=(void **)wron;
28   PyObject *weakRefOnOwner=reinterpret_cast<PyObject *>(wronc[0]);
29   PyObject *obj=PyWeakref_GetObject(weakRefOnOwner);
30   if(obj!=Py_None)
31     {
32       Py_XINCREF(obj);
33       PyArrayObject *objC=reinterpret_cast<PyArrayObject *>(obj);
34       objC->flags|=NPY_OWNDATA;
35       Py_XDECREF(weakRefOnOwner);
36       Py_XDECREF(obj);
37     }
38   else
39     {
40       typedef void (*MyDeallocator)(void *,void *);
41       MyDeallocator deall=(MyDeallocator)wronc[1];
42       deall(pt,NULL);
43     }
44   delete [] wronc;
45 }
46
47 template<class MCData>
48 struct PyCallBackDataArraySt {
49     PyObject_HEAD
50     MCData *_pt_mc;
51 };
52
53 typedef struct PyCallBackDataArraySt<ParaMEDMEM::DataArrayInt> PyCallBackDataArrayInt;
54 typedef struct PyCallBackDataArraySt<ParaMEDMEM::DataArrayDouble> PyCallBackDataArrayDouble;
55
56 extern "C"
57 {
58   static int callbackmcdataarray___init__(PyObject *self, PyObject *args, PyObject *kwargs) { return 0; }
59   
60   static PyObject *callbackmcdataarrayint___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
61   {
62     PyCallBackDataArrayInt *self = (PyCallBackDataArrayInt *) ( type->tp_alloc(type, 0) );
63     return (PyObject *)self;
64   }
65
66   static PyObject *callbackmcdataarraydouble___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
67   {
68     PyCallBackDataArrayDouble *self = (PyCallBackDataArrayDouble *) ( type->tp_alloc(type, 0) );
69     return (PyObject *)self;
70   }
71   
72   static void callbackmcdataarray_dealloc(PyObject *self)
73   {
74     Py_TYPE(self)->tp_free(self);
75   }
76   
77   static PyObject *callbackmcdataarrayint_call(PyCallBackDataArrayInt *self, PyObject *args, PyObject *kw)
78   {
79     if(self->_pt_mc)
80       {
81         ParaMEDMEM::MemArray<int>& mma=self->_pt_mc->accessToMemArray();
82         mma.destroy();
83       }
84     Py_XINCREF(Py_None);
85     return Py_None;
86   }
87
88   static PyObject *callbackmcdataarraydouble_call(PyCallBackDataArrayDouble *self, PyObject *args, PyObject *kw)
89   {
90     if(self->_pt_mc)
91       {
92         ParaMEDMEM::MemArray<double>& mma=self->_pt_mc->accessToMemArray();
93         mma.destroy();
94       }
95     Py_XINCREF(Py_None);
96     return Py_None;
97   }
98 }
99
100 PyTypeObject PyCallBackDataArrayInt_RefType = {
101   PyVarObject_HEAD_INIT(&PyType_Type, 0)
102   "callbackmcdataarrayint",
103   sizeof(PyCallBackDataArrayInt),
104   0,
105   callbackmcdataarray_dealloc,            /*tp_dealloc*/
106   0,                          /*tp_print*/
107   0,                          /*tp_getattr*/
108   0,                          /*tp_setattr*/
109   0,                          /*tp_compare*/
110   0,                          /*tp_repr*/
111   0,                          /*tp_as_number*/
112   0,                          /*tp_as_sequence*/
113   0,                          /*tp_as_mapping*/
114   0,                          /*tp_hash*/
115   (ternaryfunc)callbackmcdataarrayint_call,  /*tp_call*/
116   0,                          /*tp_str*/
117   0,                          /*tp_getattro*/
118   0,                          /*tp_setattro*/
119   0,                          /*tp_as_buffer*/
120   Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,  /*tp_flags*/
121   0,                          /*tp_doc*/
122   0,                          /*tp_traverse*/
123   0,                          /*tp_clear*/
124   0,                          /*tp_richcompare*/
125   0,                          /*tp_weaklistoffset*/
126   0,                          /*tp_iter*/
127   0,                          /*tp_iternext*/
128   0,                          /*tp_methods*/
129   0,                          /*tp_members*/
130   0,                          /*tp_getset*/
131   0,                          /*tp_base*/
132   0,                          /*tp_dict*/
133   0,                          /*tp_descr_get*/
134   0,                          /*tp_descr_set*/
135   0,                          /*tp_dictoffset*/
136   callbackmcdataarray___init__,           /*tp_init*/
137   PyType_GenericAlloc,        /*tp_alloc*/
138   callbackmcdataarrayint___new__,            /*tp_new*/
139   PyObject_GC_Del,            /*tp_free*/
140 };
141
142 PyTypeObject PyCallBackDataArrayDouble_RefType = {
143   PyVarObject_HEAD_INIT(&PyType_Type, 0)
144   "callbackmcdataarraydouble",
145   sizeof(PyCallBackDataArrayDouble),
146   0,
147   callbackmcdataarray_dealloc,            /*tp_dealloc*/
148   0,                          /*tp_print*/
149   0,                          /*tp_getattr*/
150   0,                          /*tp_setattr*/
151   0,                          /*tp_compare*/
152   0,                          /*tp_repr*/
153   0,                          /*tp_as_number*/
154   0,                          /*tp_as_sequence*/
155   0,                          /*tp_as_mapping*/
156   0,                          /*tp_hash*/
157   (ternaryfunc)callbackmcdataarraydouble_call,  /*tp_call*/
158   0,                          /*tp_str*/
159   0,                          /*tp_getattro*/
160   0,                          /*tp_setattro*/
161   0,                          /*tp_as_buffer*/
162   Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,  /*tp_flags*/
163   0,                          /*tp_doc*/
164   0,                          /*tp_traverse*/
165   0,                          /*tp_clear*/
166   0,                          /*tp_richcompare*/
167   0,                          /*tp_weaklistoffset*/
168   0,                          /*tp_iter*/
169   0,                          /*tp_iternext*/
170   0,                          /*tp_methods*/
171   0,                          /*tp_members*/
172   0,                          /*tp_getset*/
173   0,                          /*tp_base*/
174   0,                          /*tp_dict*/
175   0,                          /*tp_descr_get*/
176   0,                          /*tp_descr_set*/
177   0,                          /*tp_dictoffset*/
178   callbackmcdataarray___init__,           /*tp_init*/
179   PyType_GenericAlloc,        /*tp_alloc*/
180   callbackmcdataarraydouble___new__,            /*tp_new*/
181   PyObject_GC_Del,            /*tp_free*/
182 };
183
184 template<class MCData>
185 void numarrdeal2(void *pt, void *obj)
186 {
187   typedef struct PyCallBackDataArraySt<MCData> PyCallBackDataArray;
188   void **obj1=(void **)obj;
189   PyCallBackDataArray *cbdaic=reinterpret_cast<PyCallBackDataArray *>(obj1[0]);
190   PyObject *weakRefOnOwner=reinterpret_cast<PyObject *>(obj1[1]);
191   cbdaic->_pt_mc=0;
192   Py_XDECREF(weakRefOnOwner);
193   Py_XDECREF(cbdaic);
194   delete [] obj1;
195 }
196
197 template<class MCData, class T>
198 MCData *BuildNewInstance(PyObject *elt0, int npyObjectType, PyTypeObject *pytype, const char *msg)
199 {
200   int ndim=PyArray_NDIM(elt0);
201   if(ndim!=1)
202     throw INTERP_KERNEL::Exception("Input numpy array has not 1 dimension !");//to do 1 or 2.
203   if(PyArray_ObjectType(elt0,0)!=npyObjectType)
204     {
205       std::ostringstream oss; oss << "Input numpy array has not of type " << msg << " !";
206       throw INTERP_KERNEL::Exception(oss.str().c_str());//to do 1 or 2.
207     }
208   npy_intp stride=PyArray_STRIDE(elt0,0);
209   int itemSize=PyArray_ITEMSIZE(elt0);
210   if(itemSize<stride)
211     throw INTERP_KERNEL::Exception("Input numpy array has item size < stride !");
212   if(stride!=sizeof(T))
213     {
214       std::ostringstream oss; oss << "Input numpy array has not stride set to " << sizeof(T) << " !";
215       throw INTERP_KERNEL::Exception(oss.str().c_str());
216     }
217   npy_intp sz=PyArray_DIM(elt0,0);
218   const char *data=PyArray_BYTES(elt0);
219   typename ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<MCData> ret=MCData::New();
220   if(PyArray_ISBEHAVED(elt0))//aligned and writeable and in machine byte-order
221     {
222       PyArrayObject *elt0C=reinterpret_cast<PyArrayObject *>(elt0);
223       PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & NPY_OWNDATA)?elt0C:NULL;
224       int mask=NPY_OWNDATA; mask=~mask;
225       elt0C->flags&=mask;
226       PyObject *deepestObj=elt0;
227       PyObject *base=elt0C->base;
228       if(base) deepestObj=base;
229       while(base)
230         {
231           if(PyArray_Check(base))
232             {
233               PyArrayObject *baseC=reinterpret_cast<PyArrayObject *>(base);
234               eltOwning=(PyArray_FLAGS(baseC) & NPY_OWNDATA)?baseC:eltOwning;
235               baseC->flags&=mask;
236               base=baseC->base;
237               if(base) deepestObj=base;
238             }
239           else
240             break;
241         }
242       typename ParaMEDMEM::MemArray<T>& mma=ret->accessToMemArray();
243       if(eltOwning==NULL)
244         {
245           PyCallBackDataArraySt<MCData> *cb=PyObject_GC_New(PyCallBackDataArraySt<MCData>,pytype);
246           cb->_pt_mc=ret;
247           ret->useArray(reinterpret_cast<const T *>(data),true,ParaMEDMEM::C_DEALLOC,sz,1);
248           PyObject *ref=PyWeakref_NewRef(deepestObj,(PyObject *)cb);
249           void **objs=new void *[2]; objs[0]=cb; objs[1]=ref;
250           mma.setParameterForDeallocator(objs);
251           mma.setSpecificDeallocator(numarrdeal2<MCData>);
252           //"Impossible to share this numpy array chunk of data, because already shared by an another non numpy array object (maybe an another DataArrayInt instance) ! Release it, or perform a copy on the input array !");
253         }
254       else
255         {
256           ret->useArray(reinterpret_cast<const T *>(data),true,ParaMEDMEM::C_DEALLOC,sz,1);
257           PyObject *ref=PyWeakref_NewRef(reinterpret_cast<PyObject *>(eltOwning),NULL);
258           void **objs=new void *[2]; objs[0]=ref; objs[1]=(void*) ParaMEDMEM::MemArray<T>::CDeallocator;
259           mma.setParameterForDeallocator(objs);
260           mma.setSpecificDeallocator(numarrdeal);
261         }
262     }
263   else if(PyArray_ISBEHAVED_RO(elt0))
264     ret->useArray(reinterpret_cast<const T *>(data),false,ParaMEDMEM::CPP_DEALLOC,sz,1);
265   return ret.retn();
266 }
267
268 template<class MCData, class T>
269 PyObject *ToNumPyArray(MCData *self, int npyObjectType, const char *MCDataStr)
270 {
271   if(!self->isAllocated())
272     {
273       std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : this is not allocated !";
274       throw INTERP_KERNEL::Exception(oss.str().c_str());
275     }
276   ParaMEDMEM::MemArray<T>& mem=self->accessToMemArray();
277   int nbComp=self->getNumberOfComponents();
278   if(nbComp!=1 && nbComp!=2)
279     {
280       std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : number of components of this is " << nbComp << " ! Should 1 or 2 !"; 
281       throw INTERP_KERNEL::Exception(oss.str().c_str());
282     }
283   std::size_t sz=self->getNbOfElems();
284   npy_intp dim[2];
285   dim[0]=(npy_intp)self->getNumberOfTuples(); dim[1]=2;
286   const T *bg=self->getConstPointer();
287   PyObject *ret=PyArray_SimpleNewFromData(nbComp,dim,npyObjectType,const_cast<T *>(bg));
288   if(mem.isDeallocatorCalled())
289     {
290       if(mem.getDeallocator()!=ParaMEDMEM::MemArray<T>::CDeallocator)
291         {
292           int mask=NPY_OWNDATA; mask=~mask;
293           (reinterpret_cast<PyArrayObject *>(ret))->flags&=mask;
294           return ret;
295         }
296       else
297         {
298           PyObject *ref=PyWeakref_NewRef(ret,NULL);
299           void **objs=new void *[2]; objs[0]=ref; objs[1]=(void*) ParaMEDMEM::MemArray<T>::CDeallocator;
300           mem.setParameterForDeallocator(objs);
301           mem.setSpecificDeallocator(numarrdeal);
302           return ret;
303         }
304     }
305   return ret;
306 }
307
308 #endif
309
310 static PyObject *convertMesh(ParaMEDMEM::MEDCouplingMesh *mesh, int owner) throw(INTERP_KERNEL::Exception)
311 {
312   PyObject *ret=0;
313   if(dynamic_cast<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
314     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner);
315   if(dynamic_cast<ParaMEDMEM::MEDCouplingExtrudedMesh *>(mesh))
316     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingExtrudedMesh,owner);
317   if(dynamic_cast<ParaMEDMEM::MEDCouplingCMesh *>(mesh))
318     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh,owner);
319   if(dynamic_cast<ParaMEDMEM::MEDCouplingCurveLinearMesh *>(mesh))
320     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCurveLinearMesh,owner);
321   if(!ret)
322     throw INTERP_KERNEL::Exception("Not recognized type of mesh on downcast !");
323   return ret;
324 }
325
326 static PyObject *convertFieldDiscretization(ParaMEDMEM::MEDCouplingFieldDiscretization *fd, int owner) throw(INTERP_KERNEL::Exception)
327 {
328   PyObject *ret=0;
329   if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationP0 *>(fd))
330     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationP0,owner);
331   if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationP1 *>(fd))
332     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationP1,owner);
333   if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationGauss *>(fd))
334     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationGauss,owner);
335   if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationGaussNE *>(fd))
336     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationGaussNE,owner);
337   if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationKriging *>(fd))
338     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationKriging,owner);
339   if(!ret)
340     throw INTERP_KERNEL::Exception("Not recognized type of field discretization on downcast !");
341   return ret;
342 }
343
344 static PyObject *convertDataArrayChar(ParaMEDMEM::DataArrayChar *dac, int owner) throw(INTERP_KERNEL::Exception)
345 {
346   PyObject *ret=0;
347   if(dynamic_cast<ParaMEDMEM::DataArrayByte *>(dac))
348     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,owner);
349   if(dynamic_cast<ParaMEDMEM::DataArrayAsciiChar *>(dac))
350     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayAsciiChar,owner);
351   if(!ret)
352     throw INTERP_KERNEL::Exception("Not recognized type of DataArrayChar on downcast !");
353   return ret;
354 }
355
356 static PyObject* convertMultiFields(ParaMEDMEM::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception)
357 {
358   PyObject *ret=0;
359   if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldOverTime *>(mfs))
360     ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldOverTime,owner);
361   else
362     ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingMultiFields,owner);
363   return ret;
364 }
365
366 static PyObject *convertIntArrToPyList(const int *ptr, int size) throw(INTERP_KERNEL::Exception)
367 {
368   PyObject *ret=PyList_New(size);
369   for(int i=0;i<size;i++)
370     PyList_SetItem(ret,i,PyInt_FromLong(ptr[i]));
371   return ret;
372 }
373
374 static PyObject *convertIntArrToPyList2(const std::vector<int>& v) throw(INTERP_KERNEL::Exception)
375 {
376   int size=v.size();
377   PyObject *ret=PyList_New(size);
378   for(int i=0;i<size;i++)
379     PyList_SetItem(ret,i,PyInt_FromLong(v[i]));
380   return ret;
381 }
382
383 static PyObject *convertIntArrToPyList3(const std::set<int>& v) throw(INTERP_KERNEL::Exception)
384 {
385   int size=v.size();
386   PyObject *ret=PyList_New(size);
387   std::set<int>::const_iterator it=v.begin();
388   for(int i=0;i<size;i++,it++)
389     PyList_SetItem(ret,i,PyInt_FromLong(*it));
390   return ret;
391 }
392
393 static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
394 {
395   PyObject *ret=PyList_New(nbOfTuples);
396   for(int i=0;i<nbOfTuples;i++)
397     {
398       PyObject *t=PyTuple_New(nbOfComp);
399       for(int j=0;j<nbOfComp;j++)
400         PyTuple_SetItem(t,j,PyInt_FromLong(vals[i*nbOfComp+j]));
401       PyList_SetItem(ret,i,t);
402     }
403   return ret;
404 }
405
406 static int *convertPyToNewIntArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
407 {
408   if(PyList_Check(pyLi))
409     {
410       *size=PyList_Size(pyLi);
411       int *tmp=new int[*size];
412       for(int i=0;i<*size;i++)
413         {
414           PyObject *o=PyList_GetItem(pyLi,i);
415           if(PyInt_Check(o))
416             {
417               int val=(int)PyInt_AS_LONG(o);
418               tmp[i]=val;
419             }
420           else
421             {
422               delete [] tmp;
423               throw INTERP_KERNEL::Exception("list must contain integers only");
424             }
425         }
426       return tmp;
427     }
428   else if(PyTuple_Check(pyLi))
429     {
430       *size=PyTuple_Size(pyLi);
431       int *tmp=new int[*size];
432       for(int i=0;i<*size;i++)
433         {
434           PyObject *o=PyTuple_GetItem(pyLi,i);
435           if(PyInt_Check(o))
436             {
437               int val=(int)PyInt_AS_LONG(o);
438               tmp[i]=val;
439             }
440           else
441             {
442               delete [] tmp;
443               throw INTERP_KERNEL::Exception("tuple must contain integers only");
444             }
445         }
446       return tmp;
447     }
448   else
449     {
450       throw INTERP_KERNEL::Exception("convertPyToNewIntArr2 : not a list");
451     }
452 }
453
454 static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair<int,int> >& arr) throw(INTERP_KERNEL::Exception)
455 {
456   const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !";
457   if(PyList_Check(pyLi))
458     {
459       int size=PyList_Size(pyLi);
460       arr.resize(size);
461       for(int i=0;i<size;i++)
462         {
463           PyObject *o=PyList_GetItem(pyLi,i);
464           if(PyTuple_Check(o))
465             {
466               int sz2=PyTuple_Size(o);
467               if(sz2!=2)
468                 throw INTERP_KERNEL::Exception(msg);
469               PyObject *o_0=PyTuple_GetItem(o,0);
470               if(!PyInt_Check(o_0))
471                 throw INTERP_KERNEL::Exception(msg);
472               PyObject *o_1=PyTuple_GetItem(o,1);
473               if(!PyInt_Check(o_1))
474                 throw INTERP_KERNEL::Exception(msg);
475               arr[i].first=(int)PyInt_AS_LONG(o_0);
476               arr[i].second=(int)PyInt_AS_LONG(o_1);
477             }
478           else
479             throw INTERP_KERNEL::Exception(msg);
480         }
481     }
482   else if(PyTuple_Check(pyLi))
483     {
484       int size=PyTuple_Size(pyLi);
485       arr.resize(size);
486       for(int i=0;i<size;i++)
487         {
488           PyObject *o=PyTuple_GetItem(pyLi,i);
489           if(PyTuple_Check(o))
490             {
491               int sz2=PyTuple_Size(o);
492               if(sz2!=2)
493                 throw INTERP_KERNEL::Exception(msg);
494               PyObject *o_0=PyTuple_GetItem(o,0);
495               if(!PyInt_Check(o_0))
496                 throw INTERP_KERNEL::Exception(msg);
497               PyObject *o_1=PyTuple_GetItem(o,1);
498               if(!PyInt_Check(o_1))
499                 throw INTERP_KERNEL::Exception(msg);
500               arr[i].first=(int)PyInt_AS_LONG(o_0);
501               arr[i].second=(int)PyInt_AS_LONG(o_1);
502             }
503           else
504             throw INTERP_KERNEL::Exception(msg);
505         }
506     }
507   else
508     throw INTERP_KERNEL::Exception(msg);
509 }
510
511 static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
512 {
513   if(PyList_Check(pyLi))
514     {
515       int size=PyList_Size(pyLi);
516       arr.resize(size);
517       for(int i=0;i<size;i++)
518         {
519           PyObject *o=PyList_GetItem(pyLi,i);
520           if(PyInt_Check(o))
521             {
522               int val=(int)PyInt_AS_LONG(o);
523               arr[i]=val;
524             }
525           else
526             throw INTERP_KERNEL::Exception("list must contain integers only");
527         }
528     }
529   else if(PyTuple_Check(pyLi))
530     {
531       int size=PyTuple_Size(pyLi);
532       arr.resize(size);
533       for(int i=0;i<size;i++)
534         {
535           PyObject *o=PyTuple_GetItem(pyLi,i);
536           if(PyInt_Check(o))
537             {
538               int val=(int)PyInt_AS_LONG(o);
539               arr[i]=val;
540             }
541           else
542             throw INTERP_KERNEL::Exception("tuple must contain integers only");
543         }
544     }
545   else
546     {
547       throw INTERP_KERNEL::Exception("convertPyToNewIntArr3 : not a list nor a tuple");
548     }
549 }
550
551 static void convertPyToNewIntArr4(PyObject *pyLi, int recurseLev, int nbOfSubPart, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
552 {
553   if(recurseLev<0)
554     throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : invalid list of integers level of recursion !");
555   arr.clear();
556   if(PyList_Check(pyLi))
557     {
558       int size=PyList_Size(pyLi);
559       for(int i=0;i<size;i++)
560         {
561           PyObject *o=PyList_GetItem(pyLi,i);
562           if(PyInt_Check(o))
563             {
564               int val=(int)PyInt_AS_LONG(o);
565               arr.push_back(val);
566             }
567           else
568             {
569               std::vector<int> arr2;
570               convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
571               if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
572                   {
573                     std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " <<  recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
574                     throw INTERP_KERNEL::Exception(oss.str().c_str());
575                   }
576               arr.insert(arr.end(),arr2.begin(),arr2.end());
577             }
578         }
579     }
580   else if(PyTuple_Check(pyLi))
581     {
582       int size=PyTuple_Size(pyLi);
583       for(int i=0;i<size;i++)
584         {
585           PyObject *o=PyTuple_GetItem(pyLi,i);
586           if(PyInt_Check(o))
587             {
588               int val=(int)PyInt_AS_LONG(o);
589               arr.push_back(val);
590             }
591           else
592             {
593               std::vector<int> arr2;
594               convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
595               if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
596                   {
597                     std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " <<  recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
598                     throw INTERP_KERNEL::Exception(oss.str().c_str());
599                   }
600               arr.insert(arr.end(),arr2.begin(),arr2.end());
601             }
602         }
603     }
604   else
605     throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : not a list nor a tuple recursively !");
606 }
607
608 static void checkFillArrayWithPyList(int size1, int size2, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
609 {
610   if(nbOfTuples==-1)
611     {
612       if(nbOfComp==-1) { nbOfTuples=size1; nbOfComp=size2; }
613       else { if(nbOfComp==size2) { nbOfTuples=size1; } else
614           {
615             std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
616             oss << " whereas nb of components expected is " << nbOfComp << " !";
617             throw INTERP_KERNEL::Exception(oss.str().c_str());
618           } }
619     }
620   else
621     {
622       if(nbOfComp!=-1)
623         {
624           if((nbOfTuples!=size1 || nbOfComp!=size2))
625             {
626               if(size2!=1 || size1!=nbOfComp*nbOfTuples)
627                 {
628                   std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
629                   oss << " whereas nb of tuples expected is " << nbOfTuples << " and number of components expected is " << nbOfComp << " !";
630                   throw INTERP_KERNEL::Exception(oss.str().c_str());
631                 }
632             }
633         }
634       else
635         {
636           if(nbOfTuples==size1)
637             nbOfComp=size2;
638           else
639             {
640               std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
641               oss << " whereas nb of tuples expected is " << nbOfTuples << " !";
642               throw INTERP_KERNEL::Exception(oss.str().c_str());
643             }
644         }
645     }
646 }
647
648 static void fillArrayWithPyListInt3(PyObject *pyLi, int& nbOfElt, std::vector<int>& ret)
649 {
650   static const char MSG[]="fillArrayWithPyListInt3 : It appears that the input list or tuple is composed by elts having different sizes !";
651   if(PyInt_Check(pyLi))
652     {
653       long val=PyInt_AS_LONG(pyLi);
654       if(nbOfElt==-1)
655         nbOfElt=1;
656       else
657         if(nbOfElt!=1)
658           throw INTERP_KERNEL::Exception(MSG);
659       ret.push_back(val);
660     }
661   else if(PyList_Check(pyLi))
662     {
663       int size=PyList_Size(pyLi);
664       int tmp=0;
665       for(int i=0;i<size;i++)
666         {
667           PyObject *o=PyList_GetItem(pyLi,i);
668           int tmp1=-1;
669           fillArrayWithPyListInt3(o,tmp1,ret);
670           tmp+=tmp1;
671         }
672       if(nbOfElt==-1)
673         nbOfElt=tmp;
674       else
675         {
676           if(nbOfElt!=tmp)
677             throw INTERP_KERNEL::Exception(MSG);
678         }
679     }
680   else if(PyTuple_Check(pyLi))
681     {
682       int size=PyTuple_Size(pyLi);
683       int tmp=0;
684       for(int i=0;i<size;i++)
685         {
686           PyObject *o=PyTuple_GetItem(pyLi,i);
687           int tmp1=-1;
688           fillArrayWithPyListInt3(o,tmp1,ret);
689           tmp+=tmp1;
690         }
691       if(nbOfElt==-1)
692         nbOfElt=tmp;
693       else
694         {
695           if(nbOfElt!=tmp)
696             throw INTERP_KERNEL::Exception(MSG);
697         }
698     }
699   else
700     throw INTERP_KERNEL::Exception("fillArrayWithPyListInt3 : Unrecognized type ! Should be a composition of tuple,list,int !");
701 }
702
703 static std::vector<int> fillArrayWithPyListInt2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
704 {
705   std::vector<int> ret;
706   int size1=-1,size2=-1;
707   if(PyList_Check(pyLi))
708     {
709       size1=PyList_Size(pyLi);
710       for(int i=0;i<size1;i++)
711         {
712           PyObject *o=PyList_GetItem(pyLi,i);
713           fillArrayWithPyListInt3(o,size2,ret);
714         }
715       if(size1==0)
716         size2=1;
717     }
718   else if(PyTuple_Check(pyLi))
719     {
720       size1=PyTuple_Size(pyLi);
721       for(int i=0;i<size1;i++)
722         {
723           PyObject *o=PyTuple_GetItem(pyLi,i);
724           fillArrayWithPyListInt3(o,size2,ret);
725         }
726       if(size1==0)
727         size2=1;
728     }
729   else
730     throw INTERP_KERNEL::Exception("fillArrayWithPyListInt2 : Unrecognized type ! Should be a tuple or a list !");
731   //
732   checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
733   return ret;
734 }
735
736 static bool fillStringVector(PyObject *pyLi, std::vector<std::string>& vec) throw(INTERP_KERNEL::Exception)
737 {
738   if(PyList_Check(pyLi))
739     {
740       Py_ssize_t sz=PyList_Size(pyLi);
741       vec.resize(sz);
742       for(int i=0;i<sz;i++)
743         {
744           PyObject *o=PyList_GetItem(pyLi,i);
745           if(PyString_Check(o))
746             vec[i]=PyString_AsString(o);
747           else
748             return false;
749         }
750       return true;
751     }
752   else if(PyTuple_Check(pyLi))
753     {
754       Py_ssize_t sz=PyTuple_Size(pyLi);
755       vec.resize(sz);
756       for(int i=0;i<sz;i++)
757         {
758           PyObject *o=PyTuple_GetItem(pyLi,i);
759           if(PyString_Check(o))
760             vec[i]=PyString_AsString(o);
761           else
762             return false;
763         }
764       return true;
765     }
766   else
767     return false;
768 }
769
770 static PyObject *convertDblArrToPyList(const double *ptr, int size) throw(INTERP_KERNEL::Exception)
771 {
772   PyObject *ret=PyList_New(size);
773   for(int i=0;i<size;i++)
774     PyList_SetItem(ret,i,PyFloat_FromDouble(ptr[i]));
775   return ret;
776 }
777
778 static PyObject *convertDblArrToPyList2(const std::vector<double>& v) throw(INTERP_KERNEL::Exception)
779 {
780   int size=v.size();
781   PyObject *ret=PyList_New(size);
782   for(int i=0;i<size;i++)
783     PyList_SetItem(ret,i,PyFloat_FromDouble(v[i]));
784   return ret;
785 }
786
787 static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
788 {
789   PyObject *ret=PyList_New(nbOfTuples);
790   for(int i=0;i<nbOfTuples;i++)
791     {
792       PyObject *t=PyTuple_New(nbOfComp);
793       for(int j=0;j<nbOfComp;j++)
794         PyTuple_SetItem(t,j,PyFloat_FromDouble(vals[i*nbOfComp+j]));
795       PyList_SetItem(ret,i,t);
796     }
797   return ret;
798 }
799
800 static PyObject *convertCharArrToPyListOfTuple(const char *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
801 {
802   PyObject *ret=PyList_New(nbOfTuples);
803   INTERP_KERNEL::AutoPtr<char> tmp=new char[nbOfComp+1]; tmp[nbOfComp]='\0';
804   for(int i=0;i<nbOfTuples;i++)
805     {
806       std::copy(vals+i*nbOfComp,vals+(i+1)*nbOfComp,(char *)tmp);
807       PyList_SetItem(ret,i,PyString_FromString(tmp));
808     }
809   return ret;
810 }
811
812 static double *convertPyToNewDblArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
813 {
814   if(PyList_Check(pyLi))
815     {
816       *size=PyList_Size(pyLi);
817       double *tmp=new double[*size];
818       for(int i=0;i<*size;i++)
819         {
820           PyObject *o=PyList_GetItem(pyLi,i);
821           if(PyFloat_Check(o))
822             {
823               double val=PyFloat_AS_DOUBLE(o);
824               tmp[i]=val;
825             }
826           else if(PyInt_Check(o))
827             {
828               long val0=PyInt_AS_LONG(o);
829               double val=val0;
830               tmp[i]=val;
831             }
832           else
833             {
834               delete [] tmp;
835               throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : list must contain floats/integers only");
836             }
837         }
838       return tmp;
839     }
840   else if(PyTuple_Check(pyLi))
841     {
842       *size=PyTuple_Size(pyLi);
843       double *tmp=new double[*size];
844       for(int i=0;i<*size;i++)
845         {
846           PyObject *o=PyTuple_GetItem(pyLi,i);
847           if(PyFloat_Check(o))
848             {
849               double val=PyFloat_AS_DOUBLE(o);
850               tmp[i]=val;
851             }
852           else if(PyInt_Check(o))
853             {
854               long val0=PyInt_AS_LONG(o);
855               double val=val0;
856               tmp[i]=val;
857             }
858           else
859             {
860               delete [] tmp;
861               throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : tuple must contain floats/integers only");
862             }
863         }
864       return tmp;
865     }
866   else
867     throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : not a list");
868 }
869
870 static void fillArrayWithPyListDbl3(PyObject *pyLi, int& nbOfElt, std::vector<double>& ret)
871 {
872   static const char MSG[]="fillArrayWithPyListDbl3 : It appears that the input list or tuple is composed by elts having different sizes !";
873   if(PyFloat_Check(pyLi))
874     {
875       if(nbOfElt==-1)
876         nbOfElt=1;
877       else
878         if(nbOfElt!=1)
879           throw INTERP_KERNEL::Exception(MSG);
880       double val=PyFloat_AS_DOUBLE(pyLi);
881       ret.push_back(val);
882     }
883   else if(PyInt_Check(pyLi))
884     {
885       long val0=PyInt_AS_LONG(pyLi);
886       double val=val0;
887       if(nbOfElt==-1)
888         nbOfElt=1;
889       else
890         if(nbOfElt!=1)
891           throw INTERP_KERNEL::Exception(MSG);
892       ret.push_back(val);
893     }
894   else if(PyList_Check(pyLi))
895     {
896       int size=PyList_Size(pyLi);
897       int tmp=0;
898       for(int i=0;i<size;i++)
899         {
900           PyObject *o=PyList_GetItem(pyLi,i);
901           int tmp1=-1;
902           fillArrayWithPyListDbl3(o,tmp1,ret);
903           tmp+=tmp1;
904         }
905       if(nbOfElt==-1)
906         nbOfElt=tmp;
907       else
908         {
909           if(nbOfElt!=tmp)
910             throw INTERP_KERNEL::Exception(MSG);
911         }
912     }
913   else if(PyTuple_Check(pyLi))
914     {
915       int size=PyTuple_Size(pyLi);
916       int tmp=0;
917       for(int i=0;i<size;i++)
918         {
919           PyObject *o=PyTuple_GetItem(pyLi,i);
920           int tmp1=-1;
921           fillArrayWithPyListDbl3(o,tmp1,ret);
922           tmp+=tmp1;
923         }
924       if(nbOfElt==-1)
925         nbOfElt=tmp;
926       else
927         {
928           if(nbOfElt!=tmp)
929             throw INTERP_KERNEL::Exception(MSG);
930         }
931     }
932   else
933     throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl3 : Unrecognized type ! Should be a composition of tuple,list,int and float !");
934 }
935
936 static std::vector<double> fillArrayWithPyListDbl2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
937 {
938   std::vector<double> ret;
939   int size1=-1,size2=-1;
940   if(PyList_Check(pyLi))
941     {
942       size1=PyList_Size(pyLi);
943       for(int i=0;i<size1;i++)
944         {
945           PyObject *o=PyList_GetItem(pyLi,i);
946           fillArrayWithPyListDbl3(o,size2,ret);
947         }
948       if(size1==0)
949         size2=1;
950     }
951   else if(PyTuple_Check(pyLi))
952     {
953       size1=PyTuple_Size(pyLi);
954       for(int i=0;i<size1;i++)
955         {
956           PyObject *o=PyTuple_GetItem(pyLi,i);
957           fillArrayWithPyListDbl3(o,size2,ret);
958         }
959       if(size1==0)
960         size2=1;
961     }
962   else
963     throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !");
964   //
965   checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
966   return ret;
967 }
968
969 //convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(pyLi,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh")
970 template<class T>
971 static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, const char *typeStr, typename std::vector<T>& ret)
972 {
973   void *argp=0;
974   if(PyList_Check(pyLi))
975     {
976       int size=PyList_Size(pyLi);
977       ret.resize(size);
978       for(int i=0;i<size;i++)
979         {
980           PyObject *obj=PyList_GetItem(pyLi,i);
981           int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
982           if(!SWIG_IsOK(status))
983             throw INTERP_KERNEL::Exception("list must contain only MEDCouplingUMesh");
984           T arg=reinterpret_cast< T >(argp);
985           ret[i]=arg;
986         }
987     }
988   else if(PyTuple_Check(pyLi))
989     {
990       int size=PyTuple_Size(pyLi);
991       ret.resize(size);
992       for(int i=0;i<size;i++)
993         {
994           PyObject *obj=PyTuple_GetItem(pyLi,i);
995           int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
996           if(!SWIG_IsOK(status))
997             {
998               std::ostringstream oss; oss << "tuple must contain only " << typeStr;
999               throw INTERP_KERNEL::Exception(oss.str().c_str());
1000             }
1001           T arg=reinterpret_cast< T >(argp);
1002           ret[i]=arg;
1003         }
1004     }
1005   else if(SWIG_IsOK(SWIG_ConvertPtr(pyLi,&argp,ty,0|0)))
1006     {
1007       ret.resize(1);
1008       T arg=reinterpret_cast< T >(argp);
1009       ret[0]=arg;
1010     }
1011   else
1012     throw INTERP_KERNEL::Exception("convertFromPyObjVectorOfObj : not a list nor a tuple");
1013 }
1014
1015 /*!
1016  * if python int -> cpp int sw=1
1017  * if python list[int] -> cpp vector<int> sw=2
1018  * if python tuple[int] -> cpp vector<int> sw=2
1019  * if python DataArrayInt -> cpp DataArrayInt sw=3
1020  * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
1021  *
1022  * switch between (int,vector<int>,DataArrayInt)
1023  */
1024 static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, ParaMEDMEM::DataArrayInt *& daIntTyypp, ParaMEDMEM::DataArrayIntTuple *&daIntTuple) throw(INTERP_KERNEL::Exception)
1025 {
1026   sw=-1;
1027   if(PyInt_Check(value))
1028     {
1029       iTyypp=(int)PyInt_AS_LONG(value);
1030       sw=1;
1031       return;
1032     }
1033   if(PyTuple_Check(value))
1034     {
1035       int size=PyTuple_Size(value);
1036       stdvecTyypp.resize(size);
1037       for(int i=0;i<size;i++)
1038         {
1039           PyObject *o=PyTuple_GetItem(value,i);
1040           if(PyInt_Check(o))
1041             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1042           else
1043             {
1044               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1045               throw INTERP_KERNEL::Exception(oss.str().c_str());
1046             }
1047         }
1048       sw=2;
1049       return;
1050     }
1051   if(PyList_Check(value))
1052     {
1053       int size=PyList_Size(value);
1054       stdvecTyypp.resize(size);
1055       for(int i=0;i<size;i++)
1056         {
1057           PyObject *o=PyList_GetItem(value,i);
1058           if(PyInt_Check(o))
1059             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1060           else
1061             {
1062               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1063               throw INTERP_KERNEL::Exception(oss.str().c_str());
1064             }
1065         }
1066       sw=2;
1067       return;
1068     }
1069   void *argp;
1070   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
1071   if(SWIG_IsOK(status))
1072     {
1073       daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
1074       sw=3;
1075       return;
1076     }
1077   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
1078   if(SWIG_IsOK(status))
1079     {  
1080       daIntTuple=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
1081       sw=4;
1082       return ;
1083     }
1084   throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
1085 }
1086
1087 /*!
1088  * if python double -> cpp double sw=1
1089  * if python int -> cpp double sw=1
1090  * if python list[double] -> cpp vector<double> sw=2
1091  * if python list[int] -> cpp vector<double> sw=2
1092  * if python tuple[double] -> cpp vector<double> sw=2
1093  * if python tuple[int] -> cpp vector<double> sw=2
1094  * if python DataArrayDouble -> cpp DataArrayDouble sw=3
1095  *
1096  * switch between (int,vector<int>,DataArrayInt)
1097  */
1098 static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, ParaMEDMEM::DataArrayDouble *& daIntTyypp) throw(INTERP_KERNEL::Exception)
1099 {
1100   sw=-1;
1101   if(PyFloat_Check(value))
1102     {
1103       iTyypp=PyFloat_AS_DOUBLE(value);
1104       sw=1;
1105       return;
1106     }
1107   if(PyInt_Check(value))
1108     {
1109       iTyypp=(double)PyInt_AS_LONG(value);
1110       sw=1;
1111       return;
1112     }
1113   if(PyTuple_Check(value))
1114     {
1115       int size=PyTuple_Size(value);
1116       stdvecTyypp.resize(size);
1117       for(int i=0;i<size;i++)
1118         {
1119           PyObject *o=PyTuple_GetItem(value,i);
1120           if(PyFloat_Check(o))
1121             stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1122           else if(PyInt_Check(o))
1123             stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1124           else
1125             {
1126               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1127               throw INTERP_KERNEL::Exception(oss.str().c_str());
1128             }
1129         }
1130       sw=2;
1131       return;
1132     }
1133   if(PyList_Check(value))
1134     {
1135       int size=PyList_Size(value);
1136       stdvecTyypp.resize(size);
1137       for(int i=0;i<size;i++)
1138         {
1139           PyObject *o=PyList_GetItem(value,i);
1140           if(PyFloat_Check(o))
1141             stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1142           else if(PyInt_Check(o))
1143             stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1144           else
1145             {
1146               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1147               throw INTERP_KERNEL::Exception(oss.str().c_str());
1148             }
1149         }
1150       sw=2;
1151       return;
1152     }
1153   void *argp;
1154   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
1155   if(!SWIG_IsOK(status))
1156     throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
1157   daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
1158   sw=3;
1159 }
1160
1161 /*!
1162  * if python double -> cpp double sw=1
1163  * if python int -> cpp double sw=1
1164  * if python list[double] -> cpp vector<double> sw=2
1165  * if python list[int] -> cpp vector<double> sw=2
1166  * if python tuple[double] -> cpp vector<double> sw=2
1167  * if python tuple[int] -> cpp vector<double> sw=2
1168  * if python DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1169  *
1170  * switch between (int,vector<int>,DataArrayInt)
1171  */
1172 static void convertObjToPossibleCpp44(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, ParaMEDMEM::DataArrayDoubleTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
1173 {
1174   sw=-1;
1175   if(PyFloat_Check(value))
1176     {
1177       iTyypp=PyFloat_AS_DOUBLE(value);
1178       sw=1;
1179       return;
1180     }
1181   if(PyInt_Check(value))
1182     {
1183       iTyypp=(double)PyInt_AS_LONG(value);
1184       sw=1;
1185       return;
1186     }
1187   if(PyTuple_Check(value))
1188     {
1189       int size=PyTuple_Size(value);
1190       stdvecTyypp.resize(size);
1191       for(int i=0;i<size;i++)
1192         {
1193           PyObject *o=PyTuple_GetItem(value,i);
1194           if(PyFloat_Check(o))
1195             stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1196           else if(PyInt_Check(o))
1197             stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1198           else
1199             {
1200               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1201               throw INTERP_KERNEL::Exception(oss.str().c_str());
1202             }
1203         }
1204       sw=2;
1205       return;
1206     }
1207   if(PyList_Check(value))
1208     {
1209       int size=PyList_Size(value);
1210       stdvecTyypp.resize(size);
1211       for(int i=0;i<size;i++)
1212         {
1213           PyObject *o=PyList_GetItem(value,i);
1214           if(PyFloat_Check(o))
1215             stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1216           else if(PyInt_Check(o))
1217             stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1218           else
1219             {
1220               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1221               throw INTERP_KERNEL::Exception(oss.str().c_str());
1222             }
1223         }
1224       sw=2;
1225       return;
1226     }
1227   void *argp;
1228   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
1229   if(!SWIG_IsOK(status))
1230     throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDoubleTuple");
1231   daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
1232   sw=3;
1233 }
1234
1235 /*!
1236  * if python int -> cpp int sw=1
1237  * if python list[int] -> cpp vector<int> sw=2
1238  * if python tuple[int] -> cpp vector<int> sw=2
1239  * if python slicp -> cpp pair sw=3 (begin,end,step)
1240  * if python DataArrayInt -> cpp DataArrayInt sw=4 . The returned pointer cannot be the null pointer ! If null an exception is thrown.
1241  *
1242  * switch between (int,vector<int>,DataArrayInt)
1243  */
1244 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)
1245 {
1246   const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple";
1247   sw=-1;
1248   if(PyInt_Check(value))
1249     {
1250       iTyypp=(int)PyInt_AS_LONG(value);
1251       sw=1;
1252       return;
1253     }
1254   if(PyTuple_Check(value))
1255     {
1256       int size=PyTuple_Size(value);
1257       stdvecTyypp.resize(size);
1258       for(int i=0;i<size;i++)
1259         {
1260           PyObject *o=PyTuple_GetItem(value,i);
1261           if(PyInt_Check(o))
1262             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1263           else
1264             {
1265               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1266               throw INTERP_KERNEL::Exception(oss.str().c_str());
1267             }
1268         }
1269       sw=2;
1270       return;
1271     }
1272   if(PyList_Check(value))
1273     {
1274       int size=PyList_Size(value);
1275       stdvecTyypp.resize(size);
1276       for(int i=0;i<size;i++)
1277         {
1278           PyObject *o=PyList_GetItem(value,i);
1279           if(PyInt_Check(o))
1280             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1281           else
1282             {
1283               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1284               throw INTERP_KERNEL::Exception(oss.str().c_str());
1285             }
1286         }
1287       sw=2;
1288       return;
1289     }
1290   if(PySlice_Check(value))
1291     {
1292       Py_ssize_t strt=2,stp=2,step=2;
1293       PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
1294       if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
1295         if(nbelem!=0 || strt!=0 || stp!=0)
1296           {
1297             std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elements is : " << nbelem;
1298             throw INTERP_KERNEL::Exception(oss.str().c_str());
1299           }
1300       p.first=strt;
1301       p.second.first=stp;
1302       p.second.second=step;
1303       sw=3;
1304       return ;
1305     }
1306   void *argp;
1307   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
1308   if(SWIG_IsOK(status))
1309     {
1310       daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
1311       if(!daIntTyypp)
1312         {
1313           std::ostringstream oss; oss << msg << " Instance in null !";
1314           throw INTERP_KERNEL::Exception(oss.str().c_str());
1315         }
1316       sw=4;
1317       return ;
1318     }
1319   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
1320   if(SWIG_IsOK(status))
1321     {
1322       ParaMEDMEM::DataArrayIntTuple *tmp=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
1323       if(!tmp)
1324         {
1325           std::ostringstream oss; oss << msg << " Instance in null !";
1326           throw INTERP_KERNEL::Exception(oss.str().c_str());
1327         }
1328       stdvecTyypp.resize(tmp->getNumberOfCompo());
1329       std::copy(tmp->getConstPointer(),tmp->getConstPointer()+tmp->getNumberOfCompo(),stdvecTyypp.begin());
1330       sw=2;
1331       return ;
1332     }
1333   throw INTERP_KERNEL::Exception(msg);
1334 }
1335
1336 /*!
1337  * if python int -> cpp int sw=1
1338  * if python tuple[int] -> cpp vector<int> sw=2
1339  * if python list[int] -> cpp vector<int> sw=2
1340  * if python slice -> cpp pair sw=3
1341  * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 . WARNING The returned pointer can be the null pointer !
1342  */
1343 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)
1344 {
1345   sw=-1;
1346   if(PyInt_Check(value))
1347     {
1348       iTyypp=(int)PyInt_AS_LONG(value);
1349       sw=1;
1350       return;
1351     }
1352   if(PyTuple_Check(value))
1353     {
1354       int size=PyTuple_Size(value);
1355       stdvecTyypp.resize(size);
1356       for(int i=0;i<size;i++)
1357         {
1358           PyObject *o=PyTuple_GetItem(value,i);
1359           if(PyInt_Check(o))
1360             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1361           else
1362             {
1363               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1364               throw INTERP_KERNEL::Exception(oss.str().c_str());
1365             }
1366         }
1367       sw=2;
1368       return;
1369     }
1370   if(PyList_Check(value))
1371     {
1372       int size=PyList_Size(value);
1373       stdvecTyypp.resize(size);
1374       for(int i=0;i<size;i++)
1375         {
1376           PyObject *o=PyList_GetItem(value,i);
1377           if(PyInt_Check(o))
1378             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1379           else
1380             {
1381               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1382               throw INTERP_KERNEL::Exception(oss.str().c_str());
1383             }
1384         }
1385       sw=2;
1386       return;
1387     }
1388   if(PySlice_Check(value))
1389     {
1390       Py_ssize_t strt=2,stp=2,step=2;
1391       PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
1392       if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
1393         if(nbelem!=0 || strt!=0 || stp!=0)
1394           {
1395             std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elements is : " << nbelem;
1396             throw INTERP_KERNEL::Exception(oss.str().c_str());
1397           }
1398       p.first=strt;
1399       p.second.first=stp;
1400       p.second.second=step;
1401       sw=3;
1402       return ;
1403     }
1404   void *argp;
1405   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
1406   if(!SWIG_IsOK(status))
1407     throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayIntTuple");
1408   daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
1409   sw=4;
1410 }
1411
1412 /*!
1413  * if python string with size one -> cpp char sw=1
1414  * if python string with size different from one -> cpp string sw=2
1415  * if python tuple[string] or list[string] -> vector<string> sw=3
1416  * if python not null pointer of DataArrayChar -> cpp DataArrayChar sw=4
1417  * switch between (int,string,vector<string>,DataArrayChar)
1418  */
1419 static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, ParaMEDMEM::DataArrayChar *& dacType) throw(INTERP_KERNEL::Exception)
1420 {
1421   const char *msg="4 types accepted : string, list or tuple of strings having same size, not null DataArrayChar instance.";
1422   sw=-1;
1423   if(PyString_Check(value))
1424     {
1425       const char *pt=PyString_AsString(value);
1426       Py_ssize_t sz=PyString_Size(value);
1427       if(sz==1)
1428         {
1429           cTyp=pt[0];
1430           sw=1;
1431           return;
1432         }
1433       else
1434         {
1435           sType=pt;
1436           sw=2;
1437           return;
1438         }
1439     }
1440   if(PyTuple_Check(value))
1441     {
1442       int size=PyTuple_Size(value);
1443       vsType.resize(size);
1444       for(int i=0;i<size;i++)
1445         {
1446           PyObject *o=PyTuple_GetItem(value,i);
1447           if(PyString_Check(o))
1448             vsType[i]=PyString_AsString(o);
1449           else
1450             {
1451               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1452               throw INTERP_KERNEL::Exception(oss.str().c_str());
1453             }
1454         }
1455       sw=3;
1456       return;
1457     }
1458   if(PyList_Check(value))
1459     {
1460       int size=PyList_Size(value);
1461       vsType.resize(size);
1462       for(int i=0;i<size;i++)
1463         {
1464           PyObject *o=PyList_GetItem(value,i);
1465           if(PyString_Check(o))
1466             vsType[i]=PyString_AsString(o);
1467           else
1468             {
1469               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not string ! only lists of strings accepted !";
1470               throw INTERP_KERNEL::Exception(oss.str().c_str());
1471             }
1472         }
1473       sw=3;
1474       return;
1475     }
1476   void *argp;
1477   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayChar,0|0);
1478   if(SWIG_IsOK(status))
1479     {
1480       dacType=reinterpret_cast< ParaMEDMEM::DataArrayChar * >(argp);
1481       if(!dacType)
1482         {
1483           std::ostringstream oss; oss << msg << " Instance in null !";
1484           throw INTERP_KERNEL::Exception(oss.str().c_str());
1485         }
1486       sw=4;
1487       return ;
1488     }
1489   throw INTERP_KERNEL::Exception(msg);
1490 }
1491
1492 /*!
1493  * if value int -> cpp it sw=1
1494  * if value list[int] -> vt sw=2
1495  * if value tuple[int] -> vt sw=2
1496  * if value slice -> pt sw=3
1497  * if value DataArrayInt -> dt sw=4
1498  * if value tuple [int,int] -> cpp it,ip sw=5
1499  * if value tuple [list[int],int] -> cpp vt,ip sw=6
1500  * if value tuple [tuple[int],int] -> cpp vt,ip sw=6
1501  * if value tuple [slice,int] -> cpp pt,ip sw=7
1502  * if value tuple [DaI,int] -> cpp dt,ip sw=8
1503  * if value tuple [int,list[int]] -> cpp it,vc sw=9
1504  * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10
1505  * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10
1506  * if value tuple [slice,list[int]] -> cpp pt,vc sw=11
1507  * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12
1508  * if value tuple [int,tuple[int]] -> cpp it,vc sw=9
1509  * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10
1510  * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10
1511  * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11
1512  * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12
1513  * if value tuple [int,slice] -> cpp it,pc sw=13
1514  * if value tuple [list[int],slice] -> cpp vt,pc sw=14
1515  * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14
1516  * if value tuple [slice,slice] -> cpp pt,pc sw=15
1517  * if value tuple [DaI,slice] -> cpp dt,pc sw=16
1518  *
1519  * switch between (int,vector<int>,DataArrayInt)
1520  */
1521 static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
1522                                      std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
1523                                      ParaMEDMEM::DataArrayInt *&dt, ParaMEDMEM::DataArrayInt *&dc) throw(INTERP_KERNEL::Exception)
1524 {
1525   if(!PyTuple_Check(value))
1526     {
1527       convertObjToPossibleCpp2(value,nbTuple,sw,it,vt,pt,dt);
1528       return ;
1529     }
1530   else
1531     {
1532       int sz=PyTuple_Size(value);
1533       if(sz!=2)
1534         throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
1535       PyObject *ob0=PyTuple_GetItem(value,0);
1536       int sw1,sw2;
1537       convertObjToPossibleCpp2(ob0,nbTuple,sw1,it,vt,pt,dt);
1538       PyObject *ob1=PyTuple_GetItem(value,1);
1539       convertObjToPossibleCpp2(ob1,nbCompo,sw2,ic,vc,pc,dc);
1540       sw=4*sw2+sw1;
1541     }
1542 }
1543
1544 /*!
1545  * if value int -> cpp val sw=1
1546  * if value double -> cpp val sw=1
1547  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1548  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1549  * if value list[int,double] -> cpp std::vector<double> sw=4
1550  * if value tuple[int,double] -> cpp std::vector<double> sw=4
1551  */
1552 static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f)
1553 {
1554   sw=-1;
1555   if(PyFloat_Check(value))
1556     {
1557       val=PyFloat_AS_DOUBLE(value);
1558       sw=1;
1559       return;
1560     }
1561   if(PyInt_Check(value))
1562     {
1563       val=(double)PyInt_AS_LONG(value);
1564       sw=1;
1565       return;
1566     }
1567   if(PyTuple_Check(value))
1568     {
1569       int size=PyTuple_Size(value);
1570       f.resize(size);
1571       for(int i=0;i<size;i++)
1572         {
1573           PyObject *o=PyTuple_GetItem(value,i);
1574           if(PyFloat_Check(o))
1575             f[i]=PyFloat_AS_DOUBLE(o);
1576           else if(PyInt_Check(o))
1577             f[i]=(double)PyInt_AS_LONG(o);
1578           else
1579             {
1580               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1581               throw INTERP_KERNEL::Exception(oss.str().c_str());
1582             }
1583         }
1584       sw=4;
1585       return;
1586     }
1587   if(PyList_Check(value))
1588     {
1589       int size=PyList_Size(value);
1590       f.resize(size);
1591       for(int i=0;i<size;i++)
1592         {
1593           PyObject *o=PyList_GetItem(value,i);
1594           if(PyFloat_Check(o))
1595             f[i]=PyFloat_AS_DOUBLE(o);
1596           else if(PyInt_Check(o))
1597             f[i]=(double)PyInt_AS_LONG(o);
1598           else
1599             {
1600               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1601               throw INTERP_KERNEL::Exception(oss.str().c_str());
1602             }
1603         }
1604       sw=4;
1605       return;
1606     }
1607   void *argp;
1608   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
1609   if(SWIG_IsOK(status))
1610     {  
1611       d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
1612       sw=2;
1613       return ;
1614     }
1615   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
1616   if(SWIG_IsOK(status))
1617     {  
1618       e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
1619       sw=3;
1620       return ;
1621     }
1622   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
1623 }
1624
1625 /*!
1626  * if value int -> cpp val sw=1
1627  * if value double -> cpp val sw=1
1628  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1629  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1630  * if value list[int,double] -> cpp std::vector<double> sw=4
1631  * if value tuple[int,double] -> cpp std::vector<double> sw=4
1632  */
1633 static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f,
1634                                                    const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt) throw(INTERP_KERNEL::Exception)
1635 {
1636   sw=-1;
1637   if(PyFloat_Check(value))
1638     {
1639       val=PyFloat_AS_DOUBLE(value);
1640       sw=1;
1641       if(nbTuplesExpected*nbCompExpected!=1)
1642         {
1643           std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyFloat) !"; 
1644           throw INTERP_KERNEL::Exception(oss.str().c_str());
1645         }
1646       return &val;
1647     }
1648   if(PyInt_Check(value))
1649     {
1650       val=(double)PyInt_AS_LONG(value);
1651       sw=1;
1652       if(nbTuplesExpected*nbCompExpected!=1)
1653         {
1654           std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !"; 
1655           throw INTERP_KERNEL::Exception(oss.str().c_str());
1656         }
1657       return &val;
1658     }
1659   if(PyTuple_Check(value) || PyList_Check(value))
1660     {
1661       try
1662         {
1663           int tmp1=nbTuplesExpected,tmp2=nbCompExpected;
1664           std::vector<double> ret=fillArrayWithPyListDbl2(value,tmp1,tmp2);
1665           sw=4;
1666           f=ret;
1667           return &f[0];
1668         }
1669       catch(INTERP_KERNEL::Exception& exc) { throw exc; }
1670     }
1671   void *argp;
1672   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
1673   if(SWIG_IsOK(status))
1674     {  
1675       d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
1676       sw=2;
1677       if(d)
1678         {
1679           if(d->getNumberOfTuples()==nbTuplesExpected)
1680             {
1681               if(d->getNumberOfComponents()==nbCompExpected)
1682                 {
1683                   return d->getConstPointer();
1684                 }
1685               else
1686                 {
1687                   std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
1688                   throw INTERP_KERNEL::Exception(oss.str().c_str());
1689                 }
1690             }
1691           else
1692             {
1693               std::ostringstream oss; oss << msg << " input DataArrayDouble should have a number of tuples equal to " << nbTuplesExpected << " and there are " << d->getNumberOfTuples() << " tuples !";
1694               throw INTERP_KERNEL::Exception(oss.str().c_str());
1695             }
1696         }
1697       else
1698         {
1699           if(throwIfNullPt)
1700             {
1701               std::ostringstream oss; oss << msg << " null pointer not accepted!";
1702               throw INTERP_KERNEL::Exception(oss.str().c_str());
1703             }
1704           else
1705             return 0;
1706         }
1707     }
1708   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
1709   if(SWIG_IsOK(status))
1710     {  
1711       e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
1712       sw=3;
1713       if(e->getNumberOfCompo()==nbCompExpected)
1714         {
1715           if(nbTuplesExpected==1)
1716             return e->getConstPointer();
1717           else
1718             {
1719               std::ostringstream oss; oss << msg << "nb of tuples expected to be " << nbTuplesExpected << " , and input DataArrayDoubleTuple has always one tuple by contruction !";
1720               throw INTERP_KERNEL::Exception(oss.str().c_str());
1721             }
1722         }
1723       else
1724         {
1725           std::ostringstream oss; oss << msg << "nb of components expected to be " <<  nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
1726           throw INTERP_KERNEL::Exception(oss.str().c_str());
1727         }
1728     }
1729   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
1730 }
1731
1732 /*!
1733  * if value int -> cpp val sw=1
1734  * if value double -> cpp val sw=1
1735  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1736  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1737  * if value list[int,double] -> cpp std::vector<double> sw=4
1738  * if value tuple[int,double] -> cpp std::vector<double> sw=4
1739  */
1740 static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f,
1741                                                     const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
1742 {
1743   sw=-1;
1744   if(PyFloat_Check(value))
1745     {
1746       val=PyFloat_AS_DOUBLE(value);
1747       sw=1;
1748       if(nbCompExpected!=1)
1749         {
1750           std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyFloat) !"; 
1751           throw INTERP_KERNEL::Exception(oss.str().c_str());
1752         }
1753       nbTuples=1;
1754       return &val;
1755     }
1756   if(PyInt_Check(value))
1757     {
1758       val=(double)PyInt_AS_LONG(value);
1759       sw=1;
1760       if(nbCompExpected!=1)
1761         {
1762           std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyInt) !"; 
1763           throw INTERP_KERNEL::Exception(oss.str().c_str());
1764         }
1765       nbTuples=1;
1766       return &val;
1767     }
1768   if(PyTuple_Check(value))
1769     {
1770       int size=PyTuple_Size(value);
1771       f.resize(size);
1772       for(int i=0;i<size;i++)
1773         {
1774           PyObject *o=PyTuple_GetItem(value,i);
1775           if(PyFloat_Check(o))
1776             f[i]=PyFloat_AS_DOUBLE(o);
1777           else if(PyInt_Check(o))
1778             f[i]=(double)PyInt_AS_LONG(o);
1779           else
1780             {
1781               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1782               throw INTERP_KERNEL::Exception(oss.str().c_str());
1783             }
1784         }
1785       sw=4;
1786       if(size%nbCompExpected!=0)
1787         {
1788           std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !"; 
1789           throw INTERP_KERNEL::Exception(oss.str().c_str());
1790         }
1791       nbTuples=size/nbCompExpected;
1792       return &f[0];
1793     }
1794   if(PyList_Check(value))
1795     {
1796       int size=PyList_Size(value);
1797       f.resize(size);
1798       for(int i=0;i<size;i++)
1799         {
1800           PyObject *o=PyList_GetItem(value,i);
1801           if(PyFloat_Check(o))
1802             f[i]=PyFloat_AS_DOUBLE(o);
1803           else if(PyInt_Check(o))
1804             f[i]=(double)PyInt_AS_LONG(o);
1805           else
1806             {
1807               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1808               throw INTERP_KERNEL::Exception(oss.str().c_str());
1809             }
1810         }
1811       sw=4;
1812       if(size%nbCompExpected!=0)
1813         {
1814           std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !"; 
1815           throw INTERP_KERNEL::Exception(oss.str().c_str());
1816         }
1817       nbTuples=size/nbCompExpected;
1818       return &f[0];
1819     }
1820   void *argp;
1821   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
1822   if(SWIG_IsOK(status))
1823     {  
1824       d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
1825       sw=2;
1826       if(d)
1827         {
1828           if(d->getNumberOfComponents()==nbCompExpected)
1829             {
1830               nbTuples=d->getNumberOfTuples();
1831               return d->getConstPointer();
1832             }
1833           else
1834             {
1835               std::ostringstream oss; oss << msg << "nb of components expected to be a multiple of " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
1836               throw INTERP_KERNEL::Exception(oss.str().c_str());
1837             }
1838         }
1839       else
1840         {
1841           if(throwIfNullPt)
1842             {
1843               std::ostringstream oss; oss << msg << " null pointer not accepted!";
1844               throw INTERP_KERNEL::Exception(oss.str().c_str());
1845             }
1846           else
1847             { nbTuples=0; return 0; }
1848         }
1849     }
1850   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
1851   if(SWIG_IsOK(status))
1852     {  
1853       e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
1854       sw=3;
1855       if(e)
1856         {
1857           if(e->getNumberOfCompo()==nbCompExpected)
1858             {
1859               nbTuples=1;
1860               return e->getConstPointer();
1861             }
1862           else
1863             {
1864               std::ostringstream oss; oss << msg << "nb of components expected to be " <<  nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
1865               throw INTERP_KERNEL::Exception(oss.str().c_str());
1866             }
1867         }
1868       else
1869         {
1870           if(throwIfNullPt)
1871             {
1872               std::ostringstream oss; oss << msg << " null pointer not accepted!";
1873               throw INTERP_KERNEL::Exception(oss.str().c_str());
1874             }
1875           else
1876             { nbTuples=0; return 0; }
1877         }
1878     }
1879   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
1880 }
1881
1882 /*!
1883  * if value int -> cpp val sw=1
1884  * if value double -> cpp val sw=1
1885  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1886  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1887  * if value list[int,double] -> cpp std::vector<double> sw=4
1888  * if value tuple[int,double] -> cpp std::vector<double> sw=4
1889  */
1890 static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
1891                                                           const char *msg, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
1892 {
1893   ParaMEDMEM::DataArrayDouble *d=0;
1894   ParaMEDMEM::DataArrayDoubleTuple *e=0;
1895   sw=-1;
1896   if(PyFloat_Check(value))
1897     {
1898       val=PyFloat_AS_DOUBLE(value);
1899       sw=1;
1900       nbTuples=1;
1901       return &val;
1902     }
1903   if(PyInt_Check(value))
1904     {
1905       val=(double)PyInt_AS_LONG(value);
1906       sw=1;
1907       nbTuples=1;
1908       return &val;
1909     }
1910   if(PyTuple_Check(value))
1911     {
1912       int size=PyTuple_Size(value);
1913       f.resize(size);
1914       for(int i=0;i<size;i++)
1915         {
1916           PyObject *o=PyTuple_GetItem(value,i);
1917           if(PyFloat_Check(o))
1918             f[i]=PyFloat_AS_DOUBLE(o);
1919           else if(PyInt_Check(o))
1920             f[i]=(double)PyInt_AS_LONG(o);
1921           else
1922             {
1923               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1924               throw INTERP_KERNEL::Exception(oss.str().c_str());
1925             }
1926         }
1927       sw=4;
1928       nbTuples=size;
1929       return &f[0];
1930     }
1931   if(PyList_Check(value))
1932     {
1933       int size=PyList_Size(value);
1934       f.resize(size);
1935       for(int i=0;i<size;i++)
1936         {
1937           PyObject *o=PyList_GetItem(value,i);
1938           if(PyFloat_Check(o))
1939             f[i]=PyFloat_AS_DOUBLE(o);
1940           else if(PyInt_Check(o))
1941             f[i]=(double)PyInt_AS_LONG(o);
1942           else
1943             {
1944               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1945               throw INTERP_KERNEL::Exception(oss.str().c_str());
1946             }
1947         }
1948       sw=4;
1949       nbTuples=size;
1950       return &f[0];
1951     }
1952   void *argp;
1953   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
1954   if(SWIG_IsOK(status))
1955     {  
1956       d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
1957       sw=2;
1958       if(d)
1959         {
1960           if(d->getNumberOfComponents()==1)
1961             {
1962               nbTuples=d->getNumberOfTuples();
1963               return d->getConstPointer();
1964             }
1965           else
1966             {
1967               std::ostringstream oss; oss << msg << "nb of components expected to be one, and input has " << d->getNumberOfComponents() << " components !";
1968               throw INTERP_KERNEL::Exception(oss.str().c_str());
1969             }
1970         }
1971       else
1972         {
1973           if(throwIfNullPt)
1974             {
1975               std::ostringstream oss; oss << msg << " null pointer not accepted!";
1976               throw INTERP_KERNEL::Exception(oss.str().c_str());
1977             }
1978           else
1979             { nbTuples=0; return 0; }
1980         }
1981     }
1982   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
1983   if(SWIG_IsOK(status))
1984     {  
1985       e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
1986       sw=3;
1987       if(e)
1988         {
1989           nbTuples=e->getNumberOfCompo();
1990           return e->getConstPointer();
1991         }
1992       else
1993         {
1994           if(throwIfNullPt)
1995             {
1996               std::ostringstream oss; oss << msg << " null pointer not accepted!";
1997               throw INTERP_KERNEL::Exception(oss.str().c_str());
1998             }
1999           else
2000             { nbTuples=0; return 0; }
2001         }
2002     }
2003   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2004 }
2005
2006 /*!
2007  * if python int -> cpp int sw=1
2008  * if python list[int] -> cpp vector<int> sw=2
2009  * if python tuple[int] -> cpp vector<int> sw=2
2010  * if python DataArrayInt -> cpp DataArrayInt sw=3
2011  * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
2012  *
2013  * switch between (int,vector<int>,DataArrayInt)
2014  */
2015 static const int *convertObjToPossibleCpp1_Safe(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector<int>& stdvecTyypp) throw(INTERP_KERNEL::Exception)
2016 {
2017   sw=-1;
2018   if(PyInt_Check(value))
2019     {
2020       iTyypp=(int)PyInt_AS_LONG(value);
2021       sw=1; sz=1;
2022       return &iTyypp;
2023     }
2024   if(PyTuple_Check(value))
2025     {
2026       int size=PyTuple_Size(value);
2027       stdvecTyypp.resize(size);
2028       for(int i=0;i<size;i++)
2029         {
2030           PyObject *o=PyTuple_GetItem(value,i);
2031           if(PyInt_Check(o))
2032             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
2033           else
2034             {
2035               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
2036               throw INTERP_KERNEL::Exception(oss.str().c_str());
2037             }
2038         }
2039       sw=2; sz=size;
2040       return &stdvecTyypp[0];
2041     }
2042   if(PyList_Check(value))
2043     {
2044       int size=PyList_Size(value);
2045       stdvecTyypp.resize(size);
2046       for(int i=0;i<size;i++)
2047         {
2048           PyObject *o=PyList_GetItem(value,i);
2049           if(PyInt_Check(o))
2050             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
2051           else
2052             {
2053               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
2054               throw INTERP_KERNEL::Exception(oss.str().c_str());
2055             }
2056         }
2057       sw=2; sz=size;
2058       return &stdvecTyypp[0];
2059     }
2060   void *argp;
2061   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
2062   if(SWIG_IsOK(status))
2063     {
2064       ParaMEDMEM::DataArrayInt *daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
2065       if(daIntTyypp)
2066         {
2067           sw=3; sz=daIntTyypp->getNbOfElems();
2068           return daIntTyypp->begin();
2069         }
2070       else
2071         {
2072           sz=0;
2073           return 0;
2074         }
2075     }
2076   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
2077   if(SWIG_IsOK(status))
2078     {  
2079       ParaMEDMEM::DataArrayIntTuple *daIntTuple=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
2080       sw=4; sz=daIntTuple->getNumberOfCompo();
2081       return daIntTuple->getConstPointer();
2082     }
2083   throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
2084 }
2085
2086 static ParaMEDMEM::MEDCouplingFieldDouble *ParaMEDMEM_MEDCouplingFieldDouble___add__Impl(ParaMEDMEM::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
2087 {
2088   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.";
2089   const char msg2[]="in MEDCouplingFieldDouble.__add__ : self field has no Array of values set !";
2090   void *argp;
2091   //
2092   if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,0|0)))
2093     {
2094       ParaMEDMEM::MEDCouplingFieldDouble *other=reinterpret_cast< ParaMEDMEM::MEDCouplingFieldDouble * >(argp);
2095       if(other)
2096         return (*self)+(*other);
2097       else
2098         throw INTERP_KERNEL::Exception(msg);
2099     }
2100   //
2101   double val;
2102   ParaMEDMEM::DataArrayDouble *a;
2103   ParaMEDMEM::DataArrayDoubleTuple *aa;
2104   std::vector<double> bb;
2105   int sw;
2106   convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
2107   switch(sw)
2108     {
2109     case 1:
2110       {
2111         if(!self->getArray())
2112           throw INTERP_KERNEL::Exception(msg2);
2113         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=self->getArray()->deepCpy();
2114         ret->applyLin(1.,val);
2115         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2116         ret2->setArray(ret);
2117         return ret2.retn();
2118       }
2119     case 2:
2120       {
2121         if(!self->getArray())
2122           throw INTERP_KERNEL::Exception(msg2);
2123         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Add(self->getArray(),a);
2124         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2125         ret2->setArray(ret);
2126         return ret2.retn();
2127       }
2128     case 3:
2129       {
2130         if(!self->getArray())
2131           throw INTERP_KERNEL::Exception(msg2);
2132         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
2133         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Add(self->getArray(),aaa);
2134         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2135         ret2->setArray(ret);
2136         return ret2.retn();
2137       }
2138     case 4:
2139       {
2140         if(!self->getArray())
2141           throw INTERP_KERNEL::Exception(msg2);
2142         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> aaa=ParaMEDMEM::DataArrayDouble::New(); aaa->useArray(&bb[0],false,ParaMEDMEM::CPP_DEALLOC,1,(int)bb.size());
2143         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Add(self->getArray(),aaa);
2144         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2145         ret2->setArray(ret);
2146         return ret2.retn();
2147       }
2148     default:
2149       { throw INTERP_KERNEL::Exception(msg); }
2150     }
2151 }
2152
2153 static ParaMEDMEM::MEDCouplingFieldDouble *ParaMEDMEM_MEDCouplingFieldDouble___radd__Impl(ParaMEDMEM::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
2154 {
2155   return ParaMEDMEM_MEDCouplingFieldDouble___add__Impl(self,obj);
2156 }
2157
2158 static ParaMEDMEM::MEDCouplingFieldDouble *ParaMEDMEM_MEDCouplingFieldDouble___rsub__Impl(ParaMEDMEM::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
2159 {
2160   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.";
2161   const char msg2[]="in MEDCouplingFieldDouble.__rsub__ : self field has no Array of values set !";
2162   void *argp;
2163   //
2164   if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,0|0)))
2165     {
2166       ParaMEDMEM::MEDCouplingFieldDouble *other=reinterpret_cast< ParaMEDMEM::MEDCouplingFieldDouble * >(argp);
2167       if(other)
2168         return (*other)-(*self);
2169       else
2170         throw INTERP_KERNEL::Exception(msg);
2171     }
2172   //
2173   double val;
2174   ParaMEDMEM::DataArrayDouble *a;
2175   ParaMEDMEM::DataArrayDoubleTuple *aa;
2176   std::vector<double> bb;
2177   int sw;
2178   convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
2179   switch(sw)
2180     {
2181     case 1:
2182       {
2183         if(!self->getArray())
2184           throw INTERP_KERNEL::Exception(msg2);
2185         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=self->getArray()->deepCpy();
2186         ret->applyLin(-1.,val);
2187         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2188         ret2->setArray(ret);
2189         return ret2.retn();
2190       }
2191     case 2:
2192       {
2193         if(!self->getArray())
2194           throw INTERP_KERNEL::Exception(msg2);
2195         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Substract(a,self->getArray());
2196         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2197         ret2->setArray(ret);
2198         return ret2.retn();
2199       }
2200     case 3:
2201       {
2202         if(!self->getArray())
2203           throw INTERP_KERNEL::Exception(msg2);
2204         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
2205         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Substract(aaa,self->getArray());
2206         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2207         ret2->setArray(ret);
2208         return ret2.retn();
2209       }
2210     case 4:
2211       {
2212         if(!self->getArray())
2213           throw INTERP_KERNEL::Exception(msg2);
2214         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> aaa=ParaMEDMEM::DataArrayDouble::New(); aaa->useArray(&bb[0],false,ParaMEDMEM::CPP_DEALLOC,1,(int)bb.size());
2215         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Substract(aaa,self->getArray());
2216         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2217         ret2->setArray(ret);
2218         return ret2.retn();
2219       }
2220     default:
2221       { throw INTERP_KERNEL::Exception(msg); }
2222     }
2223 }
2224
2225 static ParaMEDMEM::MEDCouplingFieldDouble *ParaMEDMEM_MEDCouplingFieldDouble___mul__Impl(ParaMEDMEM::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
2226 {
2227   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.";
2228   const char msg2[]="in MEDCouplingFieldDouble.__mul__ : self field has no Array of values set !";
2229   void *argp;
2230   //
2231   if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,0|0)))
2232     {
2233       ParaMEDMEM::MEDCouplingFieldDouble *other=reinterpret_cast< ParaMEDMEM::MEDCouplingFieldDouble * >(argp);
2234       if(other)
2235         return (*self)*(*other);
2236       else
2237         throw INTERP_KERNEL::Exception(msg);
2238     }
2239   //
2240   double val;
2241   ParaMEDMEM::DataArrayDouble *a;
2242   ParaMEDMEM::DataArrayDoubleTuple *aa;
2243   std::vector<double> bb;
2244   int sw;
2245   convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
2246   switch(sw)
2247     {
2248     case 1:
2249       {
2250         if(!self->getArray())
2251           throw INTERP_KERNEL::Exception(msg2);
2252         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=self->getArray()->deepCpy();
2253         ret->applyLin(val,0.);
2254         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2255         ret2->setArray(ret);
2256         return ret2.retn();
2257       }
2258     case 2:
2259       {
2260         if(!self->getArray())
2261           throw INTERP_KERNEL::Exception(msg2);
2262         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Multiply(self->getArray(),a);
2263         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2264         ret2->setArray(ret);
2265         return ret2.retn();
2266       }
2267     case 3:
2268       {
2269         if(!self->getArray())
2270           throw INTERP_KERNEL::Exception(msg2);
2271         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
2272         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Multiply(self->getArray(),aaa);
2273         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2274         ret2->setArray(ret);
2275         return ret2.retn();
2276       }
2277     case 4:
2278       {
2279         if(!self->getArray())
2280           throw INTERP_KERNEL::Exception(msg2);
2281         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> aaa=ParaMEDMEM::DataArrayDouble::New(); aaa->useArray(&bb[0],false,ParaMEDMEM::CPP_DEALLOC,1,(int)bb.size());
2282         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Multiply(self->getArray(),aaa);
2283         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2284         ret2->setArray(ret);
2285         return ret2.retn();
2286       }
2287     default:
2288       { throw INTERP_KERNEL::Exception(msg); }
2289     }
2290 }
2291
2292 ParaMEDMEM::MEDCouplingFieldDouble *ParaMEDMEM_MEDCouplingFieldDouble___rmul__Impl(ParaMEDMEM::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
2293 {
2294   return ParaMEDMEM_MEDCouplingFieldDouble___mul__Impl(self,obj);
2295 }
2296
2297 ParaMEDMEM::MEDCouplingFieldDouble *ParaMEDMEM_MEDCouplingFieldDouble___rdiv__Impl(ParaMEDMEM::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
2298 {
2299   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.";
2300   const char msg2[]="in MEDCouplingFieldDouble.__div__ : self field has no Array of values set !";
2301   void *argp;
2302   //
2303   if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,0|0)))
2304     {
2305       ParaMEDMEM::MEDCouplingFieldDouble *other=reinterpret_cast< ParaMEDMEM::MEDCouplingFieldDouble * >(argp);
2306       if(other)
2307         return (*other)/(*self);
2308       else
2309         throw INTERP_KERNEL::Exception(msg);
2310     }
2311   //
2312   double val;
2313   ParaMEDMEM::DataArrayDouble *a;
2314   ParaMEDMEM::DataArrayDoubleTuple *aa;
2315   std::vector<double> bb;
2316   int sw;
2317   convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
2318   switch(sw)
2319     {
2320     case 1:
2321       {
2322         if(!self->getArray())
2323           throw INTERP_KERNEL::Exception(msg2);
2324         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=self->getArray()->deepCpy();
2325         ret->applyInv(val);
2326         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2327         ret2->setArray(ret);
2328         return ret2.retn();
2329       }
2330     case 2:
2331       {
2332         if(!self->getArray())
2333           throw INTERP_KERNEL::Exception(msg2);
2334         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Divide(a,self->getArray());
2335         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2336         ret2->setArray(ret);
2337         return ret2.retn();
2338       }
2339     case 3:
2340       {
2341         if(!self->getArray())
2342           throw INTERP_KERNEL::Exception(msg2);
2343         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
2344         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Divide(aaa,self->getArray());
2345         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2346         ret2->setArray(ret);
2347         return ret2.retn();
2348       }
2349     case 4:
2350       {
2351         if(!self->getArray())
2352           throw INTERP_KERNEL::Exception(msg2);
2353         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> aaa=ParaMEDMEM::DataArrayDouble::New(); aaa->useArray(&bb[0],false,ParaMEDMEM::CPP_DEALLOC,1,(int)bb.size());
2354         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> ret=ParaMEDMEM::DataArrayDouble::Divide(aaa,self->getArray());
2355         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> ret2=self->clone(false);
2356         ret2->setArray(ret);
2357         return ret2.retn();
2358       }
2359     default:
2360       { throw INTERP_KERNEL::Exception(msg); }
2361     }
2362 }