Salome HOME
typo-fix by Kunda
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingDataArrayTypemaps.i
1 // Copyright (C) 2007-2017  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, or (at your option) any later version.
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 // Author : Anthony Geay (EDF R&D)
20
21 #ifndef __MEDCOUPLINGDATAARRAYTYPEMAPS_I__
22 #define __MEDCOUPLINGDATAARRAYTYPEMAPS_I__
23
24 #if PY_VERSION_HEX >= 0x03000000
25 #define PyInt_AS_LONG PyLong_AS_LONG
26 #endif
27
28 #include "InterpKernelAutoPtr.hxx"
29 #include "MEDCouplingDataArrayTraits.hxx"
30
31 #include <sstream>
32
33 static PyObject *convertArray(MEDCoupling::DataArray *array, int owner)
34 {
35   PyObject *ret(NULL);
36   if(!array)
37     {
38       Py_XINCREF(Py_None);
39       return Py_None;
40     }
41   if(dynamic_cast<MEDCoupling::DataArrayDouble *>(array))
42     ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayDouble,owner);
43   if(dynamic_cast<MEDCoupling::DataArrayInt *>(array))
44     ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayInt,owner);
45   if(dynamic_cast<MEDCoupling::DataArrayFloat *>(array))
46     ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayFloat,owner);
47   if(!ret)
48     throw INTERP_KERNEL::Exception("Not recognized type of array on downcast !");
49   return ret;
50 }
51
52 /*!
53  * This method is an extension of PySlice_GetIndices but less
54  * open than PySlice_GetIndicesEx that accepts too many situations.
55  */
56 void GetIndicesOfSlice(PyObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
57 {
58   int ret(PySlice_GetIndices(
59 #if PY_VERSION_HEX >= 0x03000000
60         slice,
61 #else
62         reinterpret_cast<PySliceObject *>(slice),
63 #endif
64         length,start,stop,step));
65   if(ret==0)
66     return ;
67   if(*step>0 && *start==*stop && length==*start)
68     return ;
69   throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
70 }
71
72 /*!
73  * This method allows to retrieve slice info from \a slice.
74  */
75 void GetIndicesOfSliceExplicitely(PyObject *slice, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
76 {
77   int ret(PySlice_GetIndices(
78 #if PY_VERSION_HEX >= 0x03000000
79         slice,
80 #else
81         reinterpret_cast<PySliceObject *>(slice),
82 #endif
83         std::numeric_limits<int>::max(),start,stop,step));
84   if(ret==0)
85     {
86       if(*start!=std::numeric_limits<int>::max() && *stop!=std::numeric_limits<int>::max())
87         return ;
88       std::ostringstream oss;
89       oss << msgInCaseOfFailure << " The input slice contains some unknowns that can't be determined in static method ! The input slice must be explicit here !";
90       throw INTERP_KERNEL::Exception(oss.str().c_str());
91     }
92   throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
93 }
94
95 int InterpreteNegativeInt(int val, int nbelem)
96 {
97   if(val<0)
98     {
99       int newVal(nbelem+val);
100       if(newVal<0)
101         {
102           std::ostringstream oss; oss << "interpreteNegativeInt : request for negative int=" << val << " but number of elems is equal to " << nbelem << " !";
103           throw INTERP_KERNEL::Exception(oss.str().c_str());
104         }
105       return newVal;
106     }
107   else
108     return val;
109 }
110
111 #ifdef WITH_NUMPY
112 // this is the second type of specific deallocator, only valid for the constructor of DataArrays taking numpy array
113 // in input when an another DataArray is already client of this.
114 template<class MCData>
115 void numarrdeal2(void *pt, void *obj)
116 {
117   typedef struct PyCallBackDataArraySt<MCData> PyCallBackDataArray;
118   void **obj1=(void **)obj;
119   PyCallBackDataArray *cbdaic=reinterpret_cast<PyCallBackDataArray *>(obj1[0]);
120   PyObject *weakRefOnOwner=reinterpret_cast<PyObject *>(obj1[1]);
121   cbdaic->_pt_mc=0;
122   Py_XDECREF(weakRefOnOwner);
123   Py_XDECREF(cbdaic);
124   delete [] obj1;
125 }
126
127 template<class MCData, class T>
128 MCData *BuildNewInstance(PyObject *elt0, int npyObjectType, PyTypeObject *pytype, const char *msg)
129 {
130   int ndim=PyArray_NDIM(elt0);
131   if(ndim!=1 && ndim!=2)
132     throw INTERP_KERNEL::Exception("Input numpy array should have dimension equal to 1 or 2 !");
133   if(PyArray_DESCR(elt0)->type_num != npyObjectType)
134     {
135       std::ostringstream oss; oss << "Input numpy array has not the type " << msg << "!";
136       throw INTERP_KERNEL::Exception(oss.str().c_str());
137     }
138   npy_intp sz0=PyArray_DIM(elt0,0);
139   npy_intp sz1=ndim==2?PyArray_DIM(elt0,1):1;
140   //
141   int itemSize=PyArray_ITEMSIZE(elt0);
142   if(itemSize!=sizeof(T))
143     {
144       std::ostringstream oss; oss << "Input numpy array has not itemSize set to " << sizeof(T) << " !";
145       throw INTERP_KERNEL::Exception(oss.str().c_str());
146     }
147   if(itemSize*sz1!=PyArray_STRIDE(elt0,0))
148     throw INTERP_KERNEL::Exception("Input numpy array has stride that mismatches the item size ! Data are not packed in the right way for DataArrays !");
149   if(ndim==2)
150     if(itemSize!=PyArray_STRIDE(elt0,1))
151       throw INTERP_KERNEL::Exception("Input numpy array has stride that mismatches the item size ! Data are not packed in the right way for DataArrays for component #1 !");
152   const char *data=PyArray_BYTES(elt0);
153   typename MEDCoupling::MCAuto<MCData> ret=MCData::New();
154   if(PyArray_ISBEHAVED(elt0))//aligned and writeable and in machine byte-order
155     {
156       PyArrayObject *elt0C=reinterpret_cast<PyArrayObject *>(elt0);
157       PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & MED_NUMPY_OWNDATA)?elt0C:NULL;
158       int mask=MED_NUMPY_OWNDATA; mask=~mask;
159       elt0C->flags&=mask;
160       PyObject *deepestObj=elt0;
161       PyObject *base=elt0C->base;
162       if(base) deepestObj=base;
163       bool isSpetialCase(false);
164       while(base)
165         {
166           if(PyArray_Check(base))
167             {
168               PyArrayObject *baseC=reinterpret_cast<PyArrayObject *>(base);
169               eltOwning=(PyArray_FLAGS(baseC) & MED_NUMPY_OWNDATA)?baseC:eltOwning;
170               baseC->flags&=mask;
171               base=baseC->base;
172               if(base) deepestObj=base;
173             }
174           else
175             {
176               isSpetialCase=true;
177               break;
178             }
179         }
180       if(isSpetialCase)
181         {// this case is present for numpy arrayint coming from load of pickelized string. The owner of elt0 is not an array -> A copy is requested.
182           std::size_t nbOfElems(sz0*sz1);
183           T *dataCpy=(T*)malloc(sizeof(T)*nbOfElems);
184           std::copy(reinterpret_cast<const T*>(data),reinterpret_cast<const T*>(data)+nbOfElems,dataCpy);
185           ret->useArray(dataCpy,true,MEDCoupling::C_DEALLOC,sz0,sz1);
186           return ret.retn();
187         }
188       typename MEDCoupling::MemArray<T>& mma=ret->accessToMemArray();
189       if(eltOwning==NULL)
190         {
191           PyCallBackDataArraySt<MCData> *cb=PyObject_GC_New(PyCallBackDataArraySt<MCData>,pytype);
192           cb->_pt_mc=ret;
193           ret->useArray(reinterpret_cast<const T *>(data),true,MEDCoupling::C_DEALLOC,sz0,sz1);
194           PyObject *ref=PyWeakref_NewRef(deepestObj,(PyObject *)cb);
195           void **objs=new void *[2]; objs[0]=cb; objs[1]=ref;
196           mma.setParameterForDeallocator(objs);
197           mma.setSpecificDeallocator(numarrdeal2<MCData>);
198           //"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 !");
199         }
200       else
201         {
202           ret->useArray(reinterpret_cast<const T *>(data),true,MEDCoupling::C_DEALLOC,sz0,sz1);
203           PyObject *ref=PyWeakref_NewRef(reinterpret_cast<PyObject *>(eltOwning),NULL);
204           typename MEDCoupling::MemArray<T>::Deallocator tmp(MEDCoupling::MemArray<T>::CDeallocator);
205           void **tmp2 = reinterpret_cast<void**>(&tmp); // MSVC2010 does not support constructor()
206           void **objs=new void *[2]; objs[0]=ref; objs[1]=*tmp2;
207           mma.setParameterForDeallocator(objs);
208           mma.setSpecificDeallocator(numarrdeal);
209         }
210     }
211   else if(PyArray_ISBEHAVED_RO(elt0))
212     ret->useArray(reinterpret_cast<const T *>(data),false,MEDCoupling::CPP_DEALLOC,sz0,sz1);
213   return ret.retn();
214 }
215
216
217 int NumpyArrSetBaseObjectExt(PyArrayObject *arr, PyObject *obj)
218 {
219     if (obj == NULL) {
220         PyErr_SetString(PyExc_ValueError,
221                 "Cannot set the NumPy array 'base' "
222                 "dependency to NULL after initialization");
223         return -1;
224     }
225     /*
226      * Allow the base to be set only once. Once the object which
227      * owns the data is set, it doesn't make sense to change it.
228      */
229     if (PyArray_BASE(arr) != NULL) {
230         Py_DECREF(obj);
231         PyErr_SetString(PyExc_ValueError,
232                 "Cannot set the NumPy array 'base' "
233                 "dependency more than once");
234         return -1;
235     }
236
237     /*
238      * Don't allow infinite chains of views, always set the base
239      * to the first owner of the data.
240      * That is, either the first object which isn't an array,
241      * or the first object which owns its own data.
242      */
243
244     while (PyArray_Check(obj) && (PyObject *)arr != obj) {
245         PyArrayObject *obj_arr = (PyArrayObject *)obj;
246         PyObject *tmp;
247
248
249         /* If this array owns its own data, stop collapsing */
250         if (PyArray_CHKFLAGS(obj_arr, MED_NUMPY_OWNDATA )) {
251             break;
252         }
253
254         tmp = PyArray_BASE(obj_arr);
255         /* If there's no base, stop collapsing */
256         if (tmp == NULL) {
257             break;
258         }
259         /* Stop the collapse new base when the would not be of the same
260          * type (i.e. different subclass).
261          */
262         if (Py_TYPE(tmp) != Py_TYPE(arr)) {
263             break;
264         }
265
266
267         Py_INCREF(tmp);
268         Py_DECREF(obj);
269         obj = tmp;
270     }
271
272     /* Disallow circular references */
273     if ((PyObject *)arr == obj) {
274         Py_DECREF(obj);
275         PyErr_SetString(PyExc_ValueError,
276                 "Cannot create a circular NumPy array 'base' dependency");
277         return -1;
278     }
279
280     arr->base = obj;
281
282     return 0;
283 }
284
285 template<class MCData, class T>
286 PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, int nbTuples, int nbComp)
287 {
288   if(!self->isAllocated())
289     {
290       std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : this is not allocated !";
291       throw INTERP_KERNEL::Exception(oss.str().c_str());
292     }
293   MEDCoupling::MemArray<T>& mem=self->accessToMemArray();
294   if(nbComp==0)
295     {
296       std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : number of components of this is 0 ! Should be > 0 !";
297       throw INTERP_KERNEL::Exception(oss.str().c_str());
298     }
299   int nbDims=nbComp==1?1:2;
300   npy_intp dim[2];
301   dim[0]=(npy_intp)nbTuples; dim[1]=nbComp;
302   const T *bg=self->getConstPointer();
303   PyObject *ret(PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast<T *>(bg)));
304   if(mem.isDeallocatorCalled())
305     {
306       if(mem.getDeallocator()!=numarrdeal)
307         {// case for the first call of toNumPyArray
308           PyObject *ref(PyWeakref_NewRef(ret,NULL));
309           typename MEDCoupling::MemArray<T>::Deallocator tmp(mem.getDeallocator());
310           void **tmp2 = reinterpret_cast<void**>(&tmp); // MSVC2010 does not support constructor()
311           void **objs=new void *[2]; objs[0]=reinterpret_cast<void*>(ref); objs[1]=*tmp2;
312           mem.setParameterForDeallocator(objs);
313           mem.setSpecificDeallocator(numarrdeal);
314           return ret;
315         }
316       else
317         {// case for the second and other call of toNumPyArray
318           void **objs=(void **)mem.getParameterForDeallocator();
319           PyObject *weakRefOnOwner=(PyObject *)objs[0];
320           PyObject *obj=PyWeakref_GetObject(weakRefOnOwner);
321           if(obj!=Py_None)
322             {//the previous numArray exists let numpy deals the numpy array each other by declaring the still alive instance as base
323               Py_XINCREF(obj);
324               NumpyArrSetBaseObjectExt((PyArrayObject*)ret,obj);
325             }
326           else
327             {//the previous numArray no more exists -> declare the newly created numpy array as the first one.
328               Py_XDECREF(weakRefOnOwner);
329               PyObject *ref=PyWeakref_NewRef(ret,NULL);
330               objs[0]=ref;
331             }
332         }
333     }
334   return ret;
335 }
336
337 template<class MCData, class T>
338 PyObject *ToNumPyArray(MCData *self, int npyObjectType, const char *MCDataStr)
339 {
340   return ToNumPyArrayUnderground<MCData,T>(self,npyObjectType,MCDataStr,self->getNumberOfTuples(),self->getNumberOfComponents());
341 }
342
343 SWIGINTERN PyObject *MEDCoupling_DataArrayInt_toNumPyArray(MEDCoupling::DataArrayInt *self);
344 SWIGINTERN PyObject *MEDCoupling_DataArrayDouble_toNumPyArray(MEDCoupling::DataArrayDouble *self);
345
346 #endif
347
348 #ifdef WITH_SCIPY
349 PyObject *ToCSRMatrix(const std::vector<std::map<int,double> >& m, int nbCols)
350 {
351   int nbRows((int)m.size());
352   MEDCoupling::MCAuto<MEDCoupling::DataArrayInt> indPtr(MEDCoupling::DataArrayInt::New()),indices(MEDCoupling::DataArrayInt::New());
353   MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> data(MEDCoupling::DataArrayDouble::New());
354   indPtr->alloc(nbRows+1,1);
355   int *intPtr_ptr(indPtr->getPointer()); intPtr_ptr[0]=0; intPtr_ptr++;
356   int sz2(0);
357   for(std::vector<std::map<int,double> >::const_iterator it0=m.begin();it0!=m.end();it0++,intPtr_ptr++)
358     {
359       sz2+=(int)(*it0).size();
360       *intPtr_ptr=sz2;
361     }
362   indices->alloc(sz2,1); data->alloc(sz2,1);
363   int *indices_ptr(indices->getPointer());
364   double *data_ptr(data->getPointer());
365   for(std::vector<std::map<int,double> >::const_iterator it0=m.begin();it0!=m.end();it0++)
366     for(std::map<int,double>::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++,indices_ptr++,data_ptr++)
367       {
368         *indices_ptr=(*it1).first;
369         *data_ptr=(*it1).second;
370       }
371   PyObject *a(MEDCoupling_DataArrayDouble_toNumPyArray(data)),*b(MEDCoupling_DataArrayInt_toNumPyArray(indices)),*c(MEDCoupling_DataArrayInt_toNumPyArray(indPtr));
372   //
373   PyObject *args(PyTuple_New(1)),*args0(PyTuple_New(3)),*kw(PyDict_New()),*kw1(PyTuple_New(2));
374   PyTuple_SetItem(args0,0,a); PyTuple_SetItem(args0,1,b); PyTuple_SetItem(args0,2,c); PyTuple_SetItem(args,0,args0);
375   PyTuple_SetItem(kw1,0,PyInt_FromLong(nbRows)); PyTuple_SetItem(kw1,1,PyInt_FromLong(nbCols));
376   PyObject *tmp1(PyString_FromString("shape"));
377   PyDict_SetItem(kw,tmp1,kw1); Py_DECREF(tmp1); Py_DECREF(kw1);
378   PyObject* pdict=PyDict_New();
379   PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
380   PyObject *tmp(PyRun_String("from scipy.sparse import csr_matrix", Py_single_input, pdict, pdict));
381   if(!tmp)
382     throw INTERP_KERNEL::Exception("Problem during loading csr_matrix in scipy.sparse ! Is Scipy module available in present ?");
383   PyObject *csrMatrixCls=PyDict_GetItemString(pdict,"csr_matrix");
384   if(!csrMatrixCls)
385     throw INTERP_KERNEL::Exception("csr_matrix not found in scipy.sparse ! Is Scipy module available in present ?");
386   PyObject *ret(PyObject_Call(csrMatrixCls,args,kw));
387   Py_DECREF(pdict); Py_XDECREF(tmp); Py_DECREF(args); Py_DECREF(kw);
388   return ret;
389 }
390
391 #endif
392
393 static PyObject *convertDataArrayChar(MEDCoupling::DataArrayChar *dac, int owner)
394 {
395   PyObject *ret=0;
396   if(!dac)
397     {
398       Py_XINCREF(Py_None);
399       return Py_None;
400     }
401   if(dynamic_cast<MEDCoupling::DataArrayByte *>(dac))
402     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayByte,owner);
403   if(dynamic_cast<MEDCoupling::DataArrayAsciiChar *>(dac))
404     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,owner);
405   if(!ret)
406     throw INTERP_KERNEL::Exception("Not recognized type of DataArrayChar on downcast !");
407   return ret;
408 }
409
410 static PyObject *convertDataArray(MEDCoupling::DataArray *dac, int owner)
411 {
412   PyObject *ret=0;
413   if(!dac)
414     {
415       Py_XINCREF(Py_None);
416       return Py_None;
417     }
418   if(dynamic_cast<MEDCoupling::DataArrayDouble *>(dac))
419     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayDouble,owner);
420   if(dynamic_cast<MEDCoupling::DataArrayInt *>(dac))
421     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayInt,owner);
422   if(dynamic_cast<MEDCoupling::DataArrayFloat *>(dac))
423     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayFloat,owner);
424   if(dynamic_cast<MEDCoupling::DataArrayByte *>(dac))
425     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayByte,owner);
426   if(dynamic_cast<MEDCoupling::DataArrayAsciiChar *>(dac))
427     ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,owner);
428   if(!ret)
429     throw INTERP_KERNEL::Exception("Not recognized type of DataArray on downcast !");
430   return ret;
431 }
432
433 static PyObject *convertIntArrToPyList(const int *ptr, int size)
434 {
435   PyObject *ret=PyList_New(size);
436   for(int i=0;i<size;i++)
437     PyList_SetItem(ret,i,PyInt_FromLong(ptr[i]));
438   return ret;
439 }
440
441 static PyObject *convertIntArrToPyList2(const std::vector<int>& v)
442 {
443   int size=v.size();
444   PyObject *ret=PyList_New(size);
445   for(int i=0;i<size;i++)
446     PyList_SetItem(ret,i,PyInt_FromLong(v[i]));
447   return ret;
448 }
449
450 static PyObject *convertIntArrToPyList3(const std::set<int>& v)
451 {
452   int size=v.size();
453   PyObject *ret=PyList_New(size);
454   std::set<int>::const_iterator it=v.begin();
455   for(int i=0;i<size;i++,it++)
456     PyList_SetItem(ret,i,PyInt_FromLong(*it));
457   return ret;
458 }
459
460 static bool convertPyObjectToStrNT(PyObject *obj, std::string& ret)
461 {
462   if(PyString_Check(obj))
463     {
464       ret=PyString_AsString(obj);
465       return true;
466     }
467 #if PY_VERSION_HEX >= 0x03000000
468   else if(PyUnicode_Check(obj))
469     {
470       ret=PyUnicode_AsUTF8(obj);
471       return true;
472     }
473 #endif
474   return false;
475 }
476
477 static std::string convertPyObjectToStr(PyObject *obj, const char *msg=NULL)
478 {
479   std::string ret;
480   if(PyString_Check(obj))
481     ret=PyString_AsString(obj);
482 #if PY_VERSION_HEX >= 0x03000000
483   else if(PyUnicode_Check(obj))
484     ret=PyUnicode_AsUTF8(obj);
485 #endif
486   else
487     {
488       std::ostringstream oss;
489       if(msg)
490         oss << msg;
491       else
492         oss << "PyWrap convertPyObjectToStr : expect a string like py object !";
493       throw INTERP_KERNEL::Exception(oss.str());
494     }
495   return ret;
496 }
497
498 static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples)
499 {
500   PyObject *ret=PyList_New(nbOfTuples);
501   for(int i=0;i<nbOfTuples;i++)
502     {
503       PyObject *t=PyTuple_New(nbOfComp);
504       for(int j=0;j<nbOfComp;j++)
505         PyTuple_SetItem(t,j,PyInt_FromLong(vals[i*nbOfComp+j]));
506       PyList_SetItem(ret,i,t);
507     }
508   return ret;
509 }
510
511 static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
512 {
513   if(PyList_Check(pyLi))
514     {
515       *size=PyList_Size(pyLi);
516       int *tmp=new int[*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               tmp[i]=val;
524             }
525           else
526             {
527               delete [] tmp;
528               throw INTERP_KERNEL::Exception("list must contain integers only");
529             }
530         }
531       return tmp;
532     }
533   else if(PyTuple_Check(pyLi))
534     {
535       *size=PyTuple_Size(pyLi);
536       int *tmp=new int[*size];
537       for(int i=0;i<*size;i++)
538         {
539           PyObject *o=PyTuple_GetItem(pyLi,i);
540           if(PyInt_Check(o))
541             {
542               int val=(int)PyInt_AS_LONG(o);
543               tmp[i]=val;
544             }
545           else
546             {
547               delete [] tmp;
548               throw INTERP_KERNEL::Exception("tuple must contain integers only");
549             }
550         }
551       return tmp;
552     }
553   else
554     {
555       throw INTERP_KERNEL::Exception("convertPyToNewIntArr2 : not a list");
556     }
557 }
558
559 static PyObject *convertFromVectorPairInt(const std::vector< std::pair<int,int> >& arr)
560 {
561   PyObject *ret=PyList_New(arr.size());
562   for(std::size_t i=0;i<arr.size();i++)
563     {
564       PyObject *t=PyTuple_New(2);
565       PyTuple_SetItem(t,0,PyInt_FromLong(arr[i].first));
566       PyTuple_SetItem(t,1,PyInt_FromLong(arr[i].second));
567       PyList_SetItem(ret,i,t);
568     }
569   return ret;
570 }
571
572 static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair<int,int> >& arr)
573 {
574   const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !";
575   if(PyList_Check(pyLi))
576     {
577       int size=PyList_Size(pyLi);
578       arr.resize(size);
579       for(int i=0;i<size;i++)
580         {
581           PyObject *o=PyList_GetItem(pyLi,i);
582           if(PyTuple_Check(o))
583             {
584               int sz2=PyTuple_Size(o);
585               if(sz2!=2)
586                 throw INTERP_KERNEL::Exception(msg);
587               PyObject *o_0=PyTuple_GetItem(o,0);
588               if(!PyInt_Check(o_0))
589                 throw INTERP_KERNEL::Exception(msg);
590               PyObject *o_1=PyTuple_GetItem(o,1);
591               if(!PyInt_Check(o_1))
592                 throw INTERP_KERNEL::Exception(msg);
593               arr[i].first=(int)PyInt_AS_LONG(o_0);
594               arr[i].second=(int)PyInt_AS_LONG(o_1);
595             }
596           else
597             throw INTERP_KERNEL::Exception(msg);
598         }
599     }
600   else if(PyTuple_Check(pyLi))
601     {
602       int size=PyTuple_Size(pyLi);
603       arr.resize(size);
604       for(int i=0;i<size;i++)
605         {
606           PyObject *o=PyTuple_GetItem(pyLi,i);
607           if(PyTuple_Check(o))
608             {
609               int sz2=PyTuple_Size(o);
610               if(sz2!=2)
611                 throw INTERP_KERNEL::Exception(msg);
612               PyObject *o_0=PyTuple_GetItem(o,0);
613               if(!PyInt_Check(o_0))
614                 throw INTERP_KERNEL::Exception(msg);
615               PyObject *o_1=PyTuple_GetItem(o,1);
616               if(!PyInt_Check(o_1))
617                 throw INTERP_KERNEL::Exception(msg);
618               arr[i].first=(int)PyInt_AS_LONG(o_0);
619               arr[i].second=(int)PyInt_AS_LONG(o_1);
620             }
621           else
622             throw INTERP_KERNEL::Exception(msg);
623         }
624     }
625   else
626     throw INTERP_KERNEL::Exception(msg);
627 }
628
629 static void convertPyToVectorPairStringInt(PyObject *pyLi, std::vector< std::pair<std::string,int> >& arr)
630 {
631   const char msg[]="convertPyToVectorPairStringInt : list must contain tuples of 2 integers only or tuple must contain tuples of 1 string and 1 integer only !";
632   if(PyList_Check(pyLi))
633     {
634       int size=PyList_Size(pyLi);
635       arr.resize(size);
636       for(int i=0;i<size;i++)
637         {
638           PyObject *o=PyList_GetItem(pyLi,i);
639           if(PyTuple_Check(o))
640             {
641               int sz2=PyTuple_Size(o);
642               if(sz2!=2)
643                 throw INTERP_KERNEL::Exception(msg);
644               PyObject *o_0=PyTuple_GetItem(o,0);
645               PyObject *o_1=PyTuple_GetItem(o,1);
646               arr[i].first=convertPyObjectToStr(o_0,msg);
647               if(!PyInt_Check(o_1))
648                 throw INTERP_KERNEL::Exception(msg);
649               arr[i].second=(int)PyInt_AS_LONG(o_1);
650             }
651           else
652             throw INTERP_KERNEL::Exception(msg);
653         }
654     }
655   else if(PyTuple_Check(pyLi))
656     {
657       int size=PyTuple_Size(pyLi);
658       arr.resize(size);
659       for(int i=0;i<size;i++)
660         {
661           PyObject *o=PyTuple_GetItem(pyLi,i);
662           if(PyTuple_Check(o))
663             {
664               int sz2=PyTuple_Size(o);
665               if(sz2!=2)
666                 throw INTERP_KERNEL::Exception(msg);
667               PyObject *o_0=PyTuple_GetItem(o,0);
668               PyObject *o_1=PyTuple_GetItem(o,1);
669               arr[i].first=convertPyObjectToStr(o_0,msg);
670               if(!PyInt_Check(o_1))
671                 throw INTERP_KERNEL::Exception(msg);
672               arr[i].second=(int)PyInt_AS_LONG(o_1);
673             }
674           else
675             throw INTERP_KERNEL::Exception(msg);
676         }
677     }
678   else
679     throw INTERP_KERNEL::Exception(msg);
680 }
681
682 static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
683 {
684   if(PyList_Check(pyLi))
685     {
686       int size=PyList_Size(pyLi);
687       arr.resize(size);
688       for(int i=0;i<size;i++)
689         {
690           PyObject *o=PyList_GetItem(pyLi,i);
691           if(PyInt_Check(o))
692             {
693               int val=(int)PyInt_AS_LONG(o);
694               arr[i]=val;
695             }
696           else
697             throw INTERP_KERNEL::Exception("list must contain integers only");
698         }
699     }
700   else if(PyTuple_Check(pyLi))
701     {
702       int size=PyTuple_Size(pyLi);
703       arr.resize(size);
704       for(int i=0;i<size;i++)
705         {
706           PyObject *o=PyTuple_GetItem(pyLi,i);
707           if(PyInt_Check(o))
708             {
709               int val=(int)PyInt_AS_LONG(o);
710               arr[i]=val;
711             }
712           else
713             throw INTERP_KERNEL::Exception("tuple must contain integers only");
714         }
715     }
716   else
717     {
718       throw INTERP_KERNEL::Exception("convertPyToNewIntArr3 : not a list nor a tuple");
719     }
720 }
721
722 static void convertPyToNewIntArr4(PyObject *pyLi, int recurseLev, int nbOfSubPart, std::vector<int>& arr)
723 {
724   if(recurseLev<0)
725     throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : invalid list of integers level of recursion !");
726   arr.clear();
727   if(PyList_Check(pyLi))
728     {
729       int size=PyList_Size(pyLi);
730       for(int i=0;i<size;i++)
731         {
732           PyObject *o=PyList_GetItem(pyLi,i);
733           if(PyInt_Check(o))
734             {
735               int val=(int)PyInt_AS_LONG(o);
736               arr.push_back(val);
737             }
738           else
739             {
740               std::vector<int> arr2;
741               convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
742               if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
743                   {
744                     std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " <<  recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
745                     throw INTERP_KERNEL::Exception(oss.str().c_str());
746                   }
747               arr.insert(arr.end(),arr2.begin(),arr2.end());
748             }
749         }
750     }
751   else if(PyTuple_Check(pyLi))
752     {
753       int size=PyTuple_Size(pyLi);
754       for(int i=0;i<size;i++)
755         {
756           PyObject *o=PyTuple_GetItem(pyLi,i);
757           if(PyInt_Check(o))
758             {
759               int val=(int)PyInt_AS_LONG(o);
760               arr.push_back(val);
761             }
762           else
763             {
764               std::vector<int> arr2;
765               convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
766               if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
767                   {
768                     std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " <<  recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
769                     throw INTERP_KERNEL::Exception(oss.str().c_str());
770                   }
771               arr.insert(arr.end(),arr2.begin(),arr2.end());
772             }
773         }
774     }
775   else
776     throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : not a list nor a tuple recursively !");
777 }
778
779 static void checkFillArrayWithPyList(int size1, int size2, int& nbOfTuples, int& nbOfComp)
780 {
781   if(nbOfTuples==-1)
782     {
783       if(nbOfComp==-1) { nbOfTuples=size1; nbOfComp=size2; }
784       else { if(nbOfComp==size2) { nbOfTuples=size1; } else
785           {
786             std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
787             oss << " whereas nb of components expected is " << nbOfComp << " !";
788             throw INTERP_KERNEL::Exception(oss.str().c_str());
789           } }
790     }
791   else
792     {
793       if(nbOfComp!=-1)
794         {
795           if((nbOfTuples!=size1 || nbOfComp!=size2))
796             {
797               if(size2!=1 || size1!=nbOfComp*nbOfTuples)
798                 {
799                   std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
800                   oss << " whereas nb of tuples expected is " << nbOfTuples << " and number of components expected is " << nbOfComp << " !";
801                   throw INTERP_KERNEL::Exception(oss.str().c_str());
802                 }
803             }
804         }
805       else
806         {
807           if(nbOfTuples==size1)
808             nbOfComp=size2;
809           else
810             {
811               std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
812               oss << " whereas nb of tuples expected is " << nbOfTuples << " !";
813               throw INTERP_KERNEL::Exception(oss.str().c_str());
814             }
815         }
816     }
817 }
818
819 static void fillArrayWithPyListInt3(PyObject *pyLi, int& nbOfElt, std::vector<int>& ret)
820 {
821   static const char MSG[]="fillArrayWithPyListInt3 : It appears that the input list or tuple is composed by elts having different sizes !";
822   if(PyInt_Check(pyLi))
823     {
824       long val=PyInt_AS_LONG(pyLi);
825       if(nbOfElt==-1)
826         nbOfElt=1;
827       else
828         if(nbOfElt!=1)
829           throw INTERP_KERNEL::Exception(MSG);
830       ret.push_back(val);
831     }
832   else if(PyList_Check(pyLi))
833     {
834       int size=PyList_Size(pyLi);
835       int tmp=0;
836       for(int i=0;i<size;i++)
837         {
838           PyObject *o=PyList_GetItem(pyLi,i);
839           int tmp1=-1;
840           fillArrayWithPyListInt3(o,tmp1,ret);
841           tmp+=tmp1;
842         }
843       if(nbOfElt==-1)
844         nbOfElt=tmp;
845       else
846         {
847           if(nbOfElt!=tmp)
848             throw INTERP_KERNEL::Exception(MSG);
849         }
850     }
851   else if(PyTuple_Check(pyLi))
852     {
853       int size=PyTuple_Size(pyLi);
854       int tmp=0;
855       for(int i=0;i<size;i++)
856         {
857           PyObject *o=PyTuple_GetItem(pyLi,i);
858           int tmp1=-1;
859           fillArrayWithPyListInt3(o,tmp1,ret);
860           tmp+=tmp1;
861         }
862       if(nbOfElt==-1)
863         nbOfElt=tmp;
864       else
865         {
866           if(nbOfElt!=tmp)
867             throw INTERP_KERNEL::Exception(MSG);
868         }
869     }
870   else
871     throw INTERP_KERNEL::Exception("fillArrayWithPyListInt3 : Unrecognized type ! Should be a composition of tuple,list,int !");
872 }
873
874 static std::vector<int> fillArrayWithPyListInt2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp)
875 {
876   std::vector<int> ret;
877   int size1=-1,size2=-1;
878   if(PyList_Check(pyLi))
879     {
880       size1=PyList_Size(pyLi);
881       for(int i=0;i<size1;i++)
882         {
883           PyObject *o=PyList_GetItem(pyLi,i);
884           fillArrayWithPyListInt3(o,size2,ret);
885         }
886       if(size1==0)
887         size2=1;
888     }
889   else if(PyTuple_Check(pyLi))
890     {
891       size1=PyTuple_Size(pyLi);
892       for(int i=0;i<size1;i++)
893         {
894           PyObject *o=PyTuple_GetItem(pyLi,i);
895           fillArrayWithPyListInt3(o,size2,ret);
896         }
897       if(size1==0)
898         size2=1;
899     }
900   else
901     throw INTERP_KERNEL::Exception("fillArrayWithPyListInt2 : Unrecognized type ! Should be a tuple or a list !");
902   //
903   checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
904   return ret;
905 }
906
907 static bool fillStringVector(PyObject *pyLi, std::vector<std::string>& vec)
908 {
909   if(PyList_Check(pyLi))
910     {
911       Py_ssize_t sz=PyList_Size(pyLi);
912       vec.resize(sz);
913       for(int i=0;i<sz;i++)
914         {
915           PyObject *o=PyList_GetItem(pyLi,i);
916           if(!convertPyObjectToStrNT(o,vec[i]))
917             return false;
918         }
919       return true;
920     }
921   else if(PyTuple_Check(pyLi))
922     {
923       Py_ssize_t sz=PyTuple_Size(pyLi);
924       vec.resize(sz);
925       for(int i=0;i<sz;i++)
926         {
927           PyObject *o=PyTuple_GetItem(pyLi,i);
928           if(!convertPyObjectToStrNT(o,vec[i]))
929             return false;
930         }
931       return true;
932     }
933   else
934     return false;
935 }
936 static void convertPyToVectorOfVectorOfString(PyObject *pyLi, std::vector< std::vector<std::string> >& arr)
937 {
938   const char msg[]="convertPyToVectorOfVectorOfString : expecting list of list of strings !";
939   if(PyList_Check(pyLi))
940     {
941       Py_ssize_t sz=PyList_Size(pyLi);
942       arr.resize(sz);
943       for(int i=0;i<sz;i++)
944         {
945           PyObject *o=PyList_GetItem(pyLi,i);
946           if(!fillStringVector(o,arr[i]))
947             throw INTERP_KERNEL::Exception(msg);
948         }
949     }
950   else if(PyTuple_Check(pyLi))
951     {
952       Py_ssize_t sz=PyTuple_Size(pyLi);
953       arr.resize(sz);
954       for(int i=0;i<sz;i++)
955         {
956           PyObject *o=PyTuple_GetItem(pyLi,i);
957           if(!fillStringVector(o,arr[i]))
958             throw INTERP_KERNEL::Exception(msg);
959         }
960     }
961   else
962     throw INTERP_KERNEL::Exception(msg);
963 }
964
965 static bool fillIntVector(PyObject *pyLi, std::vector<int>& vec)
966 {
967   if(PyList_Check(pyLi))
968     {
969       Py_ssize_t sz=PyList_Size(pyLi);
970       vec.resize(sz);
971       for(int i=0;i<sz;i++)
972         {
973           PyObject *o=PyList_GetItem(pyLi,i);
974           if(PyInt_Check(o))
975             vec[i]=PyInt_AS_LONG(o);
976           else
977             return false;
978         }
979       return true;
980     }
981   else if(PyTuple_Check(pyLi))
982     {
983       Py_ssize_t sz=PyTuple_Size(pyLi);
984       vec.resize(sz);
985       for(int i=0;i<sz;i++)
986         {
987           PyObject *o=PyTuple_GetItem(pyLi,i);
988           if(PyInt_Check(o))
989             vec[i]=PyInt_AS_LONG(o);
990           else
991             return false;
992         }
993       return true;
994     }
995   else
996     return false;
997 }
998
999 static void convertPyToVectorOfVectorOfInt(PyObject *pyLi, std::vector< std::vector<int> >& arr)
1000 {
1001   const char msg[]="convertPyToVectorOfVectorOfInt : expecting list of list of strings !";
1002   if(PyList_Check(pyLi))
1003     {
1004       Py_ssize_t sz=PyList_Size(pyLi);
1005       arr.resize(sz);
1006       for(int i=0;i<sz;i++)
1007         {
1008           PyObject *o=PyList_GetItem(pyLi,i);
1009           if(!fillIntVector(o,arr[i]))
1010             throw INTERP_KERNEL::Exception(msg);
1011         }
1012     }
1013   else if(PyTuple_Check(pyLi))
1014     {
1015       Py_ssize_t sz=PyTuple_Size(pyLi);
1016       arr.resize(sz);
1017       for(int i=0;i<sz;i++)
1018         {
1019           PyObject *o=PyTuple_GetItem(pyLi,i);
1020           if(!fillIntVector(o,arr[i]))
1021             throw INTERP_KERNEL::Exception(msg);
1022         }
1023     }
1024   else
1025     throw INTERP_KERNEL::Exception(msg);
1026 }
1027
1028 static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< std::pair<std::string, std::vector<std::string> > >& arr)
1029 {
1030   const char msg[]="convertPyToVectorPairStringVecString : expecting list of tuples containing each exactly 2 items : one string and one vector of string !";
1031   if(PyList_Check(pyLi))
1032     {
1033       Py_ssize_t sz=PyList_Size(pyLi);
1034       arr.resize(sz);
1035       for(int i=0;i<sz;i++)
1036         {
1037           PyObject *o=PyList_GetItem(pyLi,i);
1038           if(PyTuple_Check(o))
1039             {
1040               int sz2=PyTuple_Size(o);
1041               if(sz2!=2)
1042                 throw INTERP_KERNEL::Exception(msg);
1043               std::pair<std::string, std::vector<std::string> > item;
1044               PyObject *o_0=PyTuple_GetItem(o,0);
1045               item.first=convertPyObjectToStr(o_0,msg);
1046               PyObject *o_1=PyTuple_GetItem(o,1);
1047               if(!fillStringVector(o_1,item.second))
1048                 throw INTERP_KERNEL::Exception(msg);
1049               arr[i]=item;
1050             }
1051           else
1052             throw INTERP_KERNEL::Exception(msg);
1053         }
1054     }
1055   else if(PyTuple_Check(pyLi))
1056     {
1057       Py_ssize_t sz=PyTuple_Size(pyLi);
1058       arr.resize(sz);
1059       for(int i=0;i<sz;i++)
1060         {
1061           PyObject *o=PyTuple_GetItem(pyLi,i);
1062           if(PyTuple_Check(o))
1063             {
1064               int sz2=PyTuple_Size(o);
1065               if(sz2!=2)
1066                 throw INTERP_KERNEL::Exception(msg);
1067               std::pair<std::string, std::vector<std::string> > item;
1068               PyObject *o_0=PyTuple_GetItem(o,0);
1069               item.first=convertPyObjectToStr(o_0,msg);
1070               PyObject *o_1=PyTuple_GetItem(o,1);
1071               if(!fillStringVector(o_1,item.second))
1072                 throw INTERP_KERNEL::Exception(msg);
1073               arr[i]=item;
1074             }
1075           else
1076             throw INTERP_KERNEL::Exception(msg);
1077         }
1078     }
1079   else
1080     throw INTERP_KERNEL::Exception(msg);
1081 }
1082
1083 template<class T>
1084 PyObject *convertDblArrToPyList(const T *ptr, int size)
1085 {
1086   PyObject *ret(PyList_New(size));
1087   for(int i=0;i<size;i++)
1088     PyList_SetItem(ret,i,PyFloat_FromDouble(ptr[i]));
1089   return ret;
1090 }
1091
1092 static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
1093 {
1094   int size(v.size());
1095   PyObject *ret(PyList_New(size));
1096   for(int i=0;i<size;i++)
1097     PyList_SetItem(ret,i,PyFloat_FromDouble(v[i]));
1098   return ret;
1099 }
1100
1101 template<class T>
1102 PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, int nbOfTuples)
1103 {
1104   PyObject *ret(PyList_New(nbOfTuples));
1105   for(int i=0;i<nbOfTuples;i++)
1106     {
1107       PyObject *t=PyTuple_New(nbOfComp);
1108       for(int j=0;j<nbOfComp;j++)
1109         PyTuple_SetItem(t,j,PyFloat_FromDouble(vals[i*nbOfComp+j]));
1110       PyList_SetItem(ret,i,t);
1111     }
1112   return ret;
1113 }
1114
1115 static PyObject *convertCharArrToPyListOfTuple(const char *vals, int nbOfComp, int nbOfTuples)
1116 {
1117   PyObject *ret=PyList_New(nbOfTuples);
1118   INTERP_KERNEL::AutoPtr<char> tmp=new char[nbOfComp+1]; tmp[nbOfComp]='\0';
1119   for(int i=0;i<nbOfTuples;i++)
1120     {
1121       std::copy(vals+i*nbOfComp,vals+(i+1)*nbOfComp,(char *)tmp);
1122       PyList_SetItem(ret,i,PyString_FromString(tmp));
1123     }
1124   return ret;
1125 }
1126
1127 static double *convertPyToNewDblArr2(PyObject *pyLi, int *size)
1128 {
1129   if(PyList_Check(pyLi))
1130     {
1131       *size=PyList_Size(pyLi);
1132       double *tmp=(double *)malloc((*size)*sizeof(double));
1133       for(int i=0;i<*size;i++)
1134         {
1135           PyObject *o=PyList_GetItem(pyLi,i);
1136           if(PyFloat_Check(o))
1137             {
1138               double val=PyFloat_AS_DOUBLE(o);
1139               tmp[i]=val;
1140             }
1141           else if(PyInt_Check(o))
1142             {
1143               long val0=PyInt_AS_LONG(o);
1144               double val=val0;
1145               tmp[i]=val;
1146             }
1147           else
1148             {
1149               free(tmp);
1150               throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : list must contain floats/integers only");
1151             }
1152         }
1153       return tmp;
1154     }
1155   else if(PyTuple_Check(pyLi))
1156     {
1157       *size=PyTuple_Size(pyLi);
1158       double *tmp=(double *)malloc((*size)*sizeof(double));
1159       for(int i=0;i<*size;i++)
1160         {
1161           PyObject *o=PyTuple_GetItem(pyLi,i);
1162           if(PyFloat_Check(o))
1163             {
1164               double val=PyFloat_AS_DOUBLE(o);
1165               tmp[i]=val;
1166             }
1167           else if(PyInt_Check(o))
1168             {
1169               long val0=PyInt_AS_LONG(o);
1170               double val=val0;
1171               tmp[i]=val;
1172             }
1173           else
1174             {
1175               free(tmp);
1176               throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : tuple must contain floats/integers only");
1177             }
1178         }
1179       return tmp;
1180     }
1181   else
1182     throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : not a list");
1183 }
1184
1185 static void fillArrayWithPyListDbl3(PyObject *pyLi, int& nbOfElt, std::vector<double>& ret)
1186 {
1187   static const char MSG[]="fillArrayWithPyListDbl3 : It appears that the input list or tuple is composed by elts having different sizes !";
1188   if(PyFloat_Check(pyLi))
1189     {
1190       if(nbOfElt==-1)
1191         nbOfElt=1;
1192       else
1193         if(nbOfElt!=1)
1194           throw INTERP_KERNEL::Exception(MSG);
1195       double val=PyFloat_AS_DOUBLE(pyLi);
1196       ret.push_back(val);
1197     }
1198   else if(PyInt_Check(pyLi))
1199     {
1200       long val0=PyInt_AS_LONG(pyLi);
1201       double val=val0;
1202       if(nbOfElt==-1)
1203         nbOfElt=1;
1204       else
1205         if(nbOfElt!=1)
1206           throw INTERP_KERNEL::Exception(MSG);
1207       ret.push_back(val);
1208     }
1209   else if(PyList_Check(pyLi))
1210     {
1211       int size=PyList_Size(pyLi);
1212       int tmp=0;
1213       for(int i=0;i<size;i++)
1214         {
1215           PyObject *o=PyList_GetItem(pyLi,i);
1216           int tmp1=-1;
1217           fillArrayWithPyListDbl3(o,tmp1,ret);
1218           tmp+=tmp1;
1219         }
1220       if(nbOfElt==-1)
1221         nbOfElt=tmp;
1222       else
1223         {
1224           if(nbOfElt!=tmp)
1225             throw INTERP_KERNEL::Exception(MSG);
1226         }
1227     }
1228   else if(PyTuple_Check(pyLi))
1229     {
1230       int size=PyTuple_Size(pyLi);
1231       int tmp=0;
1232       for(int i=0;i<size;i++)
1233         {
1234           PyObject *o=PyTuple_GetItem(pyLi,i);
1235           int tmp1=-1;
1236           fillArrayWithPyListDbl3(o,tmp1,ret);
1237           tmp+=tmp1;
1238         }
1239       if(nbOfElt==-1)
1240         nbOfElt=tmp;
1241       else
1242         {
1243           if(nbOfElt!=tmp)
1244             throw INTERP_KERNEL::Exception(MSG);
1245         }
1246     }
1247   else
1248     throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl3 : Unrecognized type ! Should be a composition of tuple,list,int and float !");
1249 }
1250
1251 static std::vector<double> fillArrayWithPyListDbl2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp)
1252 {
1253   std::vector<double> ret;
1254   int size1=-1,size2=-1;
1255   if(PyList_Check(pyLi))
1256     {
1257       size1=PyList_Size(pyLi);
1258       for(int i=0;i<size1;i++)
1259         {
1260           PyObject *o=PyList_GetItem(pyLi,i);
1261           fillArrayWithPyListDbl3(o,size2,ret);
1262         }
1263       if(size1==0)
1264         size2=1;
1265     }
1266   else if(PyTuple_Check(pyLi))
1267     {
1268       size1=PyTuple_Size(pyLi);
1269       for(int i=0;i<size1;i++)
1270         {
1271           PyObject *o=PyTuple_GetItem(pyLi,i);
1272           fillArrayWithPyListDbl3(o,size2,ret);
1273         }
1274       if(size1==0)
1275         size2=1;
1276     }
1277   else
1278     throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !");
1279   //
1280   checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
1281   return ret;
1282 }
1283
1284 //convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingUMesh *>(pyLi,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh")
1285 template<class T>
1286 static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, const char *typeStr, typename std::vector<T>& ret)
1287 {
1288   void *argp=0;
1289   if(PyList_Check(pyLi))
1290     {
1291       int size=PyList_Size(pyLi);
1292       ret.resize(size);
1293       for(int i=0;i<size;i++)
1294         {
1295           PyObject *obj=PyList_GetItem(pyLi,i);
1296           int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
1297           if(!SWIG_IsOK(status))
1298             {
1299               std::ostringstream oss; oss << "convertFromPyObjVectorOfObj : list is excepted to contain only " << typeStr << " instances !";
1300               throw INTERP_KERNEL::Exception(oss.str().c_str());
1301             }
1302           T arg=reinterpret_cast< T >(argp);
1303           ret[i]=arg;
1304         }
1305     }
1306   else if(PyTuple_Check(pyLi))
1307     {
1308       int size=PyTuple_Size(pyLi);
1309       ret.resize(size);
1310       for(int i=0;i<size;i++)
1311         {
1312           PyObject *obj=PyTuple_GetItem(pyLi,i);
1313           int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
1314           if(!SWIG_IsOK(status))
1315             {
1316               std::ostringstream oss; oss << "convertFromPyObjVectorOfObj : tuple is excepted to contain only " << typeStr << " instances !";
1317               throw INTERP_KERNEL::Exception(oss.str().c_str());
1318             }
1319           T arg=reinterpret_cast< T >(argp);
1320           ret[i]=arg;
1321         }
1322     }
1323   else if(SWIG_IsOK(SWIG_ConvertPtr(pyLi,&argp,ty,0|0)))
1324     {
1325       ret.resize(1);
1326       T arg=reinterpret_cast< T >(argp);
1327       ret[0]=arg;
1328     }
1329   else
1330     throw INTERP_KERNEL::Exception("convertFromPyObjVectorOfObj : not a list nor a tuple");
1331 }
1332
1333 /*!
1334  * if python int -> cpp int sw=1
1335  * if python list[int] -> cpp vector<int> sw=2
1336  * if python tuple[int] -> cpp vector<int> sw=2
1337  * if python DataArrayInt -> cpp DataArrayInt sw=3
1338  * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
1339  *
1340  * switch between (int,vector<int>,DataArrayInt)
1341  */
1342 static void convertIntStarLikePyObjToCpp(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple)
1343 {
1344   sw=-1;
1345   if(PyInt_Check(value))
1346     {
1347       iTyypp=(int)PyInt_AS_LONG(value);
1348       sw=1;
1349       return;
1350     }
1351   if(PyTuple_Check(value))
1352     {
1353       int size=PyTuple_Size(value);
1354       stdvecTyypp.resize(size);
1355       for(int i=0;i<size;i++)
1356         {
1357           PyObject *o=PyTuple_GetItem(value,i);
1358           if(PyInt_Check(o))
1359             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1360           else
1361             {
1362               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1363               throw INTERP_KERNEL::Exception(oss.str().c_str());
1364             }
1365         }
1366       sw=2;
1367       return;
1368     }
1369   if(PyList_Check(value))
1370     {
1371       int size=PyList_Size(value);
1372       stdvecTyypp.resize(size);
1373       for(int i=0;i<size;i++)
1374         {
1375           PyObject *o=PyList_GetItem(value,i);
1376           if(PyInt_Check(o))
1377             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1378           else
1379             {
1380               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1381               throw INTERP_KERNEL::Exception(oss.str().c_str());
1382             }
1383         }
1384       sw=2;
1385       return;
1386     }
1387   void *argp;
1388   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1389   if(SWIG_IsOK(status))
1390     {
1391       daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1392       sw=3;
1393       return;
1394     }
1395   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1396   if(SWIG_IsOK(status))
1397     {
1398       daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1399       sw=4;
1400       return ;
1401     }
1402   throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
1403 }
1404
1405 /*!
1406  * if python int -> cpp int sw=1
1407  * if python list[int] -> cpp vector<int> sw=2
1408  * if python tuple[int] -> cpp vector<int> sw=2
1409  * if python DataArrayInt -> cpp DataArrayInt sw=3
1410  * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
1411  *
1412  * switch between (int,vector<int>,DataArrayInt)
1413  */
1414 static const int *convertIntStarLikePyObjToCppIntStar(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector<int>& stdvecTyypp)
1415 {
1416   sw=-1;
1417   if(PyInt_Check(value))
1418     {
1419       iTyypp=(int)PyInt_AS_LONG(value);
1420       sw=1; sz=1;
1421       return &iTyypp;
1422     }
1423   if(PyTuple_Check(value))
1424     {
1425       int size=PyTuple_Size(value);
1426       stdvecTyypp.resize(size);
1427       for(int i=0;i<size;i++)
1428         {
1429           PyObject *o=PyTuple_GetItem(value,i);
1430           if(PyInt_Check(o))
1431             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1432           else
1433             {
1434               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1435               throw INTERP_KERNEL::Exception(oss.str().c_str());
1436             }
1437         }
1438       sw=2; sz=size;
1439       return &stdvecTyypp[0];
1440     }
1441   if(PyList_Check(value))
1442     {
1443       int size=PyList_Size(value);
1444       stdvecTyypp.resize(size);
1445       for(int i=0;i<size;i++)
1446         {
1447           PyObject *o=PyList_GetItem(value,i);
1448           if(PyInt_Check(o))
1449             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1450           else
1451             {
1452               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1453               throw INTERP_KERNEL::Exception(oss.str().c_str());
1454             }
1455         }
1456       sw=2; sz=size;
1457       return &stdvecTyypp[0];
1458     }
1459   void *argp;
1460   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1461   if(SWIG_IsOK(status))
1462     {
1463       MEDCoupling::DataArrayInt *daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1464       if(daIntTyypp)
1465         {
1466           sw=3; sz=daIntTyypp->getNbOfElems();
1467           return daIntTyypp->begin();
1468         }
1469       else
1470         {
1471           sz=0;
1472           return 0;
1473         }
1474     }
1475   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1476   if(SWIG_IsOK(status))
1477     {
1478       MEDCoupling::DataArrayIntTuple *daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1479       sw=4; sz=daIntTuple->getNumberOfCompo();
1480       return daIntTuple->getConstPointer();
1481     }
1482   throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
1483 }
1484
1485 /*!
1486  * if python double -> cpp double sw=1
1487  * if python int -> cpp double sw=1
1488  * if python list[double] -> cpp vector<double> sw=2
1489  * if python list[int] -> cpp vector<double> sw=2
1490  * if python tuple[double] -> cpp vector<double> sw=2
1491  * if python tuple[int] -> cpp vector<double> sw=2
1492  * if python DataArrayDouble -> cpp DataArrayDouble sw=3
1493  *
1494  * switch between (int,vector<int>,DataArrayInt)
1495  */
1496 template<class T>
1497 void considerPyObjAsATStarLikeObject(PyObject *value, int& sw, T& iTyypp, std::vector<T>& stdvecTyypp, typename MEDCoupling::Traits<T>::ArrayType *& daIntTyypp, swig_type_info *ti)
1498 {
1499   sw=-1;
1500   if(PyFloat_Check(value))
1501     {
1502       iTyypp=(T)PyFloat_AS_DOUBLE(value);
1503       sw=1;
1504       return;
1505     }
1506   if(PyInt_Check(value))
1507     {
1508       iTyypp=(T)PyInt_AS_LONG(value);
1509       sw=1;
1510       return;
1511     }
1512   if(PyTuple_Check(value))
1513     {
1514       int size=PyTuple_Size(value);
1515       stdvecTyypp.resize(size);
1516       for(int i=0;i<size;i++)
1517         {
1518           PyObject *o=PyTuple_GetItem(value,i);
1519           if(PyFloat_Check(o))
1520             stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
1521           else if(PyInt_Check(o))
1522             stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
1523           else
1524             {
1525               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1526               throw INTERP_KERNEL::Exception(oss.str().c_str());
1527             }
1528         }
1529       sw=2;
1530       return;
1531     }
1532   if(PyList_Check(value))
1533     {
1534       int size=PyList_Size(value);
1535       stdvecTyypp.resize(size);
1536       for(int i=0;i<size;i++)
1537         {
1538           PyObject *o=PyList_GetItem(value,i);
1539           if(PyFloat_Check(o))
1540             stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
1541           else if(PyInt_Check(o))
1542             stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
1543           else
1544             {
1545               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1546               throw INTERP_KERNEL::Exception(oss.str().c_str());
1547             }
1548         }
1549       sw=2;
1550       return;
1551     }
1552   void *argp;
1553   int status=SWIG_ConvertPtr(value,&argp,ti,0|0);
1554   if(!SWIG_IsOK(status))
1555     throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
1556   daIntTyypp=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayType * >(argp);
1557   sw=3;
1558 }
1559
1560 /*!
1561  * if python double -> cpp double sw=1
1562  * if python int -> cpp double sw=1
1563  * if python list[double] -> cpp vector<double> sw=2
1564  * if python list[int] -> cpp vector<double> sw=2
1565  * if python tuple[double] -> cpp vector<double> sw=2
1566  * if python tuple[int] -> cpp vector<double> sw=2
1567  * if python DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1568  *
1569  * switch between (int,vector<int>,DataArrayInt)
1570  */
1571 static void convertDoubleStarLikePyObjToCpp(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, MEDCoupling::DataArrayDoubleTuple *& daIntTyypp)
1572 {
1573   sw=-1;
1574   if(PyFloat_Check(value))
1575     {
1576       iTyypp=PyFloat_AS_DOUBLE(value);
1577       sw=1;
1578       return;
1579     }
1580   if(PyInt_Check(value))
1581     {
1582       iTyypp=(double)PyInt_AS_LONG(value);
1583       sw=1;
1584       return;
1585     }
1586   if(PyTuple_Check(value))
1587     {
1588       int size=PyTuple_Size(value);
1589       stdvecTyypp.resize(size);
1590       for(int i=0;i<size;i++)
1591         {
1592           PyObject *o=PyTuple_GetItem(value,i);
1593           if(PyFloat_Check(o))
1594             stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1595           else if(PyInt_Check(o))
1596             stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1597           else
1598             {
1599               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1600               throw INTERP_KERNEL::Exception(oss.str().c_str());
1601             }
1602         }
1603       sw=2;
1604       return;
1605     }
1606   if(PyList_Check(value))
1607     {
1608       int size=PyList_Size(value);
1609       stdvecTyypp.resize(size);
1610       for(int i=0;i<size;i++)
1611         {
1612           PyObject *o=PyList_GetItem(value,i);
1613           if(PyFloat_Check(o))
1614             stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1615           else if(PyInt_Check(o))
1616             stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1617           else
1618             {
1619               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1620               throw INTERP_KERNEL::Exception(oss.str().c_str());
1621             }
1622         }
1623       sw=2;
1624       return;
1625     }
1626   void *argp;
1627   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
1628   if(!SWIG_IsOK(status))
1629     throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDoubleTuple");
1630   daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
1631   sw=3;
1632 }
1633
1634 template<class T>
1635 void convertFPStarLikePyObjToCpp_2(PyObject *value, int& sw, T& val, typename MEDCoupling::Traits<T>::ArrayType *&d, typename MEDCoupling::Traits<T>::ArrayTuple *&e, std::vector<T>& f, swig_type_info *ti_da, swig_type_info *ti_tuple)
1636 {
1637   sw=-1;
1638   if(PyFloat_Check(value))
1639     {
1640       val=PyFloat_AS_DOUBLE(value);
1641       sw=1;
1642       return;
1643     }
1644   if(PyInt_Check(value))
1645     {
1646       val=(T)PyInt_AS_LONG(value);
1647       sw=1;
1648       return;
1649     }
1650   if(PyTuple_Check(value))
1651     {
1652       int size=PyTuple_Size(value);
1653       f.resize(size);
1654       for(int i=0;i<size;i++)
1655         {
1656           PyObject *o=PyTuple_GetItem(value,i);
1657           if(PyFloat_Check(o))
1658             f[i]=PyFloat_AS_DOUBLE(o);
1659           else if(PyInt_Check(o))
1660             f[i]=(T)PyInt_AS_LONG(o);
1661           else
1662             {
1663               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1664               throw INTERP_KERNEL::Exception(oss.str().c_str());
1665             }
1666         }
1667       sw=4;
1668       return;
1669     }
1670   if(PyList_Check(value))
1671     {
1672       int size=PyList_Size(value);
1673       f.resize(size);
1674       for(int i=0;i<size;i++)
1675         {
1676           PyObject *o=PyList_GetItem(value,i);
1677           if(PyFloat_Check(o))
1678             f[i]=PyFloat_AS_DOUBLE(o);
1679           else if(PyInt_Check(o))
1680             f[i]=(T)PyInt_AS_LONG(o);
1681           else
1682             {
1683               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1684               throw INTERP_KERNEL::Exception(oss.str().c_str());
1685             }
1686         }
1687       sw=4;
1688       return;
1689     }
1690   void *argp;
1691   int status=SWIG_ConvertPtr(value,&argp,ti_da,0|0);
1692   if(SWIG_IsOK(status))
1693     {
1694       d=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayType * >(argp);
1695       sw=2;
1696       return ;
1697     }
1698   status=SWIG_ConvertPtr(value,&argp,ti_tuple,0|0);
1699   if(SWIG_IsOK(status))
1700     {
1701       e=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayTuple * >(argp);
1702       sw=3;
1703       return ;
1704     }
1705   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
1706 }
1707
1708 /*!
1709  * if value int -> cpp val sw=1
1710  * if value double -> cpp val sw=1
1711  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1712  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1713  * if value list[int,double] -> cpp std::vector<double> sw=4
1714  * if value tuple[int,double] -> cpp std::vector<double> sw=4
1715  */
1716 static void convertDoubleStarLikePyObjToCpp_2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f)
1717 {
1718   convertFPStarLikePyObjToCpp_2<double>(value,sw,val,d,e,f,SWIGTYPE_p_MEDCoupling__DataArrayDouble,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple);
1719 }
1720
1721 /*!
1722  * if value int -> cpp val sw=1
1723  * if value double -> cpp val sw=1
1724  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1725  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1726  * if value list[int,double] -> cpp std::vector<double> sw=4
1727  * if value tuple[int,double] -> cpp std::vector<double> sw=4
1728  */
1729 static void convertFloatStarLikePyObjToCpp_2(PyObject *value, int& sw, float& val, MEDCoupling::DataArrayFloat *&d, MEDCoupling::DataArrayFloatTuple *&e, std::vector<float>& f)
1730 {
1731   convertFPStarLikePyObjToCpp_2<float>(value,sw,val,d,e,f,SWIGTYPE_p_MEDCoupling__DataArrayFloat,SWIGTYPE_p_MEDCoupling__DataArrayFloatTuple);
1732 }
1733
1734 /*!
1735  * if python int -> cpp int sw=1
1736  * if python list[int] -> cpp vector<int> sw=2
1737  * if python tuple[int] -> cpp vector<int> sw=2
1738  * if python slicp -> cpp pair sw=3 (begin,end,step)
1739  * if python DataArrayInt -> cpp DataArrayInt sw=4 . The returned pointer cannot be the null pointer ! If null an exception is thrown.
1740  *
1741  * switch between (int,vector<int>,DataArrayInt)
1742  */
1743 static void convertIntStarOrSliceLikePyObjToCpp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp)
1744 {
1745   const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple";
1746   sw=-1;
1747   if(PyInt_Check(value))
1748     {
1749       iTyypp=(int)PyInt_AS_LONG(value);
1750       sw=1;
1751       return;
1752     }
1753   if(PyTuple_Check(value))
1754     {
1755       int size=PyTuple_Size(value);
1756       stdvecTyypp.resize(size);
1757       for(int i=0;i<size;i++)
1758         {
1759           PyObject *o=PyTuple_GetItem(value,i);
1760           if(PyInt_Check(o))
1761             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1762           else
1763             {
1764               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1765               throw INTERP_KERNEL::Exception(oss.str().c_str());
1766             }
1767         }
1768       sw=2;
1769       return;
1770     }
1771   if(PyList_Check(value))
1772     {
1773       int size=PyList_Size(value);
1774       stdvecTyypp.resize(size);
1775       for(int i=0;i<size;i++)
1776         {
1777           PyObject *o=PyList_GetItem(value,i);
1778           if(PyInt_Check(o))
1779             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1780           else
1781             {
1782               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1783               throw INTERP_KERNEL::Exception(oss.str().c_str());
1784             }
1785         }
1786       sw=2;
1787       return;
1788     }
1789   if(PySlice_Check(value))
1790     {
1791       Py_ssize_t strt=2,stp=2,step=2;
1792       GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
1793       p.first=strt;
1794       p.second.first=stp;
1795       p.second.second=step;
1796       sw=3;
1797       return ;
1798     }
1799   void *argp;
1800   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1801   if(SWIG_IsOK(status))
1802     {
1803       daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1804       if(!daIntTyypp)
1805         {
1806           std::ostringstream oss; oss << msg << " Instance in null !";
1807           throw INTERP_KERNEL::Exception(oss.str().c_str());
1808         }
1809       sw=4;
1810       return ;
1811     }
1812   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1813   if(SWIG_IsOK(status))
1814     {
1815       MEDCoupling::DataArrayIntTuple *tmp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1816       if(!tmp)
1817         {
1818           std::ostringstream oss; oss << msg << " Instance in null !";
1819           throw INTERP_KERNEL::Exception(oss.str().c_str());
1820         }
1821       stdvecTyypp.resize(tmp->getNumberOfCompo());
1822       std::copy(tmp->getConstPointer(),tmp->getConstPointer()+tmp->getNumberOfCompo(),stdvecTyypp.begin());
1823       sw=2;
1824       return ;
1825     }
1826   throw INTERP_KERNEL::Exception(msg);
1827 }
1828
1829 /*!
1830  * Idem than convertIntStarOrSliceLikePyObjToCpp
1831  */
1832 static void convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp)
1833 {
1834   convertIntStarOrSliceLikePyObjToCpp(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
1835   if(sw==1)
1836     {
1837       iTyypp=InterpreteNegativeInt(iTyypp,nbelem);
1838     }
1839 }
1840
1841 /*!
1842  * if python int -> cpp int sw=1
1843  * if python tuple[int] -> cpp vector<int> sw=2
1844  * if python list[int] -> cpp vector<int> sw=2
1845  * if python slice -> cpp pair sw=3
1846  * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 . WARNING The returned pointer can be the null pointer !
1847  */
1848 static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayIntTuple *& daIntTyypp)
1849 {
1850   sw=-1;
1851   if(PyInt_Check(value))
1852     {
1853       iTyypp=(int)PyInt_AS_LONG(value);
1854       sw=1;
1855       return;
1856     }
1857   if(PyTuple_Check(value))
1858     {
1859       int size=PyTuple_Size(value);
1860       stdvecTyypp.resize(size);
1861       for(int i=0;i<size;i++)
1862         {
1863           PyObject *o=PyTuple_GetItem(value,i);
1864           if(PyInt_Check(o))
1865             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1866           else
1867             {
1868               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1869               throw INTERP_KERNEL::Exception(oss.str().c_str());
1870             }
1871         }
1872       sw=2;
1873       return;
1874     }
1875   if(PyList_Check(value))
1876     {
1877       int size=PyList_Size(value);
1878       stdvecTyypp.resize(size);
1879       for(int i=0;i<size;i++)
1880         {
1881           PyObject *o=PyList_GetItem(value,i);
1882           if(PyInt_Check(o))
1883             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1884           else
1885             {
1886               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1887               throw INTERP_KERNEL::Exception(oss.str().c_str());
1888             }
1889         }
1890       sw=2;
1891       return;
1892     }
1893   if(PySlice_Check(value))
1894     {
1895       Py_ssize_t strt=2,stp=2,step=2;
1896       GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
1897       p.first=strt;
1898       p.second.first=stp;
1899       p.second.second=step;
1900       sw=3;
1901       return ;
1902     }
1903   void *argp;
1904   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1905   if(!SWIG_IsOK(status))
1906     throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayIntTuple");
1907   daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1908   sw=4;
1909 }
1910
1911 /*!
1912  * if python string with size one -> cpp char sw=1
1913  * if python string with size different from one -> cpp string sw=2
1914  * if python tuple[string] or list[string] -> vector<string> sw=3
1915  * if python not null pointer of DataArrayChar -> cpp DataArrayChar sw=4
1916  * switch between (int,string,vector<string>,DataArrayChar)
1917  */
1918 static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, MEDCoupling::DataArrayChar *& dacType)
1919 {
1920   const char *msg="4 types accepted : string, list or tuple of strings having same size, not null DataArrayChar instance.";
1921   sw=-1;
1922   if(PyString_Check(value))
1923     {
1924       const char *pt=PyString_AsString(value);
1925       Py_ssize_t sz=PyString_Size(value);
1926       if(sz==1)
1927         {
1928           cTyp=pt[0];
1929           sw=1;
1930           return;
1931         }
1932       else
1933         {
1934           sType=pt;
1935           sw=2;
1936           return;
1937         }
1938     }
1939 #if PY_VERSION_HEX >= 0x03000000
1940   if(PyUnicode_Check(value))
1941     {
1942       Py_ssize_t sz;
1943       const char *pt = PyUnicode_AsUTF8AndSize(value, &sz);
1944       if(sz==1)
1945         {
1946           cTyp=pt[0];
1947           sw=1;
1948           return;
1949         }
1950       else
1951         {
1952           sType=pt;
1953           sw=2;
1954           return;
1955         }
1956     }
1957 #endif
1958   if(PyTuple_Check(value))
1959     {
1960       int size=PyTuple_Size(value);
1961       vsType.resize(size);
1962       for(int i=0;i<size;i++)
1963         {
1964           PyObject *o=PyTuple_GetItem(value,i);
1965           try
1966             {
1967               vsType[i]=convertPyObjectToStr(o);
1968             }
1969           catch(INTERP_KERNEL::Exception& e)
1970             {
1971               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1972               throw INTERP_KERNEL::Exception(oss.str().c_str());
1973             }
1974         }
1975       sw=3;
1976       return;
1977     }
1978   if(PyList_Check(value))
1979     {
1980       int size=PyList_Size(value);
1981       vsType.resize(size);
1982       for(int i=0;i<size;i++)
1983         {
1984           PyObject *o=PyList_GetItem(value,i);
1985           try
1986             {
1987               vsType[i]=convertPyObjectToStr(o);
1988             }
1989           catch(INTERP_KERNEL::Exception& e)
1990             {
1991               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1992               throw INTERP_KERNEL::Exception(oss.str().c_str());
1993             }
1994         }
1995       sw=3;
1996       return;
1997     }
1998   void *argp;
1999   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayChar,0|0);
2000   if(SWIG_IsOK(status))
2001     {
2002       dacType=reinterpret_cast< MEDCoupling::DataArrayChar * >(argp);
2003       if(!dacType)
2004         {
2005           std::ostringstream oss; oss << msg << " Instance in null !";
2006           throw INTERP_KERNEL::Exception(oss.str().c_str());
2007         }
2008       sw=4;
2009       return ;
2010     }
2011   throw INTERP_KERNEL::Exception(msg);
2012 }
2013
2014 /*!
2015  * if value int -> cpp it sw=1
2016  * if value list[int] -> vt sw=2
2017  * if value tuple[int] -> vt sw=2
2018  * if value slice -> pt sw=3
2019  * if value DataArrayInt -> dt sw=4
2020  * if value tuple [int,int] -> cpp it,ip sw=5
2021  * if value tuple [list[int],int] -> cpp vt,ip sw=6
2022  * if value tuple [tuple[int],int] -> cpp vt,ip sw=6
2023  * if value tuple [slice,int] -> cpp pt,ip sw=7
2024  * if value tuple [DaI,int] -> cpp dt,ip sw=8
2025  * if value tuple [int,list[int]] -> cpp it,vc sw=9
2026  * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10
2027  * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10
2028  * if value tuple [slice,list[int]] -> cpp pt,vc sw=11
2029  * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12
2030  * if value tuple [int,tuple[int]] -> cpp it,vc sw=9
2031  * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10
2032  * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10
2033  * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11
2034  * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12
2035  * if value tuple [int,slice] -> cpp it,pc sw=13
2036  * if value tuple [list[int],slice] -> cpp vt,pc sw=14
2037  * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14
2038  * if value tuple [slice,slice] -> cpp pt,pc sw=15
2039  * if value tuple [DaI,slice] -> cpp dt,pc sw=16
2040  *
2041  * switch between (int,vector<int>,DataArrayInt)
2042  */
2043 static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
2044                                      std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
2045                                      MEDCoupling::DataArrayInt *&dt, MEDCoupling::DataArrayInt *&dc)
2046 {
2047   if(!PyTuple_Check(value))
2048     {
2049       convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(value,nbTuple,sw,it,vt,pt,dt);
2050       return ;
2051     }
2052   else
2053     {
2054       int sz=PyTuple_Size(value);
2055       if(sz!=2)
2056         throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
2057       PyObject *ob0=PyTuple_GetItem(value,0);
2058       int sw1,sw2;
2059       convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob0,nbTuple,sw1,it,vt,pt,dt);
2060       PyObject *ob1=PyTuple_GetItem(value,1);
2061       convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob1,nbCompo,sw2,ic,vc,pc,dc);
2062       sw=4*sw2+sw1;
2063     }
2064 }
2065
2066 /*!
2067  * if value int -> cpp val sw=1
2068  * if value double -> cpp val sw=1
2069  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2070  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2071  * if value list[int,double] -> cpp std::vector<double> sw=4
2072  * if value tuple[int,double] -> cpp std::vector<double> sw=4
2073  */
2074 static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
2075                                                    const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt)
2076 {
2077   sw=-1;
2078   if(PyFloat_Check(value))
2079     {
2080       val=PyFloat_AS_DOUBLE(value);
2081       sw=1;
2082       if(nbTuplesExpected*nbCompExpected!=1)
2083         {
2084           std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
2085           throw INTERP_KERNEL::Exception(oss.str().c_str());
2086         }
2087       return &val;
2088     }
2089   if(PyInt_Check(value))
2090     {
2091       val=(double)PyInt_AS_LONG(value);
2092       sw=1;
2093       if(nbTuplesExpected*nbCompExpected!=1)
2094         {
2095           std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
2096           throw INTERP_KERNEL::Exception(oss.str().c_str());
2097         }
2098       return &val;
2099     }
2100   if(PyTuple_Check(value) || PyList_Check(value))
2101     {
2102       try
2103         {
2104           int tmp1=nbTuplesExpected,tmp2=nbCompExpected;
2105           std::vector<double> ret=fillArrayWithPyListDbl2(value,tmp1,tmp2);
2106           sw=4;
2107           f=ret;
2108           return &f[0];
2109         }
2110       catch(INTERP_KERNEL::Exception& exc) { throw exc; }
2111     }
2112   void *argp;
2113   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2114   if(SWIG_IsOK(status))
2115     {
2116       d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2117       sw=2;
2118       if(d)
2119         {
2120           if(d->getNumberOfTuples()==nbTuplesExpected)
2121             {
2122               if(d->getNumberOfComponents()==nbCompExpected)
2123                 {
2124                   return d->getConstPointer();
2125                 }
2126               else
2127                 {
2128                   std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
2129                   throw INTERP_KERNEL::Exception(oss.str().c_str());
2130                 }
2131             }
2132           else
2133             {
2134               std::ostringstream oss; oss << msg << " input DataArrayDouble should have a number of tuples equal to " << nbTuplesExpected << " and there are " << d->getNumberOfTuples() << " tuples !";
2135               throw INTERP_KERNEL::Exception(oss.str().c_str());
2136             }
2137         }
2138       else
2139         {
2140           if(throwIfNullPt)
2141             {
2142               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2143               throw INTERP_KERNEL::Exception(oss.str().c_str());
2144             }
2145           else
2146             return 0;
2147         }
2148     }
2149   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2150   if(SWIG_IsOK(status))
2151     {
2152       e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2153       sw=3;
2154       if(e->getNumberOfCompo()==nbCompExpected)
2155         {
2156           if(nbTuplesExpected==1)
2157             return e->getConstPointer();
2158           else
2159             {
2160               std::ostringstream oss; oss << msg << "nb of tuples expected to be " << nbTuplesExpected << " , and input DataArrayDoubleTuple has always one tuple by construction !";
2161               throw INTERP_KERNEL::Exception(oss.str().c_str());
2162             }
2163         }
2164       else
2165         {
2166           std::ostringstream oss; oss << msg << "nb of components expected to be " <<  nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
2167           throw INTERP_KERNEL::Exception(oss.str().c_str());
2168         }
2169     }
2170   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2171 }
2172
2173 /*!
2174  * if value int -> cpp val sw=1
2175  * if value double -> cpp val sw=1
2176  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2177  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2178  * if value list[int,double] -> cpp std::vector<double> sw=4
2179  * if value tuple[int,double] -> cpp std::vector<double> sw=4
2180  */
2181 static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
2182                                                     const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples)
2183 {
2184   sw=-1;
2185   if(PyFloat_Check(value))
2186     {
2187       val=PyFloat_AS_DOUBLE(value);
2188       sw=1;
2189       if(nbCompExpected!=1)
2190         {
2191           std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
2192           throw INTERP_KERNEL::Exception(oss.str().c_str());
2193         }
2194       nbTuples=1;
2195       return &val;
2196     }
2197   if(PyInt_Check(value))
2198     {
2199       val=(double)PyInt_AS_LONG(value);
2200       sw=1;
2201       if(nbCompExpected!=1)
2202         {
2203           std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
2204           throw INTERP_KERNEL::Exception(oss.str().c_str());
2205         }
2206       nbTuples=1;
2207       return &val;
2208     }
2209   if(PyTuple_Check(value))
2210     {
2211       int size=PyTuple_Size(value);
2212       f.resize(size);
2213       for(int i=0;i<size;i++)
2214         {
2215           PyObject *o=PyTuple_GetItem(value,i);
2216           if(PyFloat_Check(o))
2217             f[i]=PyFloat_AS_DOUBLE(o);
2218           else if(PyInt_Check(o))
2219             f[i]=(double)PyInt_AS_LONG(o);
2220           else
2221             {
2222               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
2223               throw INTERP_KERNEL::Exception(oss.str().c_str());
2224             }
2225         }
2226       sw=4;
2227       if(size%nbCompExpected!=0)
2228         {
2229           std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
2230           throw INTERP_KERNEL::Exception(oss.str().c_str());
2231         }
2232       nbTuples=size/nbCompExpected;
2233       return &f[0];
2234     }
2235   if(PyList_Check(value))
2236     {
2237       int size=PyList_Size(value);
2238       f.resize(size);
2239       for(int i=0;i<size;i++)
2240         {
2241           PyObject *o=PyList_GetItem(value,i);
2242           if(PyFloat_Check(o))
2243             f[i]=PyFloat_AS_DOUBLE(o);
2244           else if(PyInt_Check(o))
2245             f[i]=(double)PyInt_AS_LONG(o);
2246           else
2247             {
2248               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
2249               throw INTERP_KERNEL::Exception(oss.str().c_str());
2250             }
2251         }
2252       sw=4;
2253       if(size%nbCompExpected!=0)
2254         {
2255           std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
2256           throw INTERP_KERNEL::Exception(oss.str().c_str());
2257         }
2258       nbTuples=size/nbCompExpected;
2259       return &f[0];
2260     }
2261   void *argp;
2262   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2263   if(SWIG_IsOK(status))
2264     {
2265       d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2266       sw=2;
2267       if(d)
2268         {
2269           if(d->getNumberOfComponents()==nbCompExpected)
2270             {
2271               nbTuples=d->getNumberOfTuples();
2272               return d->getConstPointer();
2273             }
2274           else
2275             {
2276               std::ostringstream oss; oss << msg << "nb of components expected to be a multiple of " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
2277               throw INTERP_KERNEL::Exception(oss.str().c_str());
2278             }
2279         }
2280       else
2281         {
2282           if(throwIfNullPt)
2283             {
2284               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2285               throw INTERP_KERNEL::Exception(oss.str().c_str());
2286             }
2287           else
2288             { nbTuples=0; return 0; }
2289         }
2290     }
2291   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2292   if(SWIG_IsOK(status))
2293     {
2294       e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2295       sw=3;
2296       if(e)
2297         {
2298           if(e->getNumberOfCompo()==nbCompExpected)
2299             {
2300               nbTuples=1;
2301               return e->getConstPointer();
2302             }
2303           else
2304             {
2305               std::ostringstream oss; oss << msg << "nb of components expected to be " <<  nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
2306               throw INTERP_KERNEL::Exception(oss.str().c_str());
2307             }
2308         }
2309       else
2310         {
2311           if(throwIfNullPt)
2312             {
2313               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2314               throw INTERP_KERNEL::Exception(oss.str().c_str());
2315             }
2316           else
2317             { nbTuples=0; return 0; }
2318         }
2319     }
2320   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2321 }
2322
2323 /*!
2324  * if value int -> cpp val sw=1
2325  * if value double -> cpp val sw=1
2326  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2327  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2328  * if value list[int,double] -> cpp std::vector<double> sw=4
2329  * if value tuple[int,double] -> cpp std::vector<double> sw=4
2330  */
2331 static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
2332                                                           const char *msg, bool throwIfNullPt, int& nbTuples)
2333 {
2334   MEDCoupling::DataArrayDouble *d=0;
2335   MEDCoupling::DataArrayDoubleTuple *e=0;
2336   sw=-1;
2337   if(PyFloat_Check(value))
2338     {
2339       val=PyFloat_AS_DOUBLE(value);
2340       sw=1;
2341       nbTuples=1;
2342       return &val;
2343     }
2344   if(PyInt_Check(value))
2345     {
2346       val=(double)PyInt_AS_LONG(value);
2347       sw=1;
2348       nbTuples=1;
2349       return &val;
2350     }
2351   if(PyTuple_Check(value))
2352     {
2353       int size=PyTuple_Size(value);
2354       f.resize(size);
2355       for(int i=0;i<size;i++)
2356         {
2357           PyObject *o=PyTuple_GetItem(value,i);
2358           if(PyFloat_Check(o))
2359             f[i]=PyFloat_AS_DOUBLE(o);
2360           else if(PyInt_Check(o))
2361             f[i]=(double)PyInt_AS_LONG(o);
2362           else
2363             {
2364               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
2365               throw INTERP_KERNEL::Exception(oss.str().c_str());
2366             }
2367         }
2368       sw=4;
2369       nbTuples=size;
2370       return &f[0];
2371     }
2372   if(PyList_Check(value))
2373     {
2374       int size=PyList_Size(value);
2375       f.resize(size);
2376       for(int i=0;i<size;i++)
2377         {
2378           PyObject *o=PyList_GetItem(value,i);
2379           if(PyFloat_Check(o))
2380             f[i]=PyFloat_AS_DOUBLE(o);
2381           else if(PyInt_Check(o))
2382             f[i]=(double)PyInt_AS_LONG(o);
2383           else
2384             {
2385               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
2386               throw INTERP_KERNEL::Exception(oss.str().c_str());
2387             }
2388         }
2389       sw=4;
2390       nbTuples=size;
2391       return &f[0];
2392     }
2393   void *argp;
2394   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2395   if(SWIG_IsOK(status))
2396     {
2397       d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2398       sw=2;
2399       if(d)
2400         {
2401           if(d->getNumberOfComponents()==1)
2402             {
2403               nbTuples=d->getNumberOfTuples();
2404               return d->getConstPointer();
2405             }
2406           else
2407             {
2408               std::ostringstream oss; oss << msg << "nb of components expected to be one, and input has " << d->getNumberOfComponents() << " components !";
2409               throw INTERP_KERNEL::Exception(oss.str().c_str());
2410             }
2411         }
2412       else
2413         {
2414           if(throwIfNullPt)
2415             {
2416               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2417               throw INTERP_KERNEL::Exception(oss.str().c_str());
2418             }
2419           else
2420             { nbTuples=0; return 0; }
2421         }
2422     }
2423   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2424   if(SWIG_IsOK(status))
2425     {
2426       e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2427       sw=3;
2428       if(e)
2429         {
2430           nbTuples=e->getNumberOfCompo();
2431           return e->getConstPointer();
2432         }
2433       else
2434         {
2435           if(throwIfNullPt)
2436             {
2437               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2438               throw INTERP_KERNEL::Exception(oss.str().c_str());
2439             }
2440           else
2441             { nbTuples=0; return 0; }
2442         }
2443     }
2444   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2445 }
2446
2447 static MEDCoupling::DataArray *CheckAndRetrieveDataArrayInstance(PyObject *obj, const char *msg)
2448 {
2449   void *aBasePtrVS=0;
2450   int status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArray,0|0);
2451   if(!SWIG_IsOK(status))
2452     {
2453       status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2454       if(!SWIG_IsOK(status))
2455         {
2456           status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
2457           if(!SWIG_IsOK(status))
2458             {
2459               status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,0|0);
2460               if(!SWIG_IsOK(status))
2461                 {
2462                   status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayByte,0|0);
2463                   std::ostringstream oss; oss << msg << " ! Accepted instances are DataArrayDouble, DataArrayInt, DataArrayAsciiChar, DataArrayByte !";
2464                   throw INTERP_KERNEL::Exception(oss.str().c_str());
2465                 }
2466             }
2467         }
2468     }
2469   return reinterpret_cast< MEDCoupling::DataArray * >(aBasePtrVS);
2470 }
2471
2472 static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner)
2473 {
2474   PyObject *ret=0;
2475   if(!pd)
2476     {
2477       Py_XINCREF(Py_None);
2478       return Py_None;
2479     }
2480   if(dynamic_cast<MEDCoupling::DataArrayPartDefinition *>(pd))
2481     ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__DataArrayPartDefinition,owner);
2482   else
2483     ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__SlicePartDefinition,owner);
2484   return ret;
2485 }
2486
2487 template<class T>
2488 static typename MEDCoupling::Traits<T>::ArrayType *DataArrayT_New(PyObject *elt0, PyObject *nbOfTuples, PyObject *elt2)
2489 {
2490   const char *msgBase="MEDCoupling::DataArrayDouble::New : Available API are : \n-DataArrayDouble.New()\n-DataArrayDouble.New([1.,3.,4.])\n-DataArrayDouble.New([1.,3.,4.],3)\n-DataArrayDouble.New([1.,3.,4.,5.],2,2)\n-DataArrayDouble.New([1.,3.,4.,5.,7,8.],3,2)\n-DataArrayDouble.New([(1.,3.),(4.,5.),(7,8.)])\n-DataArrayDouble.New(5)\n-DataArrayDouble.New(5,2)";
2491   std::string msg(msgBase);
2492 #ifdef WITH_NUMPY
2493   msg+="\n-DataArrayDouble.New(numpy array with dtype=float64)";
2494 #endif
2495   msg+=" !";
2496   if(PyList_Check(elt0) || PyTuple_Check(elt0))
2497     {
2498       if(nbOfTuples)
2499         {
2500           if(PyInt_Check(nbOfTuples))
2501             {
2502               int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
2503               if(nbOfTuples1<0)
2504                 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
2505               if(elt2)
2506                 {
2507                   if(PyInt_Check(elt2))
2508                     {//DataArrayDouble.New([1.,3.,4.,5.],2,2)
2509                       int nbOfCompo=PyInt_AS_LONG(elt2);
2510                       if(nbOfCompo<0)
2511                         throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
2512                       MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2513                       std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,nbOfCompo));
2514                       ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2515                       return ret.retn();
2516                     }
2517                   else
2518                     throw INTERP_KERNEL::Exception(msg.c_str());
2519                 }
2520               else
2521                 {//DataArrayDouble.New([1.,3.,4.],3)
2522                   MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2523                   int tmpp1(-1);
2524                   std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,tmpp1));
2525                   ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2526                   return ret.retn();
2527                 }
2528             }
2529           else
2530             throw INTERP_KERNEL::Exception(msg.c_str());
2531         }
2532       else
2533         {// DataArrayDouble.New([1.,3.,4.])
2534           MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2535           int tmpp1(-1),tmpp2(-1);
2536           std::vector<double> tmp=fillArrayWithPyListDbl2(elt0,tmpp1,tmpp2);
2537           ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2538           return ret.retn();
2539         }
2540     }
2541   else if(PyInt_Check(elt0))
2542     {
2543       int nbOfTuples1(PyInt_AS_LONG(elt0));
2544       if(nbOfTuples1<0)
2545         throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
2546       if(nbOfTuples)
2547         {
2548           if(!elt2)
2549             {
2550               if(PyInt_Check(nbOfTuples))
2551                 {//DataArrayDouble.New(5,2)
2552                   int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
2553                   if(nbOfCompo<0)
2554                     throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
2555                   MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2556                   ret->alloc(nbOfTuples1,nbOfCompo);
2557                   return ret.retn();
2558                 }
2559               else
2560                 throw INTERP_KERNEL::Exception(msg.c_str());
2561             }
2562           else
2563             throw INTERP_KERNEL::Exception(msg.c_str());
2564         }
2565       else
2566         {//DataArrayDouble.New(5)
2567           MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2568           ret->alloc(nbOfTuples1,1);
2569           return ret.retn();
2570         }
2571     }
2572 #ifdef WITH_NUMPY
2573   else if(PyArray_Check(elt0) && nbOfTuples==NULL && elt2==NULL)
2574     {//DataArrayDouble.New(numpyArray)
2575       return BuildNewInstance< typename MEDCoupling::Traits<T>::ArrayType , T >(elt0,NPYTraits<T>::NPYObjectType,NPYTraits<T>::NPYFunc,MEDCoupling::Traits<T>::NPYStr);
2576     }
2577 #endif
2578   else
2579     throw INTERP_KERNEL::Exception(msg.c_str());
2580   throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
2581 }
2582
2583 template<class T>
2584 typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__internal(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value, swig_type_info *ti)
2585 {
2586   self->checkAllocated();
2587   const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
2588   int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
2589   int sw1,sw2;
2590   T i1;
2591   std::vector<T> v1;
2592   typename MEDCoupling::Traits<T>::ArrayType *d1=0;
2593   considerPyObjAsATStarLikeObject<T>(value,sw1,i1,v1,d1,ti);
2594   int it1,ic1;
2595   std::vector<int> vt1,vc1;
2596   std::pair<int, std::pair<int,int> > pt1,pc1;
2597   MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
2598   convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
2599   MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > tmp;
2600   switch(sw2)
2601     {
2602     case 1:
2603       {
2604         switch(sw1)
2605           {
2606           case 1:
2607             self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
2608             return self;
2609           case 2:
2610             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2611             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2612             self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
2613             return self;
2614           case 3:
2615             self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
2616             return self;
2617           default:
2618             throw INTERP_KERNEL::Exception(msg);
2619           }
2620         break;
2621       }
2622     case 2:
2623       {
2624         switch(sw1)
2625           {
2626           case 1:
2627             self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
2628             return self;
2629           case 2:
2630             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2631             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2632             self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
2633             return self;
2634           case 3:
2635             self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
2636             return self;
2637           default:
2638             throw INTERP_KERNEL::Exception(msg);
2639           }
2640         break;
2641       }
2642     case 3:
2643       {
2644         switch(sw1)
2645           {
2646           case 1:
2647             self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
2648             return self;
2649           case 2:
2650             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2651             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2652             self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
2653             return self;
2654           case 3:
2655             self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
2656             return self;
2657           default:
2658             throw INTERP_KERNEL::Exception(msg);
2659           }
2660         break;
2661       }
2662     case 4:
2663       {
2664         switch(sw1)
2665           {
2666           case 1:
2667             self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
2668             return self;
2669           case 2:
2670             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2671             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2672             self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
2673             return self;
2674           case 3:
2675             self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
2676             return self;
2677           default:
2678             throw INTERP_KERNEL::Exception(msg);
2679           }
2680         break;
2681       }
2682     case 5:
2683       {
2684         switch(sw1)
2685           {
2686           case 1:
2687             self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
2688             return self;
2689           case 2:
2690             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2691             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2692             self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
2693             return self;
2694           case 3:
2695             self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
2696             return self;
2697           default:
2698             throw INTERP_KERNEL::Exception(msg);
2699           }
2700         break;
2701       }
2702     case 6:
2703       {
2704         switch(sw1)
2705           {
2706           case 1:
2707             self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
2708             return self;
2709           case 2:
2710             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2711             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2712             self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
2713             return self;
2714           case 3:
2715             self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
2716             return self;
2717           default:
2718             throw INTERP_KERNEL::Exception(msg);
2719           }
2720         break;
2721       }
2722     case 7:
2723       {
2724         switch(sw1)
2725           {
2726           case 1:
2727             self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
2728             return self;
2729           case 2:
2730             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2731             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2732             self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
2733             return self;
2734           case 3:
2735             self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
2736             return self;
2737           default:
2738             throw INTERP_KERNEL::Exception(msg);
2739           }
2740         break;
2741       }
2742     case 8:
2743       {
2744         switch(sw1)
2745           {
2746           case 1:
2747             self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
2748             return self;
2749           case 2:
2750             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2751             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2752             self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
2753             return self;
2754           case 3:
2755             self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
2756             return self;
2757           default:
2758             throw INTERP_KERNEL::Exception(msg);
2759           }
2760         break;
2761       }
2762     case 9:
2763       {
2764         switch(sw1)
2765           {
2766           case 1:
2767             self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
2768             return self;
2769           case 2:
2770             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2771             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2772             self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
2773             return self;
2774           case 3:
2775             self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
2776             return self;
2777           default:
2778             throw INTERP_KERNEL::Exception(msg);
2779           }
2780         break;
2781       }
2782     case 10:
2783       {
2784         switch(sw1)
2785           {
2786           case 1:
2787             self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
2788             return self;
2789           case 2:
2790             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2791             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2792             self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
2793             return self;
2794           case 3:
2795             self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
2796             return self;
2797           default:
2798             throw INTERP_KERNEL::Exception(msg);
2799           }
2800         break;
2801       }
2802     case 11:
2803       {
2804         switch(sw1)
2805           {
2806           case 1:
2807             self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
2808             return self;
2809           case 2:
2810             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2811             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2812             self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
2813             return self;
2814           case 3:
2815             self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
2816             return self;
2817           default:
2818             throw INTERP_KERNEL::Exception(msg);
2819           }
2820         break;
2821       }
2822     case 12:
2823       {
2824         switch(sw1)
2825           {
2826           case 1:
2827             self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
2828             return self;
2829           case 2:
2830             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2831             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2832             self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
2833             return self;
2834           case 3:
2835             self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
2836             return self;
2837           default:
2838             throw INTERP_KERNEL::Exception(msg);
2839           }
2840         break;
2841       }
2842     case 13:
2843       {
2844         switch(sw1)
2845           {
2846           case 1:
2847             self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
2848             return self;
2849           case 2:
2850             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2851             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2852             self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
2853             return self;
2854           case 3:
2855             self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
2856             return self;
2857           default:
2858             throw INTERP_KERNEL::Exception(msg);
2859           }
2860         break;
2861       }
2862     case 14:
2863       {
2864         switch(sw1)
2865           {
2866           case 1:
2867             self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
2868             return self;
2869           case 2:
2870             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2871             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2872             self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
2873             return self;
2874           case 3:
2875             self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
2876             return self;
2877           default:
2878             throw INTERP_KERNEL::Exception(msg);
2879           }
2880         break;
2881       }
2882     case 15:
2883       {
2884         switch(sw1)
2885           {
2886           case 1:
2887             self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
2888             return self;
2889           case 2:
2890             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2891             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2892             self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
2893             return self;
2894           case 3:
2895             self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
2896             return self;
2897           default:
2898             throw INTERP_KERNEL::Exception(msg);
2899           }
2900         break;
2901       }
2902     case 16:
2903       {
2904         switch(sw1)
2905           {
2906           case 1:
2907             self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
2908             return self;
2909           case 2:
2910             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2911             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2912             self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
2913             return self;
2914           case 3:
2915             self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
2916             return self;
2917           default:
2918             throw INTERP_KERNEL::Exception(msg);
2919           }
2920         break;
2921       }
2922     default:
2923       throw INTERP_KERNEL::Exception(msg);
2924     }
2925   return self;
2926 }
2927
2928 template<class T>
2929 PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, swig_type_info *ti)
2930 {
2931   const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !";
2932   const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2933   self->checkAllocated();
2934   int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
2935   int it1,ic1;
2936   std::vector<int> vt1,vc1;
2937   std::pair<int, std::pair<int,int> > pt1,pc1;
2938   MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
2939   int sw;
2940   convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
2941   MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType > ret;
2942   switch(sw)
2943     {
2944     case 1:
2945       if(nbOfComponents==1)
2946         return PyFloat_FromDouble((T)self->getIJSafe(it1,0));
2947       return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),ti, SWIG_POINTER_OWN | 0 );
2948     case 2:
2949       return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),ti, SWIG_POINTER_OWN | 0 );
2950     case 3:
2951       return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),ti, SWIG_POINTER_OWN | 0 );
2952     case 4:
2953       return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),ti, SWIG_POINTER_OWN | 0 );
2954     case 5:
2955       return PyFloat_FromDouble((T)self->getIJSafe(it1,ic1));
2956     case 6:
2957       {
2958         ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
2959         std::vector<int> v2(1,ic1);
2960         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
2961       }
2962     case 7:
2963       {
2964         ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
2965         std::vector<int> v2(1,ic1);
2966         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
2967       }
2968     case 8:
2969       {
2970         ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
2971         std::vector<int> v2(1,ic1);
2972         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
2973       }
2974     case 9:
2975       {
2976         ret=self->selectByTupleIdSafe(&it1,&it1+1);
2977         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
2978       }
2979     case 10:
2980       {
2981         ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
2982         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
2983       }
2984     case 11:
2985       {
2986         ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
2987         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
2988       }
2989     case 12:
2990       {
2991         ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
2992         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
2993       }
2994     case 13:
2995       {
2996         ret=self->selectByTupleIdSafe(&it1,&it1+1);
2997         int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
2998         std::vector<int> v2(nbOfComp);
2999         for(int i=0;i<nbOfComp;i++)
3000           v2[i]=pc1.first+i*pc1.second.second;
3001         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3002       }
3003     case 14:
3004       {
3005         ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3006         int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3007         std::vector<int> v2(nbOfComp);
3008         for(int i=0;i<nbOfComp;i++)
3009           v2[i]=pc1.first+i*pc1.second.second;
3010         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3011       }
3012     case 15:
3013       {
3014         ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3015         int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3016         std::vector<int> v2(nbOfComp);
3017         for(int i=0;i<nbOfComp;i++)
3018           v2[i]=pc1.first+i*pc1.second.second;
3019         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3020       }
3021     case 16:
3022       {
3023         ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3024         int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3025         std::vector<int> v2(nbOfComp);
3026         for(int i=0;i<nbOfComp;i++)
3027           v2[i]=pc1.first+i*pc1.second.second;
3028         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3029       }
3030     default:
3031       throw INTERP_KERNEL::Exception(msg);
3032     }
3033 }
3034
3035 template<class T>
3036 PyObject *DataArrayT_imul__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3037 {
3038   const char msg[]="Unexpected situation in __imul__ !";
3039   T val;
3040   typename MEDCoupling::Traits<T>::ArrayType *a;
3041   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3042   std::vector<T> bb;
3043   int sw;
3044   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3045   switch(sw)
3046     {
3047     case 1:
3048       {
3049         self->applyLin(val,0.);
3050         Py_XINCREF(trueSelf);
3051         return trueSelf;
3052       }
3053     case 2:
3054       {
3055         self->multiplyEqual(a);
3056         Py_XINCREF(trueSelf);
3057         return trueSelf;
3058       }
3059     case 3:
3060       {
3061         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3062         self->multiplyEqual(aaa);
3063         Py_XINCREF(trueSelf);
3064         return trueSelf;
3065       }
3066     case 4:
3067       {
3068         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3069         self->multiplyEqual(aaa);
3070         Py_XINCREF(trueSelf);
3071         return trueSelf;
3072       }
3073     default:
3074       throw INTERP_KERNEL::Exception(msg);
3075     }
3076 }
3077
3078 template<class T>
3079 PyObject *DataArrayT_idiv__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3080 {
3081   const char msg[]="Unexpected situation in __idiv__ !";
3082   T val;
3083   typename MEDCoupling::Traits<T>::ArrayType *a;
3084   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3085   std::vector<T> bb;
3086   int sw;
3087   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3088   switch(sw)
3089     {
3090     case 1:
3091       {
3092         if(val==0.)
3093           throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
3094         self->applyLin(1./val,0.);
3095         Py_XINCREF(trueSelf);
3096         return trueSelf;
3097       }
3098     case 2:
3099       {
3100         self->divideEqual(a);
3101         Py_XINCREF(trueSelf);
3102         return trueSelf;
3103       }
3104     case 3:
3105       {
3106         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3107         self->divideEqual(aaa);
3108         Py_XINCREF(trueSelf);
3109         return trueSelf;
3110       }
3111     case 4:
3112       {
3113         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3114         self->divideEqual(aaa);
3115         Py_XINCREF(trueSelf);
3116         return trueSelf;
3117       }
3118     default:
3119       throw INTERP_KERNEL::Exception(msg);
3120     }
3121 }
3122
3123 template<class T>
3124 PyObject *DataArrayT_iadd__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3125 {
3126   const char msg[]="Unexpected situation in __iadd__ !";
3127   T val;
3128   typename MEDCoupling::Traits<T>::ArrayType *a;
3129   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3130   std::vector<T> bb;
3131   int sw;
3132   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3133   switch(sw)
3134     {
3135     case 1:
3136       {
3137         self->applyLin(1.,val);
3138         Py_XINCREF(trueSelf);
3139         return trueSelf;
3140       }
3141     case 2:
3142       {
3143         self->addEqual(a);
3144         Py_XINCREF(trueSelf);
3145         return trueSelf;
3146       }
3147     case 3:
3148       {
3149         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3150         self->addEqual(aaa);
3151         Py_XINCREF(trueSelf);
3152         return trueSelf;
3153       }
3154     case 4:
3155       {
3156         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3157         self->addEqual(aaa);
3158         Py_XINCREF(trueSelf);
3159         return trueSelf;
3160       }
3161     default:
3162       throw INTERP_KERNEL::Exception(msg);
3163     }
3164 }
3165
3166 template<class T>
3167 PyObject *DataArrayT_isub__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3168 {
3169   const char msg[]="Unexpected situation in __isub__ !";
3170   T val;
3171   typename MEDCoupling::Traits<T>::ArrayType *a;
3172   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3173   std::vector<T> bb;
3174   int sw;
3175   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3176   switch(sw)
3177     {
3178     case 1:
3179       {
3180         self->applyLin(1.,-val);
3181         Py_XINCREF(trueSelf);
3182         return trueSelf;
3183       }
3184     case 2:
3185       {
3186         self->substractEqual(a);
3187         Py_XINCREF(trueSelf);
3188         return trueSelf;
3189       }
3190     case 3:
3191       {
3192         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3193         self->substractEqual(aaa);
3194         Py_XINCREF(trueSelf);
3195         return trueSelf;
3196       }
3197     case 4:
3198       {
3199         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3200         self->substractEqual(aaa);
3201         Py_XINCREF(trueSelf);
3202         return trueSelf;
3203       }
3204     default:
3205       throw INTERP_KERNEL::Exception(msg);
3206     }
3207 }
3208
3209 template<class T>
3210 struct SWIGTITraits
3211 { };
3212
3213 template<>
3214 struct SWIGTITraits<double>
3215 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3216
3217 template<>
3218 struct SWIGTITraits<float>
3219 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3220
3221 template<>
3222 struct SWIGTITraits<int>
3223 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3224
3225 swig_type_info *SWIGTITraits<double>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
3226 swig_type_info *SWIGTITraits<float>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3227 swig_type_info *SWIGTITraits<int>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3228 swig_type_info *SWIGTITraits<double>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
3229 swig_type_info *SWIGTITraits<float>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3230 swig_type_info *SWIGTITraits<int>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3231
3232 #ifdef WITH_NUMPY
3233 PyTypeObject *NPYTraits<double>::NPYFunc=&PyCallBackDataArrayDouble_RefType;
3234
3235 PyTypeObject *NPYTraits<float>::NPYFunc=&PyCallBackDataArrayFloat_RefType;
3236 #endif
3237
3238 template<class T>
3239 typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value)
3240 {
3241   return DataArrayT__setitem__internal<T>(self,obj,value,SWIGTITraits<T>::TI);
3242 }
3243
3244 template<class T>
3245 PyObject *DataArrayT__getitem(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj)
3246 {
3247   return DataArrayT__getitem__internal<T>(self,obj,SWIGTITraits<T>::TI);
3248 }
3249
3250 template<class T>
3251 PyObject *DataArrayT_imul(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3252 {
3253   return DataArrayT_imul__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3254 }
3255
3256 template<class T>
3257 PyObject *DataArrayT_idiv(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3258 {
3259   return DataArrayT_idiv__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3260 }
3261
3262 template<class T>
3263 PyObject *DataArrayT_iadd(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3264 {
3265   return DataArrayT_iadd__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3266 }
3267
3268 template<class T>
3269 PyObject *DataArrayT_isub(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3270 {
3271   return DataArrayT_isub__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3272 }
3273
3274 template<class T>
3275 typename MEDCoupling::Traits<T>::ArrayType *DataArrayFPT_rmul(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj)
3276 {
3277   const char msg[]="Unexpected situation in __rmul__ !";
3278   T val;
3279   typename MEDCoupling::Traits<T>::ArrayType *a;
3280   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3281   std::vector<T> bb;
3282   int sw;
3283   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3284   switch(sw)
3285     {
3286     case 1:
3287       {
3288         typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> ret(self->deepCopy());
3289         ret->applyLin(val,0.);
3290         return ret.retn();
3291       }
3292     case 3:
3293       {
3294         typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> aaa(aa->buildDA(1,self->getNumberOfComponents()));
3295         return MEDCoupling::Traits<T>::ArrayType::Multiply(self,aaa);
3296       }
3297     case 4:
3298       {
3299         typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3300         return MEDCoupling::Traits<T>::ArrayType::Multiply(self,aaa);
3301       }
3302     default:
3303       throw INTERP_KERNEL::Exception(msg);
3304     }
3305 }
3306
3307 #endif