Salome HOME
Numpy optionnal dependancies + getNumberOfCells porting
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingDataArrayTypemaps.i
1 // Copyright (C) 2007-2016  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 extention 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 sting 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 python int -> cpp int sw=1
1723  * if python list[int] -> cpp vector<int> sw=2
1724  * if python tuple[int] -> cpp vector<int> sw=2
1725  * if python slicp -> cpp pair sw=3 (begin,end,step)
1726  * if python DataArrayInt -> cpp DataArrayInt sw=4 . The returned pointer cannot be the null pointer ! If null an exception is thrown.
1727  *
1728  * switch between (int,vector<int>,DataArrayInt)
1729  */
1730 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)
1731 {
1732   const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple";
1733   sw=-1;
1734   if(PyInt_Check(value))
1735     {
1736       iTyypp=(int)PyInt_AS_LONG(value);
1737       sw=1;
1738       return;
1739     }
1740   if(PyTuple_Check(value))
1741     {
1742       int size=PyTuple_Size(value);
1743       stdvecTyypp.resize(size);
1744       for(int i=0;i<size;i++)
1745         {
1746           PyObject *o=PyTuple_GetItem(value,i);
1747           if(PyInt_Check(o))
1748             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1749           else
1750             {
1751               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1752               throw INTERP_KERNEL::Exception(oss.str().c_str());
1753             }
1754         }
1755       sw=2;
1756       return;
1757     }
1758   if(PyList_Check(value))
1759     {
1760       int size=PyList_Size(value);
1761       stdvecTyypp.resize(size);
1762       for(int i=0;i<size;i++)
1763         {
1764           PyObject *o=PyList_GetItem(value,i);
1765           if(PyInt_Check(o))
1766             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1767           else
1768             {
1769               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1770               throw INTERP_KERNEL::Exception(oss.str().c_str());
1771             }
1772         }
1773       sw=2;
1774       return;
1775     }
1776   if(PySlice_Check(value))
1777     {
1778       Py_ssize_t strt=2,stp=2,step=2;
1779       GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
1780       p.first=strt;
1781       p.second.first=stp;
1782       p.second.second=step;
1783       sw=3;
1784       return ;
1785     }
1786   void *argp;
1787   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1788   if(SWIG_IsOK(status))
1789     {
1790       daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1791       if(!daIntTyypp)
1792         {
1793           std::ostringstream oss; oss << msg << " Instance in null !";
1794           throw INTERP_KERNEL::Exception(oss.str().c_str());
1795         }
1796       sw=4;
1797       return ;
1798     }
1799   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1800   if(SWIG_IsOK(status))
1801     {
1802       MEDCoupling::DataArrayIntTuple *tmp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1803       if(!tmp)
1804         {
1805           std::ostringstream oss; oss << msg << " Instance in null !";
1806           throw INTERP_KERNEL::Exception(oss.str().c_str());
1807         }
1808       stdvecTyypp.resize(tmp->getNumberOfCompo());
1809       std::copy(tmp->getConstPointer(),tmp->getConstPointer()+tmp->getNumberOfCompo(),stdvecTyypp.begin());
1810       sw=2;
1811       return ;
1812     }
1813   throw INTERP_KERNEL::Exception(msg);
1814 }
1815
1816 /*!
1817  * Idem than convertIntStarOrSliceLikePyObjToCpp
1818  */
1819 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)
1820 {
1821   convertIntStarOrSliceLikePyObjToCpp(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
1822   if(sw==1)
1823     {
1824       iTyypp=InterpreteNegativeInt(iTyypp,nbelem);
1825     }
1826 }
1827
1828 /*!
1829  * if python int -> cpp int sw=1
1830  * if python tuple[int] -> cpp vector<int> sw=2
1831  * if python list[int] -> cpp vector<int> sw=2
1832  * if python slice -> cpp pair sw=3
1833  * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 . WARNING The returned pointer can be the null pointer !
1834  */
1835 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)
1836 {
1837   sw=-1;
1838   if(PyInt_Check(value))
1839     {
1840       iTyypp=(int)PyInt_AS_LONG(value);
1841       sw=1;
1842       return;
1843     }
1844   if(PyTuple_Check(value))
1845     {
1846       int size=PyTuple_Size(value);
1847       stdvecTyypp.resize(size);
1848       for(int i=0;i<size;i++)
1849         {
1850           PyObject *o=PyTuple_GetItem(value,i);
1851           if(PyInt_Check(o))
1852             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1853           else
1854             {
1855               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1856               throw INTERP_KERNEL::Exception(oss.str().c_str());
1857             }
1858         }
1859       sw=2;
1860       return;
1861     }
1862   if(PyList_Check(value))
1863     {
1864       int size=PyList_Size(value);
1865       stdvecTyypp.resize(size);
1866       for(int i=0;i<size;i++)
1867         {
1868           PyObject *o=PyList_GetItem(value,i);
1869           if(PyInt_Check(o))
1870             stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1871           else
1872             {
1873               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1874               throw INTERP_KERNEL::Exception(oss.str().c_str());
1875             }
1876         }
1877       sw=2;
1878       return;
1879     }
1880   if(PySlice_Check(value))
1881     {
1882       Py_ssize_t strt=2,stp=2,step=2;
1883       GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
1884       p.first=strt;
1885       p.second.first=stp;
1886       p.second.second=step;
1887       sw=3;
1888       return ;
1889     }
1890   void *argp;
1891   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1892   if(!SWIG_IsOK(status))
1893     throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayIntTuple");
1894   daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1895   sw=4;
1896 }
1897
1898 /*!
1899  * if python string with size one -> cpp char sw=1
1900  * if python string with size different from one -> cpp string sw=2
1901  * if python tuple[string] or list[string] -> vector<string> sw=3
1902  * if python not null pointer of DataArrayChar -> cpp DataArrayChar sw=4
1903  * switch between (int,string,vector<string>,DataArrayChar)
1904  */
1905 static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, MEDCoupling::DataArrayChar *& dacType)
1906 {
1907   const char *msg="4 types accepted : string, list or tuple of strings having same size, not null DataArrayChar instance.";
1908   sw=-1;
1909   if(PyString_Check(value))
1910     {
1911       const char *pt=PyString_AsString(value);
1912       Py_ssize_t sz=PyString_Size(value);
1913       if(sz==1)
1914         {
1915           cTyp=pt[0];
1916           sw=1;
1917           return;
1918         }
1919       else
1920         {
1921           sType=pt;
1922           sw=2;
1923           return;
1924         }
1925     }
1926 #if PY_VERSION_HEX >= 0x03000000
1927   if(PyUnicode_Check(value))
1928     {
1929       Py_ssize_t sz;
1930       const char *pt = PyUnicode_AsUTF8AndSize(value, &sz);
1931       if(sz==1)
1932         {
1933           cTyp=pt[0];
1934           sw=1;
1935           return;
1936         }
1937       else
1938         {
1939           sType=pt;
1940           sw=2;
1941           return;
1942         }
1943     }
1944 #endif
1945   if(PyTuple_Check(value))
1946     {
1947       int size=PyTuple_Size(value);
1948       vsType.resize(size);
1949       for(int i=0;i<size;i++)
1950         {
1951           PyObject *o=PyTuple_GetItem(value,i);
1952           try
1953             {
1954               vsType[i]=convertPyObjectToStr(o);
1955             }
1956           catch(INTERP_KERNEL::Exception& e)
1957             {
1958               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1959               throw INTERP_KERNEL::Exception(oss.str().c_str());
1960             }
1961         }
1962       sw=3;
1963       return;
1964     }
1965   if(PyList_Check(value))
1966     {
1967       int size=PyList_Size(value);
1968       vsType.resize(size);
1969       for(int i=0;i<size;i++)
1970         {
1971           PyObject *o=PyList_GetItem(value,i);
1972           try
1973             {
1974               vsType[i]=convertPyObjectToStr(o);
1975             }
1976           catch(INTERP_KERNEL::Exception& e)
1977             {
1978               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1979               throw INTERP_KERNEL::Exception(oss.str().c_str());
1980             }
1981         }
1982       sw=3;
1983       return;
1984     }
1985   void *argp;
1986   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayChar,0|0);
1987   if(SWIG_IsOK(status))
1988     {
1989       dacType=reinterpret_cast< MEDCoupling::DataArrayChar * >(argp);
1990       if(!dacType)
1991         {
1992           std::ostringstream oss; oss << msg << " Instance in null !";
1993           throw INTERP_KERNEL::Exception(oss.str().c_str());
1994         }
1995       sw=4;
1996       return ;
1997     }
1998   throw INTERP_KERNEL::Exception(msg);
1999 }
2000
2001 /*!
2002  * if value int -> cpp it sw=1
2003  * if value list[int] -> vt sw=2
2004  * if value tuple[int] -> vt sw=2
2005  * if value slice -> pt sw=3
2006  * if value DataArrayInt -> dt sw=4
2007  * if value tuple [int,int] -> cpp it,ip sw=5
2008  * if value tuple [list[int],int] -> cpp vt,ip sw=6
2009  * if value tuple [tuple[int],int] -> cpp vt,ip sw=6
2010  * if value tuple [slice,int] -> cpp pt,ip sw=7
2011  * if value tuple [DaI,int] -> cpp dt,ip sw=8
2012  * if value tuple [int,list[int]] -> cpp it,vc sw=9
2013  * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10
2014  * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10
2015  * if value tuple [slice,list[int]] -> cpp pt,vc sw=11
2016  * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12
2017  * if value tuple [int,tuple[int]] -> cpp it,vc sw=9
2018  * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10
2019  * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10
2020  * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11
2021  * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12
2022  * if value tuple [int,slice] -> cpp it,pc sw=13
2023  * if value tuple [list[int],slice] -> cpp vt,pc sw=14
2024  * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14
2025  * if value tuple [slice,slice] -> cpp pt,pc sw=15
2026  * if value tuple [DaI,slice] -> cpp dt,pc sw=16
2027  *
2028  * switch between (int,vector<int>,DataArrayInt)
2029  */
2030 static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
2031                                      std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
2032                                      MEDCoupling::DataArrayInt *&dt, MEDCoupling::DataArrayInt *&dc)
2033 {
2034   if(!PyTuple_Check(value))
2035     {
2036       convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(value,nbTuple,sw,it,vt,pt,dt);
2037       return ;
2038     }
2039   else
2040     {
2041       int sz=PyTuple_Size(value);
2042       if(sz!=2)
2043         throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
2044       PyObject *ob0=PyTuple_GetItem(value,0);
2045       int sw1,sw2;
2046       convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob0,nbTuple,sw1,it,vt,pt,dt);
2047       PyObject *ob1=PyTuple_GetItem(value,1);
2048       convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob1,nbCompo,sw2,ic,vc,pc,dc);
2049       sw=4*sw2+sw1;
2050     }
2051 }
2052
2053 /*!
2054  * if value int -> cpp val sw=1
2055  * if value double -> cpp val sw=1
2056  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2057  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2058  * if value list[int,double] -> cpp std::vector<double> sw=4
2059  * if value tuple[int,double] -> cpp std::vector<double> sw=4
2060  */
2061 static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
2062                                                    const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt)
2063 {
2064   sw=-1;
2065   if(PyFloat_Check(value))
2066     {
2067       val=PyFloat_AS_DOUBLE(value);
2068       sw=1;
2069       if(nbTuplesExpected*nbCompExpected!=1)
2070         {
2071           std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyFloat) !"; 
2072           throw INTERP_KERNEL::Exception(oss.str().c_str());
2073         }
2074       return &val;
2075     }
2076   if(PyInt_Check(value))
2077     {
2078       val=(double)PyInt_AS_LONG(value);
2079       sw=1;
2080       if(nbTuplesExpected*nbCompExpected!=1)
2081         {
2082           std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !"; 
2083           throw INTERP_KERNEL::Exception(oss.str().c_str());
2084         }
2085       return &val;
2086     }
2087   if(PyTuple_Check(value) || PyList_Check(value))
2088     {
2089       try
2090         {
2091           int tmp1=nbTuplesExpected,tmp2=nbCompExpected;
2092           std::vector<double> ret=fillArrayWithPyListDbl2(value,tmp1,tmp2);
2093           sw=4;
2094           f=ret;
2095           return &f[0];
2096         }
2097       catch(INTERP_KERNEL::Exception& exc) { throw exc; }
2098     }
2099   void *argp;
2100   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2101   if(SWIG_IsOK(status))
2102     {  
2103       d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2104       sw=2;
2105       if(d)
2106         {
2107           if(d->getNumberOfTuples()==nbTuplesExpected)
2108             {
2109               if(d->getNumberOfComponents()==nbCompExpected)
2110                 {
2111                   return d->getConstPointer();
2112                 }
2113               else
2114                 {
2115                   std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
2116                   throw INTERP_KERNEL::Exception(oss.str().c_str());
2117                 }
2118             }
2119           else
2120             {
2121               std::ostringstream oss; oss << msg << " input DataArrayDouble should have a number of tuples equal to " << nbTuplesExpected << " and there are " << d->getNumberOfTuples() << " tuples !";
2122               throw INTERP_KERNEL::Exception(oss.str().c_str());
2123             }
2124         }
2125       else
2126         {
2127           if(throwIfNullPt)
2128             {
2129               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2130               throw INTERP_KERNEL::Exception(oss.str().c_str());
2131             }
2132           else
2133             return 0;
2134         }
2135     }
2136   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2137   if(SWIG_IsOK(status))
2138     {  
2139       e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2140       sw=3;
2141       if(e->getNumberOfCompo()==nbCompExpected)
2142         {
2143           if(nbTuplesExpected==1)
2144             return e->getConstPointer();
2145           else
2146             {
2147               std::ostringstream oss; oss << msg << "nb of tuples expected to be " << nbTuplesExpected << " , and input DataArrayDoubleTuple has always one tuple by contruction !";
2148               throw INTERP_KERNEL::Exception(oss.str().c_str());
2149             }
2150         }
2151       else
2152         {
2153           std::ostringstream oss; oss << msg << "nb of components expected to be " <<  nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
2154           throw INTERP_KERNEL::Exception(oss.str().c_str());
2155         }
2156     }
2157   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2158 }
2159
2160 /*!
2161  * if value int -> cpp val sw=1
2162  * if value double -> cpp val sw=1
2163  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2164  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2165  * if value list[int,double] -> cpp std::vector<double> sw=4
2166  * if value tuple[int,double] -> cpp std::vector<double> sw=4
2167  */
2168 static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
2169                                                     const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples)
2170 {
2171   sw=-1;
2172   if(PyFloat_Check(value))
2173     {
2174       val=PyFloat_AS_DOUBLE(value);
2175       sw=1;
2176       if(nbCompExpected!=1)
2177         {
2178           std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyFloat) !"; 
2179           throw INTERP_KERNEL::Exception(oss.str().c_str());
2180         }
2181       nbTuples=1;
2182       return &val;
2183     }
2184   if(PyInt_Check(value))
2185     {
2186       val=(double)PyInt_AS_LONG(value);
2187       sw=1;
2188       if(nbCompExpected!=1)
2189         {
2190           std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyInt) !"; 
2191           throw INTERP_KERNEL::Exception(oss.str().c_str());
2192         }
2193       nbTuples=1;
2194       return &val;
2195     }
2196   if(PyTuple_Check(value))
2197     {
2198       int size=PyTuple_Size(value);
2199       f.resize(size);
2200       for(int i=0;i<size;i++)
2201         {
2202           PyObject *o=PyTuple_GetItem(value,i);
2203           if(PyFloat_Check(o))
2204             f[i]=PyFloat_AS_DOUBLE(o);
2205           else if(PyInt_Check(o))
2206             f[i]=(double)PyInt_AS_LONG(o);
2207           else
2208             {
2209               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
2210               throw INTERP_KERNEL::Exception(oss.str().c_str());
2211             }
2212         }
2213       sw=4;
2214       if(size%nbCompExpected!=0)
2215         {
2216           std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !"; 
2217           throw INTERP_KERNEL::Exception(oss.str().c_str());
2218         }
2219       nbTuples=size/nbCompExpected;
2220       return &f[0];
2221     }
2222   if(PyList_Check(value))
2223     {
2224       int size=PyList_Size(value);
2225       f.resize(size);
2226       for(int i=0;i<size;i++)
2227         {
2228           PyObject *o=PyList_GetItem(value,i);
2229           if(PyFloat_Check(o))
2230             f[i]=PyFloat_AS_DOUBLE(o);
2231           else if(PyInt_Check(o))
2232             f[i]=(double)PyInt_AS_LONG(o);
2233           else
2234             {
2235               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
2236               throw INTERP_KERNEL::Exception(oss.str().c_str());
2237             }
2238         }
2239       sw=4;
2240       if(size%nbCompExpected!=0)
2241         {
2242           std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !"; 
2243           throw INTERP_KERNEL::Exception(oss.str().c_str());
2244         }
2245       nbTuples=size/nbCompExpected;
2246       return &f[0];
2247     }
2248   void *argp;
2249   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2250   if(SWIG_IsOK(status))
2251     {  
2252       d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2253       sw=2;
2254       if(d)
2255         {
2256           if(d->getNumberOfComponents()==nbCompExpected)
2257             {
2258               nbTuples=d->getNumberOfTuples();
2259               return d->getConstPointer();
2260             }
2261           else
2262             {
2263               std::ostringstream oss; oss << msg << "nb of components expected to be a multiple of " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
2264               throw INTERP_KERNEL::Exception(oss.str().c_str());
2265             }
2266         }
2267       else
2268         {
2269           if(throwIfNullPt)
2270             {
2271               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2272               throw INTERP_KERNEL::Exception(oss.str().c_str());
2273             }
2274           else
2275             { nbTuples=0; return 0; }
2276         }
2277     }
2278   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2279   if(SWIG_IsOK(status))
2280     {  
2281       e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2282       sw=3;
2283       if(e)
2284         {
2285           if(e->getNumberOfCompo()==nbCompExpected)
2286             {
2287               nbTuples=1;
2288               return e->getConstPointer();
2289             }
2290           else
2291             {
2292               std::ostringstream oss; oss << msg << "nb of components expected to be " <<  nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
2293               throw INTERP_KERNEL::Exception(oss.str().c_str());
2294             }
2295         }
2296       else
2297         {
2298           if(throwIfNullPt)
2299             {
2300               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2301               throw INTERP_KERNEL::Exception(oss.str().c_str());
2302             }
2303           else
2304             { nbTuples=0; return 0; }
2305         }
2306     }
2307   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2308 }
2309
2310 /*!
2311  * if value int -> cpp val sw=1
2312  * if value double -> cpp val sw=1
2313  * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2314  * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2315  * if value list[int,double] -> cpp std::vector<double> sw=4
2316  * if value tuple[int,double] -> cpp std::vector<double> sw=4
2317  */
2318 static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
2319                                                           const char *msg, bool throwIfNullPt, int& nbTuples)
2320 {
2321   MEDCoupling::DataArrayDouble *d=0;
2322   MEDCoupling::DataArrayDoubleTuple *e=0;
2323   sw=-1;
2324   if(PyFloat_Check(value))
2325     {
2326       val=PyFloat_AS_DOUBLE(value);
2327       sw=1;
2328       nbTuples=1;
2329       return &val;
2330     }
2331   if(PyInt_Check(value))
2332     {
2333       val=(double)PyInt_AS_LONG(value);
2334       sw=1;
2335       nbTuples=1;
2336       return &val;
2337     }
2338   if(PyTuple_Check(value))
2339     {
2340       int size=PyTuple_Size(value);
2341       f.resize(size);
2342       for(int i=0;i<size;i++)
2343         {
2344           PyObject *o=PyTuple_GetItem(value,i);
2345           if(PyFloat_Check(o))
2346             f[i]=PyFloat_AS_DOUBLE(o);
2347           else if(PyInt_Check(o))
2348             f[i]=(double)PyInt_AS_LONG(o);
2349           else
2350             {
2351               std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
2352               throw INTERP_KERNEL::Exception(oss.str().c_str());
2353             }
2354         }
2355       sw=4;
2356       nbTuples=size;
2357       return &f[0];
2358     }
2359   if(PyList_Check(value))
2360     {
2361       int size=PyList_Size(value);
2362       f.resize(size);
2363       for(int i=0;i<size;i++)
2364         {
2365           PyObject *o=PyList_GetItem(value,i);
2366           if(PyFloat_Check(o))
2367             f[i]=PyFloat_AS_DOUBLE(o);
2368           else if(PyInt_Check(o))
2369             f[i]=(double)PyInt_AS_LONG(o);
2370           else
2371             {
2372               std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
2373               throw INTERP_KERNEL::Exception(oss.str().c_str());
2374             }
2375         }
2376       sw=4;
2377       nbTuples=size;
2378       return &f[0];
2379     }
2380   void *argp;
2381   int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2382   if(SWIG_IsOK(status))
2383     {  
2384       d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2385       sw=2;
2386       if(d)
2387         {
2388           if(d->getNumberOfComponents()==1)
2389             {
2390               nbTuples=d->getNumberOfTuples();
2391               return d->getConstPointer();
2392             }
2393           else
2394             {
2395               std::ostringstream oss; oss << msg << "nb of components expected to be one, and input has " << d->getNumberOfComponents() << " components !";
2396               throw INTERP_KERNEL::Exception(oss.str().c_str());
2397             }
2398         }
2399       else
2400         {
2401           if(throwIfNullPt)
2402             {
2403               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2404               throw INTERP_KERNEL::Exception(oss.str().c_str());
2405             }
2406           else
2407             { nbTuples=0; return 0; }
2408         }
2409     }
2410   status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2411   if(SWIG_IsOK(status))
2412     {  
2413       e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2414       sw=3;
2415       if(e)
2416         {
2417           nbTuples=e->getNumberOfCompo();
2418           return e->getConstPointer();
2419         }
2420       else
2421         {
2422           if(throwIfNullPt)
2423             {
2424               std::ostringstream oss; oss << msg << " null pointer not accepted!";
2425               throw INTERP_KERNEL::Exception(oss.str().c_str());
2426             }
2427           else
2428             { nbTuples=0; return 0; }
2429         }
2430     }
2431   throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2432 }
2433
2434 static MEDCoupling::DataArray *CheckAndRetrieveDataArrayInstance(PyObject *obj, const char *msg)
2435 {
2436   void *aBasePtrVS=0;
2437   int status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArray,0|0);
2438   if(!SWIG_IsOK(status))
2439     {
2440       status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2441       if(!SWIG_IsOK(status))
2442         {
2443           status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
2444           if(!SWIG_IsOK(status))
2445             {
2446               status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,0|0);
2447               if(!SWIG_IsOK(status))
2448                 {
2449                   status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayByte,0|0);
2450                   std::ostringstream oss; oss << msg << " ! Accepted instances are DataArrayDouble, DataArrayInt, DataArrayAsciiChar, DataArrayByte !";
2451                   throw INTERP_KERNEL::Exception(oss.str().c_str());
2452                 }
2453             }
2454         }
2455     }
2456   return reinterpret_cast< MEDCoupling::DataArray * >(aBasePtrVS);
2457 }
2458
2459 static PyObject *NewMethWrapCallInitOnlyIfEmptyDictInInput(PyObject *cls, PyObject *args, const char *clsName)
2460 {
2461   if(!PyTuple_Check(args))
2462     {
2463       std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
2464       throw INTERP_KERNEL::Exception(oss.str().c_str());
2465     }
2466   PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
2467   PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
2468   PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
2469   //
2470   PyObject *tmp0(PyTuple_New(1));
2471   PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
2472   PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
2473   Py_DECREF(tmp0);
2474   Py_DECREF(selfMeth);
2475   if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==0 )
2476     {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
2477       PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
2478       PyObject *tmp3(PyTuple_New(0));
2479       PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
2480       Py_XDECREF(tmp2);
2481       Py_DECREF(tmp3);
2482       Py_DECREF(initMeth);
2483     }
2484   return instance;
2485 }
2486
2487 template<class T>
2488 static PyObject *NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral(PyObject *cls, PyObject *args, const char *clsName)
2489 {
2490   if(!PyTuple_Check(args))
2491     {
2492       std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
2493       throw INTERP_KERNEL::Exception(oss.str().c_str());
2494     }
2495   PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
2496   PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
2497   PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
2498   //
2499   PyObject *tmp0(PyTuple_New(1));
2500   PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
2501   PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
2502   Py_DECREF(tmp0);
2503   Py_DECREF(selfMeth);
2504   if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
2505     {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
2506       PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
2507       PyObject *zeNumpyRepr(0);
2508       {
2509         PyObject *tmp1(PyInt_FromLong(0));
2510        zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed
2511         Py_DECREF(tmp1);
2512       }
2513       if(!zeNumpyRepr)
2514         {
2515           std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
2516           throw INTERP_KERNEL::Exception(oss.str().c_str());
2517         }
2518       T tt;
2519       {
2520         PyObject *tmp3(0);
2521         try
2522           {
2523             tmp3=tt(zeNumpyRepr);
2524           }
2525         catch(INTERP_KERNEL::Exception& e)
2526           {
2527             std::ostringstream oss; oss << clsName << ".__new__ : Invalid type in input " << " : " << e.what();
2528             throw INTERP_KERNEL::Exception(oss.str());
2529           }
2530         {
2531           PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
2532           Py_XDECREF(tmp2);
2533         }
2534         Py_DECREF(tmp3);
2535       }
2536       Py_DECREF(initMeth);
2537     }
2538   return instance;
2539 }
2540
2541 struct SinglePyObjToBePutInATuple
2542 {
2543   PyObject *operator()(PyObject *zeNumpyRepr)
2544   {
2545     PyObject *tmp3(PyTuple_New(1));
2546     PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr);
2547     return tmp3;
2548   }
2549 };
2550
2551 struct SinglePyObjExpectToBeAListOfSz2
2552 {
2553   PyObject *operator()(PyObject *uniqueElt)
2554   {
2555     if(!PyTuple_Check(uniqueElt) || PyTuple_Size(uniqueElt)!=2)
2556       throw INTERP_KERNEL::Exception("Not a tuple of size 2 !");
2557     Py_XINCREF(uniqueElt);
2558     return uniqueElt;
2559   }
2560 };
2561
2562 static PyObject *NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(PyObject *cls, PyObject *args, const char *clsName)
2563 {
2564   return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral<SinglePyObjToBePutInATuple>(cls,args,clsName);
2565 }
2566
2567 static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner)
2568 {
2569   PyObject *ret=0;
2570   if(!pd)
2571     {
2572       Py_XINCREF(Py_None);
2573       return Py_None;
2574     }
2575   if(dynamic_cast<MEDCoupling::DataArrayPartDefinition *>(pd))
2576     ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__DataArrayPartDefinition,owner);
2577   else
2578     ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__SlicePartDefinition,owner);
2579   return ret;
2580 }
2581
2582 template<class T>
2583 static typename MEDCoupling::Traits<T>::ArrayType *DataArrayT_New(PyObject *elt0, PyObject *nbOfTuples, PyObject *elt2)
2584 {
2585   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)";
2586   std::string msg(msgBase);
2587 #ifdef WITH_NUMPY
2588   msg+="\n-DataArrayDouble.New(numpy array with dtype=float64)";
2589 #endif
2590   msg+=" !";
2591   if(PyList_Check(elt0) || PyTuple_Check(elt0))
2592     {
2593       if(nbOfTuples)
2594         {
2595           if(PyInt_Check(nbOfTuples))
2596             {
2597               int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
2598               if(nbOfTuples1<0)
2599                 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
2600               if(elt2)
2601                 {
2602                   if(PyInt_Check(elt2))
2603                     {//DataArrayDouble.New([1.,3.,4.,5.],2,2)
2604                       int nbOfCompo=PyInt_AS_LONG(elt2);
2605                       if(nbOfCompo<0)
2606                         throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
2607                       MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2608                       std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,nbOfCompo));
2609                       ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2610                       return ret.retn();
2611                     }
2612                   else
2613                     throw INTERP_KERNEL::Exception(msg.c_str());
2614                 }
2615               else
2616                 {//DataArrayDouble.New([1.,3.,4.],3)
2617                   MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2618                   int tmpp1(-1);
2619                   std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,tmpp1));
2620                   ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2621                   return ret.retn();
2622                 }
2623             }
2624           else
2625             throw INTERP_KERNEL::Exception(msg.c_str());
2626         }
2627       else
2628         {// DataArrayDouble.New([1.,3.,4.])
2629           MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2630           int tmpp1(-1),tmpp2(-1);
2631           std::vector<double> tmp=fillArrayWithPyListDbl2(elt0,tmpp1,tmpp2);
2632           ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2633           return ret.retn();
2634         }
2635     }
2636   else if(PyInt_Check(elt0))
2637     {
2638       int nbOfTuples1(PyInt_AS_LONG(elt0));
2639       if(nbOfTuples1<0)
2640         throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
2641       if(nbOfTuples)
2642         {
2643           if(!elt2)
2644             {
2645               if(PyInt_Check(nbOfTuples))
2646                 {//DataArrayDouble.New(5,2)
2647                   int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
2648                   if(nbOfCompo<0)
2649                     throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
2650                   MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2651                   ret->alloc(nbOfTuples1,nbOfCompo);
2652                   return ret.retn();
2653                 }
2654               else
2655                 throw INTERP_KERNEL::Exception(msg.c_str());
2656             }
2657           else
2658             throw INTERP_KERNEL::Exception(msg.c_str());
2659         }
2660       else
2661         {//DataArrayDouble.New(5)
2662           MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2663           ret->alloc(nbOfTuples1,1);
2664           return ret.retn();
2665         }
2666     }
2667 #ifdef WITH_NUMPY
2668   else if(PyArray_Check(elt0) && nbOfTuples==NULL && elt2==NULL)
2669     {//DataArrayDouble.New(numpyArray)
2670       return BuildNewInstance< typename MEDCoupling::Traits<T>::ArrayType , T >(elt0,NPYTraits<T>::NPYObjectType,NPYTraits<T>::NPYFunc,MEDCoupling::Traits<T>::NPYStr);
2671     }
2672 #endif
2673   else
2674     throw INTERP_KERNEL::Exception(msg.c_str());
2675   throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
2676 }
2677
2678 template<class T>
2679 typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__internal(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value, swig_type_info *ti)
2680 {
2681   self->checkAllocated();
2682   const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
2683   int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
2684   int sw1,sw2;
2685   T i1;
2686   std::vector<T> v1;
2687   typename MEDCoupling::Traits<T>::ArrayType *d1=0;
2688   considerPyObjAsATStarLikeObject<T>(value,sw1,i1,v1,d1,ti);
2689   int it1,ic1;
2690   std::vector<int> vt1,vc1;
2691   std::pair<int, std::pair<int,int> > pt1,pc1;
2692   MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
2693   convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
2694   MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > tmp;
2695   switch(sw2)
2696     {
2697     case 1:
2698       {
2699         switch(sw1)
2700           {
2701           case 1:
2702             self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
2703             return self;
2704           case 2:
2705             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2706             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2707             self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
2708             return self;
2709           case 3:
2710             self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
2711             return self;
2712           default:
2713             throw INTERP_KERNEL::Exception(msg);
2714           }
2715         break;
2716       }
2717     case 2:
2718       {
2719         switch(sw1)
2720           {
2721           case 1:
2722             self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
2723             return self;
2724           case 2:
2725             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2726             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2727             self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
2728             return self;
2729           case 3:
2730             self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
2731             return self;
2732           default:
2733             throw INTERP_KERNEL::Exception(msg);
2734           }
2735         break;
2736       }
2737     case 3:
2738       {
2739         switch(sw1)
2740           {
2741           case 1:
2742             self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
2743             return self;
2744           case 2:
2745             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2746             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2747             self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
2748             return self;
2749           case 3:
2750             self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
2751             return self;
2752           default:
2753             throw INTERP_KERNEL::Exception(msg);
2754           }
2755         break;
2756       }
2757     case 4:
2758       {
2759         switch(sw1)
2760           {
2761           case 1:
2762             self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
2763             return self;
2764           case 2:
2765             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2766             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2767             self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
2768             return self;
2769           case 3:
2770             self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
2771             return self;
2772           default:
2773             throw INTERP_KERNEL::Exception(msg);
2774           }
2775         break;
2776       }
2777     case 5:
2778       {
2779         switch(sw1)
2780           {
2781           case 1:
2782             self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
2783             return self;
2784           case 2:
2785             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2786             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2787             self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
2788             return self;
2789           case 3:
2790             self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
2791             return self;
2792           default:
2793             throw INTERP_KERNEL::Exception(msg);
2794           }
2795         break;
2796       }
2797     case 6:
2798       {
2799         switch(sw1)
2800           {
2801           case 1:
2802             self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
2803             return self;
2804           case 2:
2805             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2806             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2807             self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
2808             return self;
2809           case 3:
2810             self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
2811             return self;
2812           default:
2813             throw INTERP_KERNEL::Exception(msg);
2814           }
2815         break;
2816       }
2817     case 7:
2818       {
2819         switch(sw1)
2820           {
2821           case 1:
2822             self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
2823             return self;
2824           case 2:
2825             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2826             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2827             self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
2828             return self;
2829           case 3:
2830             self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
2831             return self;
2832           default:
2833             throw INTERP_KERNEL::Exception(msg);
2834           }
2835         break;
2836       }
2837     case 8:
2838       {
2839         switch(sw1)
2840           {
2841           case 1:
2842             self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
2843             return self;
2844           case 2:
2845             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2846             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2847             self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
2848             return self;
2849           case 3:
2850             self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
2851             return self;
2852           default:
2853             throw INTERP_KERNEL::Exception(msg);
2854           }
2855         break;
2856       }
2857     case 9:
2858       {
2859         switch(sw1)
2860           {
2861           case 1:
2862             self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
2863             return self;
2864           case 2:
2865             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2866             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2867             self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
2868             return self;
2869           case 3:
2870             self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
2871             return self;
2872           default:
2873             throw INTERP_KERNEL::Exception(msg);
2874           }
2875         break;
2876       }
2877     case 10:
2878       {
2879         switch(sw1)
2880           {
2881           case 1:
2882             self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
2883             return self;
2884           case 2:
2885             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2886             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2887             self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
2888             return self;
2889           case 3:
2890             self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
2891             return self;
2892           default:
2893             throw INTERP_KERNEL::Exception(msg);
2894           }
2895         break;
2896       }
2897     case 11:
2898       {
2899         switch(sw1)
2900           {
2901           case 1:
2902             self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
2903             return self;
2904           case 2:
2905             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2906             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2907             self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
2908             return self;
2909           case 3:
2910             self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
2911             return self;
2912           default:
2913             throw INTERP_KERNEL::Exception(msg);
2914           }
2915         break;
2916       }
2917     case 12:
2918       {
2919         switch(sw1)
2920           {
2921           case 1:
2922             self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
2923             return self;
2924           case 2:
2925             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2926             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2927             self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
2928             return self;
2929           case 3:
2930             self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
2931             return self;
2932           default:
2933             throw INTERP_KERNEL::Exception(msg);
2934           }
2935         break;
2936       }
2937     case 13:
2938       {
2939         switch(sw1)
2940           {
2941           case 1:
2942             self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
2943             return self;
2944           case 2:
2945             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2946             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2947             self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
2948             return self;
2949           case 3:
2950             self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
2951             return self;
2952           default:
2953             throw INTERP_KERNEL::Exception(msg);
2954           }
2955         break;
2956       }
2957     case 14:
2958       {
2959         switch(sw1)
2960           {
2961           case 1:
2962             self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
2963             return self;
2964           case 2:
2965             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2966             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2967             self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
2968             return self;
2969           case 3:
2970             self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
2971             return self;
2972           default:
2973             throw INTERP_KERNEL::Exception(msg);
2974           }
2975         break;
2976       }
2977     case 15:
2978       {
2979         switch(sw1)
2980           {
2981           case 1:
2982             self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
2983             return self;
2984           case 2:
2985             tmp=MEDCoupling::Traits<T>::ArrayType::New();
2986             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2987             self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
2988             return self;
2989           case 3:
2990             self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
2991             return self;
2992           default:
2993             throw INTERP_KERNEL::Exception(msg);
2994           }
2995         break;
2996       }
2997     case 16:
2998       {
2999         switch(sw1)
3000           {
3001           case 1:
3002             self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
3003             return self;
3004           case 2:
3005             tmp=MEDCoupling::Traits<T>::ArrayType::New();
3006             tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
3007             self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
3008             return self;
3009           case 3:
3010             self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
3011             return self;
3012           default:
3013             throw INTERP_KERNEL::Exception(msg);
3014           }
3015         break;
3016       }
3017     default:
3018       throw INTERP_KERNEL::Exception(msg);
3019     }
3020   return self;
3021 }
3022
3023 template<class T>
3024 PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, swig_type_info *ti)
3025 {
3026   const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !";
3027   const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
3028   self->checkAllocated();
3029   int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
3030   int it1,ic1;
3031   std::vector<int> vt1,vc1;
3032   std::pair<int, std::pair<int,int> > pt1,pc1;
3033   MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
3034   int sw;
3035   convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
3036   MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType > ret;
3037   switch(sw)
3038     {
3039     case 1:
3040       if(nbOfComponents==1)
3041         return PyFloat_FromDouble((T)self->getIJSafe(it1,0));
3042       return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),ti, SWIG_POINTER_OWN | 0 );
3043     case 2:
3044       return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),ti, SWIG_POINTER_OWN | 0 );
3045     case 3:
3046       return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),ti, SWIG_POINTER_OWN | 0 );
3047     case 4:
3048       return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),ti, SWIG_POINTER_OWN | 0 );
3049     case 5:
3050       return PyFloat_FromDouble((T)self->getIJSafe(it1,ic1));
3051     case 6:
3052       {
3053         ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3054         std::vector<int> v2(1,ic1);
3055         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3056       }
3057     case 7:
3058       {
3059         ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3060         std::vector<int> v2(1,ic1);
3061         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3062       }
3063     case 8:
3064       {
3065         ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3066         std::vector<int> v2(1,ic1);
3067         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3068       }
3069     case 9:
3070       {
3071         ret=self->selectByTupleIdSafe(&it1,&it1+1);
3072         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3073       }
3074     case 10:
3075       {
3076         ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3077         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3078       }
3079     case 11:
3080       {
3081         ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3082         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3083       }
3084     case 12:
3085       {
3086         ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3087         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3088       }
3089     case 13:
3090       {
3091         ret=self->selectByTupleIdSafe(&it1,&it1+1);
3092         int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3093         std::vector<int> v2(nbOfComp);
3094         for(int i=0;i<nbOfComp;i++)
3095           v2[i]=pc1.first+i*pc1.second.second;
3096         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3097       }
3098     case 14:
3099       {
3100         ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3101         int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3102         std::vector<int> v2(nbOfComp);
3103         for(int i=0;i<nbOfComp;i++)
3104           v2[i]=pc1.first+i*pc1.second.second;
3105         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3106       }
3107     case 15:
3108       {
3109         ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3110         int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3111         std::vector<int> v2(nbOfComp);
3112         for(int i=0;i<nbOfComp;i++)
3113           v2[i]=pc1.first+i*pc1.second.second;
3114         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3115       }
3116     case 16:
3117       {
3118         ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3119         int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3120         std::vector<int> v2(nbOfComp);
3121         for(int i=0;i<nbOfComp;i++)
3122           v2[i]=pc1.first+i*pc1.second.second;
3123         return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3124       }
3125     default:
3126       throw INTERP_KERNEL::Exception(msg);
3127     }
3128 }
3129
3130 template<class T>
3131 PyObject *DataArrayT_imul__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3132 {
3133   const char msg[]="Unexpected situation in __imul__ !";
3134   T val;
3135   typename MEDCoupling::Traits<T>::ArrayType *a;
3136   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3137   std::vector<T> bb;
3138   int sw;
3139   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3140   switch(sw)
3141     {
3142     case 1:
3143       {
3144         self->applyLin(val,0.);
3145         Py_XINCREF(trueSelf);
3146         return trueSelf;
3147       }
3148     case 2:
3149       {
3150         self->multiplyEqual(a);
3151         Py_XINCREF(trueSelf);
3152         return trueSelf;
3153       }
3154     case 3:
3155       {
3156         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3157         self->multiplyEqual(aaa);
3158         Py_XINCREF(trueSelf);
3159         return trueSelf;
3160       }
3161     case 4:
3162       {
3163         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());
3164         self->multiplyEqual(aaa);
3165         Py_XINCREF(trueSelf);
3166         return trueSelf;
3167       }
3168     default:
3169       throw INTERP_KERNEL::Exception(msg);
3170     }
3171 }
3172
3173 template<class T>
3174 PyObject *DataArrayT_idiv__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3175 {
3176   const char msg[]="Unexpected situation in __idiv__ !";
3177   T val;
3178   typename MEDCoupling::Traits<T>::ArrayType *a;
3179   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3180   std::vector<T> bb;
3181   int sw;
3182   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3183   switch(sw)
3184     {
3185     case 1:
3186       {
3187         if(val==0.)
3188           throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
3189         self->applyLin(1./val,0.);
3190         Py_XINCREF(trueSelf);
3191         return trueSelf;
3192       }
3193     case 2:
3194       {
3195         self->divideEqual(a);
3196         Py_XINCREF(trueSelf);
3197         return trueSelf;
3198       }
3199     case 3:
3200       {
3201         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3202         self->divideEqual(aaa);
3203         Py_XINCREF(trueSelf);
3204         return trueSelf;
3205       }
3206     case 4:
3207       {
3208         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());
3209         self->divideEqual(aaa);
3210         Py_XINCREF(trueSelf);
3211         return trueSelf;
3212       }
3213     default:
3214       throw INTERP_KERNEL::Exception(msg);
3215     }
3216 }
3217
3218 template<class T>
3219 PyObject *DataArrayT_iadd__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3220 {
3221   const char msg[]="Unexpected situation in __iadd__ !";
3222   T val;
3223   typename MEDCoupling::Traits<T>::ArrayType *a;
3224   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3225   std::vector<T> bb;
3226   int sw;
3227   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3228   switch(sw)
3229     {
3230     case 1:
3231       {
3232         self->applyLin(1.,val);
3233         Py_XINCREF(trueSelf);
3234         return trueSelf;
3235       }
3236     case 2:
3237       {
3238         self->addEqual(a);
3239         Py_XINCREF(trueSelf);
3240         return trueSelf;
3241       }
3242     case 3:
3243       {
3244         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3245         self->addEqual(aaa);
3246         Py_XINCREF(trueSelf);
3247         return trueSelf;
3248       }
3249     case 4:
3250       {
3251         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());
3252         self->addEqual(aaa);
3253         Py_XINCREF(trueSelf);
3254         return trueSelf;
3255       }
3256     default:
3257       throw INTERP_KERNEL::Exception(msg);
3258     }
3259 }
3260   
3261 template<class T>
3262 PyObject *DataArrayT_isub__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3263 {
3264   const char msg[]="Unexpected situation in __isub__ !";
3265   T val;
3266   typename MEDCoupling::Traits<T>::ArrayType *a;
3267   typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3268   std::vector<T> bb;
3269   int sw;
3270   convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3271   switch(sw)
3272     {
3273     case 1:
3274       {
3275         self->applyLin(1.,-val);
3276         Py_XINCREF(trueSelf);
3277         return trueSelf;
3278       }
3279     case 2:
3280       {
3281         self->substractEqual(a);
3282         Py_XINCREF(trueSelf);
3283         return trueSelf;
3284       }
3285     case 3:
3286       {
3287         MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3288         self->substractEqual(aaa);
3289         Py_XINCREF(trueSelf);
3290         return trueSelf;
3291       }
3292     case 4:
3293       {
3294         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());
3295         self->substractEqual(aaa);
3296         Py_XINCREF(trueSelf);
3297         return trueSelf;
3298       }
3299     default:
3300       throw INTERP_KERNEL::Exception(msg);
3301     }
3302 }
3303
3304 template<class T>
3305 struct SWIGTITraits
3306 { };
3307
3308 template<>
3309 struct SWIGTITraits<double>
3310 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3311
3312 template<>
3313 struct SWIGTITraits<float>
3314 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3315
3316 template<>
3317 struct SWIGTITraits<int>
3318 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3319
3320 swig_type_info *SWIGTITraits<double>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
3321 swig_type_info *SWIGTITraits<float>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3322 swig_type_info *SWIGTITraits<int>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3323 swig_type_info *SWIGTITraits<double>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
3324 swig_type_info *SWIGTITraits<float>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3325 swig_type_info *SWIGTITraits<int>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3326
3327 PyTypeObject *NPYTraits<double>::NPYFunc=&PyCallBackDataArrayDouble_RefType;
3328
3329 PyTypeObject *NPYTraits<float>::NPYFunc=&PyCallBackDataArrayFloat_RefType;
3330
3331 template<class T>
3332 typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value)
3333 {
3334   return DataArrayT__setitem__internal<T>(self,obj,value,SWIGTITraits<T>::TI);
3335 }
3336
3337 template<class T>
3338 PyObject *DataArrayT__getitem(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj)
3339 {
3340   return DataArrayT__getitem__internal<T>(self,obj,SWIGTITraits<T>::TI);
3341 }
3342
3343 template<class T>
3344 PyObject *DataArrayT_imul(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3345 {
3346   return DataArrayT_imul__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3347 }
3348
3349 template<class T>
3350 PyObject *DataArrayT_idiv(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3351 {
3352   return DataArrayT_idiv__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3353 }
3354
3355 template<class T>
3356 PyObject *DataArrayT_iadd(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3357 {
3358   return DataArrayT_iadd__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3359 }
3360
3361 template<class T>
3362 PyObject *DataArrayT_isub(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3363 {
3364   return DataArrayT_isub__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3365 }
3366
3367 #endif