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