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