1 // Copyright (C) 2007-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #ifndef __MEDCOUPLINGDATAARRAYTYPEMAPS_I__
22 #define __MEDCOUPLINGDATAARRAYTYPEMAPS_I__
24 #if PY_VERSION_HEX >= 0x03000000
25 #define PyInt_AS_LONG PyLong_AS_LONG
28 #include "InterpKernelAutoPtr.hxx"
29 #include "MEDCouplingDataArrayTraits.hxx"
33 static PyObject *convertArray(MEDCoupling::DataArray *array, int owner)
41 if(dynamic_cast<MEDCoupling::DataArrayDouble *>(array))
42 ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayDouble,owner);
43 if(dynamic_cast<MEDCoupling::DataArrayInt *>(array))
44 ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayInt,owner);
45 if(dynamic_cast<MEDCoupling::DataArrayFloat *>(array))
46 ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayFloat,owner);
48 throw INTERP_KERNEL::Exception("Not recognized type of array on downcast !");
53 * This method is an extention of PySlice_GetIndices but less
54 * open than PySlice_GetIndicesEx that accepts too many situations.
56 void GetIndicesOfSlice(PyObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
58 int ret(PySlice_GetIndices(
59 #if PY_VERSION_HEX >= 0x03000000
62 reinterpret_cast<PySliceObject *>(slice),
64 length,start,stop,step));
67 if(*step>0 && *start==*stop && length==*start)
69 throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
73 * This method allows to retrieve slice info from \a slice.
75 void GetIndicesOfSliceExplicitely(PyObject *slice, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
77 int ret(PySlice_GetIndices(
78 #if PY_VERSION_HEX >= 0x03000000
81 reinterpret_cast<PySliceObject *>(slice),
83 std::numeric_limits<int>::max(),start,stop,step));
86 if(*start!=std::numeric_limits<int>::max() && *stop!=std::numeric_limits<int>::max())
88 std::ostringstream oss;
89 oss << msgInCaseOfFailure << " The input slice contains some unknowns that can't be determined in static method ! The input slice must be explicit here !";
90 throw INTERP_KERNEL::Exception(oss.str().c_str());
92 throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
95 int InterpreteNegativeInt(int val, int nbelem)
99 int newVal(nbelem+val);
102 std::ostringstream oss; oss << "interpreteNegativeInt : request for negative int=" << val << " but number of elems is equal to " << nbelem << " !";
103 throw INTERP_KERNEL::Exception(oss.str().c_str());
112 // this is the second type of specific deallocator, only valid for the constructor of DataArrays taking numpy array
113 // in input when an another DataArray is already client of this.
114 template<class MCData>
115 void numarrdeal2(void *pt, void *obj)
117 typedef struct PyCallBackDataArraySt<MCData> PyCallBackDataArray;
118 void **obj1=(void **)obj;
119 PyCallBackDataArray *cbdaic=reinterpret_cast<PyCallBackDataArray *>(obj1[0]);
120 PyObject *weakRefOnOwner=reinterpret_cast<PyObject *>(obj1[1]);
122 Py_XDECREF(weakRefOnOwner);
127 template<class MCData, class T>
128 MCData *BuildNewInstance(PyObject *elt0, int npyObjectType, PyTypeObject *pytype, const char *msg)
130 int ndim=PyArray_NDIM(elt0);
131 if(ndim!=1 && ndim!=2)
132 throw INTERP_KERNEL::Exception("Input numpy array should have dimension equal to 1 or 2 !");
133 if(PyArray_DESCR(elt0)->type_num != npyObjectType)
135 std::ostringstream oss; oss << "Input numpy array has not the type " << msg << "!";
136 throw INTERP_KERNEL::Exception(oss.str().c_str());
138 npy_intp sz0=PyArray_DIM(elt0,0);
139 npy_intp sz1=ndim==2?PyArray_DIM(elt0,1):1;
141 int itemSize=PyArray_ITEMSIZE(elt0);
142 if(itemSize!=sizeof(T))
144 std::ostringstream oss; oss << "Input numpy array has not itemSize set to " << sizeof(T) << " !";
145 throw INTERP_KERNEL::Exception(oss.str().c_str());
147 if(itemSize*sz1!=PyArray_STRIDE(elt0,0))
148 throw INTERP_KERNEL::Exception("Input numpy array has stride that mismatches the item size ! Data are not packed in the right way for DataArrays !");
150 if(itemSize!=PyArray_STRIDE(elt0,1))
151 throw INTERP_KERNEL::Exception("Input numpy array has stride that mismatches the item size ! Data are not packed in the right way for DataArrays for component #1 !");
152 const char *data=PyArray_BYTES(elt0);
153 typename MEDCoupling::MCAuto<MCData> ret=MCData::New();
154 if(PyArray_ISBEHAVED(elt0))//aligned and writeable and in machine byte-order
156 PyArrayObject *elt0C=reinterpret_cast<PyArrayObject *>(elt0);
157 PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & MED_NUMPY_OWNDATA)?elt0C:NULL;
158 int mask=MED_NUMPY_OWNDATA; mask=~mask;
160 PyObject *deepestObj=elt0;
161 PyObject *base=elt0C->base;
162 if(base) deepestObj=base;
163 bool isSpetialCase(false);
166 if(PyArray_Check(base))
168 PyArrayObject *baseC=reinterpret_cast<PyArrayObject *>(base);
169 eltOwning=(PyArray_FLAGS(baseC) & MED_NUMPY_OWNDATA)?baseC:eltOwning;
172 if(base) deepestObj=base;
181 {// this case is present for numpy arrayint coming from load of pickelized string. The owner of elt0 is not an array -> A copy is requested.
182 std::size_t nbOfElems(sz0*sz1);
183 T *dataCpy=(T*)malloc(sizeof(T)*nbOfElems);
184 std::copy(reinterpret_cast<const T*>(data),reinterpret_cast<const T*>(data)+nbOfElems,dataCpy);
185 ret->useArray(dataCpy,true,MEDCoupling::C_DEALLOC,sz0,sz1);
188 typename MEDCoupling::MemArray<T>& mma=ret->accessToMemArray();
191 PyCallBackDataArraySt<MCData> *cb=PyObject_GC_New(PyCallBackDataArraySt<MCData>,pytype);
193 ret->useArray(reinterpret_cast<const T *>(data),true,MEDCoupling::C_DEALLOC,sz0,sz1);
194 PyObject *ref=PyWeakref_NewRef(deepestObj,(PyObject *)cb);
195 void **objs=new void *[2]; objs[0]=cb; objs[1]=ref;
196 mma.setParameterForDeallocator(objs);
197 mma.setSpecificDeallocator(numarrdeal2<MCData>);
198 //"Impossible to share this numpy array chunk of data, because already shared by an another non numpy array object (maybe an another DataArrayInt instance) ! Release it, or perform a copy on the input array !");
202 ret->useArray(reinterpret_cast<const T *>(data),true,MEDCoupling::C_DEALLOC,sz0,sz1);
203 PyObject *ref=PyWeakref_NewRef(reinterpret_cast<PyObject *>(eltOwning),NULL);
204 typename MEDCoupling::MemArray<T>::Deallocator tmp(MEDCoupling::MemArray<T>::CDeallocator);
205 void **tmp2 = reinterpret_cast<void**>(&tmp); // MSVC2010 does not support constructor()
206 void **objs=new void *[2]; objs[0]=ref; objs[1]=*tmp2;
207 mma.setParameterForDeallocator(objs);
208 mma.setSpecificDeallocator(numarrdeal);
211 else if(PyArray_ISBEHAVED_RO(elt0))
212 ret->useArray(reinterpret_cast<const T *>(data),false,MEDCoupling::CPP_DEALLOC,sz0,sz1);
217 int NumpyArrSetBaseObjectExt(PyArrayObject *arr, PyObject *obj)
220 PyErr_SetString(PyExc_ValueError,
221 "Cannot set the NumPy array 'base' "
222 "dependency to NULL after initialization");
226 * Allow the base to be set only once. Once the object which
227 * owns the data is set, it doesn't make sense to change it.
229 if (PyArray_BASE(arr) != NULL) {
231 PyErr_SetString(PyExc_ValueError,
232 "Cannot set the NumPy array 'base' "
233 "dependency more than once");
238 * Don't allow infinite chains of views, always set the base
239 * to the first owner of the data.
240 * That is, either the first object which isn't an array,
241 * or the first object which owns its own data.
244 while (PyArray_Check(obj) && (PyObject *)arr != obj) {
245 PyArrayObject *obj_arr = (PyArrayObject *)obj;
249 /* If this array owns its own data, stop collapsing */
250 if (PyArray_CHKFLAGS(obj_arr, MED_NUMPY_OWNDATA )) {
254 tmp = PyArray_BASE(obj_arr);
255 /* If there's no base, stop collapsing */
259 /* Stop the collapse new base when the would not be of the same
260 * type (i.e. different subclass).
262 if (Py_TYPE(tmp) != Py_TYPE(arr)) {
272 /* Disallow circular references */
273 if ((PyObject *)arr == obj) {
275 PyErr_SetString(PyExc_ValueError,
276 "Cannot create a circular NumPy array 'base' dependency");
285 template<class MCData, class T>
286 PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, int nbTuples, int nbComp)
288 if(!self->isAllocated())
290 std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : this is not allocated !";
291 throw INTERP_KERNEL::Exception(oss.str().c_str());
293 MEDCoupling::MemArray<T>& mem=self->accessToMemArray();
296 std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : number of components of this is 0 ! Should be > 0 !";
297 throw INTERP_KERNEL::Exception(oss.str().c_str());
299 int nbDims=nbComp==1?1:2;
301 dim[0]=(npy_intp)nbTuples; dim[1]=nbComp;
302 const T *bg=self->getConstPointer();
303 PyObject *ret(PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast<T *>(bg)));
304 if(mem.isDeallocatorCalled())
306 if(mem.getDeallocator()!=numarrdeal)
307 {// case for the first call of toNumPyArray
308 PyObject *ref(PyWeakref_NewRef(ret,NULL));
309 typename MEDCoupling::MemArray<T>::Deallocator tmp(mem.getDeallocator());
310 void **tmp2 = reinterpret_cast<void**>(&tmp); // MSVC2010 does not support constructor()
311 void **objs=new void *[2]; objs[0]=reinterpret_cast<void*>(ref); objs[1]=*tmp2;
312 mem.setParameterForDeallocator(objs);
313 mem.setSpecificDeallocator(numarrdeal);
317 {// case for the second and other call of toNumPyArray
318 void **objs=(void **)mem.getParameterForDeallocator();
319 PyObject *weakRefOnOwner=(PyObject *)objs[0];
320 PyObject *obj=PyWeakref_GetObject(weakRefOnOwner);
322 {//the previous numArray exists let numpy deals the numpy array each other by declaring the still alive instance as base
324 NumpyArrSetBaseObjectExt((PyArrayObject*)ret,obj);
327 {//the previous numArray no more exists -> declare the newly created numpy array as the first one.
328 Py_XDECREF(weakRefOnOwner);
329 PyObject *ref=PyWeakref_NewRef(ret,NULL);
337 template<class MCData, class T>
338 PyObject *ToNumPyArray(MCData *self, int npyObjectType, const char *MCDataStr)
340 return ToNumPyArrayUnderground<MCData,T>(self,npyObjectType,MCDataStr,self->getNumberOfTuples(),self->getNumberOfComponents());
343 SWIGINTERN PyObject *MEDCoupling_DataArrayInt_toNumPyArray(MEDCoupling::DataArrayInt *self);
344 SWIGINTERN PyObject *MEDCoupling_DataArrayDouble_toNumPyArray(MEDCoupling::DataArrayDouble *self);
349 PyObject *ToCSRMatrix(const std::vector<std::map<int,double> >& m, int nbCols)
351 int nbRows((int)m.size());
352 MEDCoupling::MCAuto<MEDCoupling::DataArrayInt> indPtr(MEDCoupling::DataArrayInt::New()),indices(MEDCoupling::DataArrayInt::New());
353 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> data(MEDCoupling::DataArrayDouble::New());
354 indPtr->alloc(nbRows+1,1);
355 int *intPtr_ptr(indPtr->getPointer()); intPtr_ptr[0]=0; intPtr_ptr++;
357 for(std::vector<std::map<int,double> >::const_iterator it0=m.begin();it0!=m.end();it0++,intPtr_ptr++)
359 sz2+=(int)(*it0).size();
362 indices->alloc(sz2,1); data->alloc(sz2,1);
363 int *indices_ptr(indices->getPointer());
364 double *data_ptr(data->getPointer());
365 for(std::vector<std::map<int,double> >::const_iterator it0=m.begin();it0!=m.end();it0++)
366 for(std::map<int,double>::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++,indices_ptr++,data_ptr++)
368 *indices_ptr=(*it1).first;
369 *data_ptr=(*it1).second;
371 PyObject *a(MEDCoupling_DataArrayDouble_toNumPyArray(data)),*b(MEDCoupling_DataArrayInt_toNumPyArray(indices)),*c(MEDCoupling_DataArrayInt_toNumPyArray(indPtr));
373 PyObject *args(PyTuple_New(1)),*args0(PyTuple_New(3)),*kw(PyDict_New()),*kw1(PyTuple_New(2));
374 PyTuple_SetItem(args0,0,a); PyTuple_SetItem(args0,1,b); PyTuple_SetItem(args0,2,c); PyTuple_SetItem(args,0,args0);
375 PyTuple_SetItem(kw1,0,PyInt_FromLong(nbRows)); PyTuple_SetItem(kw1,1,PyInt_FromLong(nbCols));
376 PyObject *tmp1(PyString_FromString("shape"));
377 PyDict_SetItem(kw,tmp1,kw1); Py_DECREF(tmp1); Py_DECREF(kw1);
378 PyObject* pdict=PyDict_New();
379 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
380 PyObject *tmp(PyRun_String("from scipy.sparse import csr_matrix", Py_single_input, pdict, pdict));
382 throw INTERP_KERNEL::Exception("Problem during loading csr_matrix in scipy.sparse ! Is Scipy module available in present ?");
383 PyObject *csrMatrixCls=PyDict_GetItemString(pdict,"csr_matrix");
385 throw INTERP_KERNEL::Exception("csr_matrix not found in scipy.sparse ! Is Scipy module available in present ?");
386 PyObject *ret(PyObject_Call(csrMatrixCls,args,kw));
387 Py_DECREF(pdict); Py_XDECREF(tmp); Py_DECREF(args); Py_DECREF(kw);
393 static PyObject *convertDataArrayChar(MEDCoupling::DataArrayChar *dac, int owner)
401 if(dynamic_cast<MEDCoupling::DataArrayByte *>(dac))
402 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayByte,owner);
403 if(dynamic_cast<MEDCoupling::DataArrayAsciiChar *>(dac))
404 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,owner);
406 throw INTERP_KERNEL::Exception("Not recognized type of DataArrayChar on downcast !");
410 static PyObject *convertDataArray(MEDCoupling::DataArray *dac, int owner)
418 if(dynamic_cast<MEDCoupling::DataArrayDouble *>(dac))
419 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayDouble,owner);
420 if(dynamic_cast<MEDCoupling::DataArrayInt *>(dac))
421 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayInt,owner);
422 if(dynamic_cast<MEDCoupling::DataArrayFloat *>(dac))
423 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayFloat,owner);
424 if(dynamic_cast<MEDCoupling::DataArrayByte *>(dac))
425 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayByte,owner);
426 if(dynamic_cast<MEDCoupling::DataArrayAsciiChar *>(dac))
427 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,owner);
429 throw INTERP_KERNEL::Exception("Not recognized type of DataArray on downcast !");
433 static PyObject *convertIntArrToPyList(const int *ptr, int size)
435 PyObject *ret=PyList_New(size);
436 for(int i=0;i<size;i++)
437 PyList_SetItem(ret,i,PyInt_FromLong(ptr[i]));
441 static PyObject *convertIntArrToPyList2(const std::vector<int>& v)
444 PyObject *ret=PyList_New(size);
445 for(int i=0;i<size;i++)
446 PyList_SetItem(ret,i,PyInt_FromLong(v[i]));
450 static PyObject *convertIntArrToPyList3(const std::set<int>& v)
453 PyObject *ret=PyList_New(size);
454 std::set<int>::const_iterator it=v.begin();
455 for(int i=0;i<size;i++,it++)
456 PyList_SetItem(ret,i,PyInt_FromLong(*it));
460 static bool convertPyObjectToStrNT(PyObject *obj, std::string& ret)
462 if(PyString_Check(obj))
464 ret=PyString_AsString(obj);
467 #if PY_VERSION_HEX >= 0x03000000
468 else if(PyUnicode_Check(obj))
470 ret=PyUnicode_AsUTF8(obj);
477 static std::string convertPyObjectToStr(PyObject *obj, const char *msg=NULL)
480 if(PyString_Check(obj))
481 ret=PyString_AsString(obj);
482 #if PY_VERSION_HEX >= 0x03000000
483 else if(PyUnicode_Check(obj))
484 ret=PyUnicode_AsUTF8(obj);
488 std::ostringstream oss;
492 oss << "PyWrap convertPyObjectToStr : expect a string like py object !";
493 throw INTERP_KERNEL::Exception(oss.str());
498 static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples)
500 PyObject *ret=PyList_New(nbOfTuples);
501 for(int i=0;i<nbOfTuples;i++)
503 PyObject *t=PyTuple_New(nbOfComp);
504 for(int j=0;j<nbOfComp;j++)
505 PyTuple_SetItem(t,j,PyInt_FromLong(vals[i*nbOfComp+j]));
506 PyList_SetItem(ret,i,t);
511 static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
513 if(PyList_Check(pyLi))
515 *size=PyList_Size(pyLi);
516 int *tmp=new int[*size];
517 for(int i=0;i<*size;i++)
519 PyObject *o=PyList_GetItem(pyLi,i);
522 int val=(int)PyInt_AS_LONG(o);
528 throw INTERP_KERNEL::Exception("list must contain integers only");
533 else if(PyTuple_Check(pyLi))
535 *size=PyTuple_Size(pyLi);
536 int *tmp=new int[*size];
537 for(int i=0;i<*size;i++)
539 PyObject *o=PyTuple_GetItem(pyLi,i);
542 int val=(int)PyInt_AS_LONG(o);
548 throw INTERP_KERNEL::Exception("tuple must contain integers only");
555 throw INTERP_KERNEL::Exception("convertPyToNewIntArr2 : not a list");
559 static PyObject *convertFromVectorPairInt(const std::vector< std::pair<int,int> >& arr)
561 PyObject *ret=PyList_New(arr.size());
562 for(std::size_t i=0;i<arr.size();i++)
564 PyObject *t=PyTuple_New(2);
565 PyTuple_SetItem(t,0,PyInt_FromLong(arr[i].first));
566 PyTuple_SetItem(t,1,PyInt_FromLong(arr[i].second));
567 PyList_SetItem(ret,i,t);
572 static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair<int,int> >& arr)
574 const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !";
575 if(PyList_Check(pyLi))
577 int size=PyList_Size(pyLi);
579 for(int i=0;i<size;i++)
581 PyObject *o=PyList_GetItem(pyLi,i);
584 int sz2=PyTuple_Size(o);
586 throw INTERP_KERNEL::Exception(msg);
587 PyObject *o_0=PyTuple_GetItem(o,0);
588 if(!PyInt_Check(o_0))
589 throw INTERP_KERNEL::Exception(msg);
590 PyObject *o_1=PyTuple_GetItem(o,1);
591 if(!PyInt_Check(o_1))
592 throw INTERP_KERNEL::Exception(msg);
593 arr[i].first=(int)PyInt_AS_LONG(o_0);
594 arr[i].second=(int)PyInt_AS_LONG(o_1);
597 throw INTERP_KERNEL::Exception(msg);
600 else if(PyTuple_Check(pyLi))
602 int size=PyTuple_Size(pyLi);
604 for(int i=0;i<size;i++)
606 PyObject *o=PyTuple_GetItem(pyLi,i);
609 int sz2=PyTuple_Size(o);
611 throw INTERP_KERNEL::Exception(msg);
612 PyObject *o_0=PyTuple_GetItem(o,0);
613 if(!PyInt_Check(o_0))
614 throw INTERP_KERNEL::Exception(msg);
615 PyObject *o_1=PyTuple_GetItem(o,1);
616 if(!PyInt_Check(o_1))
617 throw INTERP_KERNEL::Exception(msg);
618 arr[i].first=(int)PyInt_AS_LONG(o_0);
619 arr[i].second=(int)PyInt_AS_LONG(o_1);
622 throw INTERP_KERNEL::Exception(msg);
626 throw INTERP_KERNEL::Exception(msg);
629 static void convertPyToVectorPairStringInt(PyObject *pyLi, std::vector< std::pair<std::string,int> >& arr)
631 const char msg[]="convertPyToVectorPairStringInt : list must contain tuples of 2 integers only or tuple must contain tuples of 1 string and 1 integer only !";
632 if(PyList_Check(pyLi))
634 int size=PyList_Size(pyLi);
636 for(int i=0;i<size;i++)
638 PyObject *o=PyList_GetItem(pyLi,i);
641 int sz2=PyTuple_Size(o);
643 throw INTERP_KERNEL::Exception(msg);
644 PyObject *o_0=PyTuple_GetItem(o,0);
645 PyObject *o_1=PyTuple_GetItem(o,1);
646 arr[i].first=convertPyObjectToStr(o_0,msg);
647 if(!PyInt_Check(o_1))
648 throw INTERP_KERNEL::Exception(msg);
649 arr[i].second=(int)PyInt_AS_LONG(o_1);
652 throw INTERP_KERNEL::Exception(msg);
655 else if(PyTuple_Check(pyLi))
657 int size=PyTuple_Size(pyLi);
659 for(int i=0;i<size;i++)
661 PyObject *o=PyTuple_GetItem(pyLi,i);
664 int sz2=PyTuple_Size(o);
666 throw INTERP_KERNEL::Exception(msg);
667 PyObject *o_0=PyTuple_GetItem(o,0);
668 PyObject *o_1=PyTuple_GetItem(o,1);
669 arr[i].first=convertPyObjectToStr(o_0,msg);
670 if(!PyInt_Check(o_1))
671 throw INTERP_KERNEL::Exception(msg);
672 arr[i].second=(int)PyInt_AS_LONG(o_1);
675 throw INTERP_KERNEL::Exception(msg);
679 throw INTERP_KERNEL::Exception(msg);
682 static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
684 if(PyList_Check(pyLi))
686 int size=PyList_Size(pyLi);
688 for(int i=0;i<size;i++)
690 PyObject *o=PyList_GetItem(pyLi,i);
693 int val=(int)PyInt_AS_LONG(o);
697 throw INTERP_KERNEL::Exception("list must contain integers only");
700 else if(PyTuple_Check(pyLi))
702 int size=PyTuple_Size(pyLi);
704 for(int i=0;i<size;i++)
706 PyObject *o=PyTuple_GetItem(pyLi,i);
709 int val=(int)PyInt_AS_LONG(o);
713 throw INTERP_KERNEL::Exception("tuple must contain integers only");
718 throw INTERP_KERNEL::Exception("convertPyToNewIntArr3 : not a list nor a tuple");
722 static void convertPyToNewIntArr4(PyObject *pyLi, int recurseLev, int nbOfSubPart, std::vector<int>& arr)
725 throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : invalid list of integers level of recursion !");
727 if(PyList_Check(pyLi))
729 int size=PyList_Size(pyLi);
730 for(int i=0;i<size;i++)
732 PyObject *o=PyList_GetItem(pyLi,i);
735 int val=(int)PyInt_AS_LONG(o);
740 std::vector<int> arr2;
741 convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
742 if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
744 std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " << recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
745 throw INTERP_KERNEL::Exception(oss.str().c_str());
747 arr.insert(arr.end(),arr2.begin(),arr2.end());
751 else if(PyTuple_Check(pyLi))
753 int size=PyTuple_Size(pyLi);
754 for(int i=0;i<size;i++)
756 PyObject *o=PyTuple_GetItem(pyLi,i);
759 int val=(int)PyInt_AS_LONG(o);
764 std::vector<int> arr2;
765 convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
766 if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
768 std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " << recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
769 throw INTERP_KERNEL::Exception(oss.str().c_str());
771 arr.insert(arr.end(),arr2.begin(),arr2.end());
776 throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : not a list nor a tuple recursively !");
779 static void checkFillArrayWithPyList(int size1, int size2, int& nbOfTuples, int& nbOfComp)
783 if(nbOfComp==-1) { nbOfTuples=size1; nbOfComp=size2; }
784 else { if(nbOfComp==size2) { nbOfTuples=size1; } else
786 std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
787 oss << " whereas nb of components expected is " << nbOfComp << " !";
788 throw INTERP_KERNEL::Exception(oss.str().c_str());
795 if((nbOfTuples!=size1 || nbOfComp!=size2))
797 if(size2!=1 || size1!=nbOfComp*nbOfTuples)
799 std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
800 oss << " whereas nb of tuples expected is " << nbOfTuples << " and number of components expected is " << nbOfComp << " !";
801 throw INTERP_KERNEL::Exception(oss.str().c_str());
807 if(nbOfTuples==size1)
811 std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
812 oss << " whereas nb of tuples expected is " << nbOfTuples << " !";
813 throw INTERP_KERNEL::Exception(oss.str().c_str());
819 static void fillArrayWithPyListInt3(PyObject *pyLi, int& nbOfElt, std::vector<int>& ret)
821 static const char MSG[]="fillArrayWithPyListInt3 : It appears that the input list or tuple is composed by elts having different sizes !";
822 if(PyInt_Check(pyLi))
824 long val=PyInt_AS_LONG(pyLi);
829 throw INTERP_KERNEL::Exception(MSG);
832 else if(PyList_Check(pyLi))
834 int size=PyList_Size(pyLi);
836 for(int i=0;i<size;i++)
838 PyObject *o=PyList_GetItem(pyLi,i);
840 fillArrayWithPyListInt3(o,tmp1,ret);
848 throw INTERP_KERNEL::Exception(MSG);
851 else if(PyTuple_Check(pyLi))
853 int size=PyTuple_Size(pyLi);
855 for(int i=0;i<size;i++)
857 PyObject *o=PyTuple_GetItem(pyLi,i);
859 fillArrayWithPyListInt3(o,tmp1,ret);
867 throw INTERP_KERNEL::Exception(MSG);
871 throw INTERP_KERNEL::Exception("fillArrayWithPyListInt3 : Unrecognized type ! Should be a composition of tuple,list,int !");
874 static std::vector<int> fillArrayWithPyListInt2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp)
876 std::vector<int> ret;
877 int size1=-1,size2=-1;
878 if(PyList_Check(pyLi))
880 size1=PyList_Size(pyLi);
881 for(int i=0;i<size1;i++)
883 PyObject *o=PyList_GetItem(pyLi,i);
884 fillArrayWithPyListInt3(o,size2,ret);
889 else if(PyTuple_Check(pyLi))
891 size1=PyTuple_Size(pyLi);
892 for(int i=0;i<size1;i++)
894 PyObject *o=PyTuple_GetItem(pyLi,i);
895 fillArrayWithPyListInt3(o,size2,ret);
901 throw INTERP_KERNEL::Exception("fillArrayWithPyListInt2 : Unrecognized type ! Should be a tuple or a list !");
903 checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
907 static bool fillStringVector(PyObject *pyLi, std::vector<std::string>& vec)
909 if(PyList_Check(pyLi))
911 Py_ssize_t sz=PyList_Size(pyLi);
913 for(int i=0;i<sz;i++)
915 PyObject *o=PyList_GetItem(pyLi,i);
916 if(!convertPyObjectToStrNT(o,vec[i]))
921 else if(PyTuple_Check(pyLi))
923 Py_ssize_t sz=PyTuple_Size(pyLi);
925 for(int i=0;i<sz;i++)
927 PyObject *o=PyTuple_GetItem(pyLi,i);
928 if(!convertPyObjectToStrNT(o,vec[i]))
936 static void convertPyToVectorOfVectorOfString(PyObject *pyLi, std::vector< std::vector<std::string> >& arr)
938 const char msg[]="convertPyToVectorOfVectorOfString : expecting list of list of strings !";
939 if(PyList_Check(pyLi))
941 Py_ssize_t sz=PyList_Size(pyLi);
943 for(int i=0;i<sz;i++)
945 PyObject *o=PyList_GetItem(pyLi,i);
946 if(!fillStringVector(o,arr[i]))
947 throw INTERP_KERNEL::Exception(msg);
950 else if(PyTuple_Check(pyLi))
952 Py_ssize_t sz=PyTuple_Size(pyLi);
954 for(int i=0;i<sz;i++)
956 PyObject *o=PyTuple_GetItem(pyLi,i);
957 if(!fillStringVector(o,arr[i]))
958 throw INTERP_KERNEL::Exception(msg);
962 throw INTERP_KERNEL::Exception(msg);
965 static bool fillIntVector(PyObject *pyLi, std::vector<int>& vec)
967 if(PyList_Check(pyLi))
969 Py_ssize_t sz=PyList_Size(pyLi);
971 for(int i=0;i<sz;i++)
973 PyObject *o=PyList_GetItem(pyLi,i);
975 vec[i]=PyInt_AS_LONG(o);
981 else if(PyTuple_Check(pyLi))
983 Py_ssize_t sz=PyTuple_Size(pyLi);
985 for(int i=0;i<sz;i++)
987 PyObject *o=PyTuple_GetItem(pyLi,i);
989 vec[i]=PyInt_AS_LONG(o);
999 static void convertPyToVectorOfVectorOfInt(PyObject *pyLi, std::vector< std::vector<int> >& arr)
1001 const char msg[]="convertPyToVectorOfVectorOfInt : expecting list of list of strings !";
1002 if(PyList_Check(pyLi))
1004 Py_ssize_t sz=PyList_Size(pyLi);
1006 for(int i=0;i<sz;i++)
1008 PyObject *o=PyList_GetItem(pyLi,i);
1009 if(!fillIntVector(o,arr[i]))
1010 throw INTERP_KERNEL::Exception(msg);
1013 else if(PyTuple_Check(pyLi))
1015 Py_ssize_t sz=PyTuple_Size(pyLi);
1017 for(int i=0;i<sz;i++)
1019 PyObject *o=PyTuple_GetItem(pyLi,i);
1020 if(!fillIntVector(o,arr[i]))
1021 throw INTERP_KERNEL::Exception(msg);
1025 throw INTERP_KERNEL::Exception(msg);
1028 static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< std::pair<std::string, std::vector<std::string> > >& arr)
1030 const char msg[]="convertPyToVectorPairStringVecString : expecting list of tuples containing each exactly 2 items : one string and one vector of string !";
1031 if(PyList_Check(pyLi))
1033 Py_ssize_t sz=PyList_Size(pyLi);
1035 for(int i=0;i<sz;i++)
1037 PyObject *o=PyList_GetItem(pyLi,i);
1038 if(PyTuple_Check(o))
1040 int sz2=PyTuple_Size(o);
1042 throw INTERP_KERNEL::Exception(msg);
1043 std::pair<std::string, std::vector<std::string> > item;
1044 PyObject *o_0=PyTuple_GetItem(o,0);
1045 item.first=convertPyObjectToStr(o_0,msg);
1046 PyObject *o_1=PyTuple_GetItem(o,1);
1047 if(!fillStringVector(o_1,item.second))
1048 throw INTERP_KERNEL::Exception(msg);
1052 throw INTERP_KERNEL::Exception(msg);
1055 else if(PyTuple_Check(pyLi))
1057 Py_ssize_t sz=PyTuple_Size(pyLi);
1059 for(int i=0;i<sz;i++)
1061 PyObject *o=PyTuple_GetItem(pyLi,i);
1062 if(PyTuple_Check(o))
1064 int sz2=PyTuple_Size(o);
1066 throw INTERP_KERNEL::Exception(msg);
1067 std::pair<std::string, std::vector<std::string> > item;
1068 PyObject *o_0=PyTuple_GetItem(o,0);
1069 item.first=convertPyObjectToStr(o_0,msg);
1070 PyObject *o_1=PyTuple_GetItem(o,1);
1071 if(!fillStringVector(o_1,item.second))
1072 throw INTERP_KERNEL::Exception(msg);
1076 throw INTERP_KERNEL::Exception(msg);
1080 throw INTERP_KERNEL::Exception(msg);
1084 PyObject *convertDblArrToPyList(const T *ptr, int size)
1086 PyObject *ret(PyList_New(size));
1087 for(int i=0;i<size;i++)
1088 PyList_SetItem(ret,i,PyFloat_FromDouble(ptr[i]));
1092 static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
1095 PyObject *ret(PyList_New(size));
1096 for(int i=0;i<size;i++)
1097 PyList_SetItem(ret,i,PyFloat_FromDouble(v[i]));
1102 PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, int nbOfTuples)
1104 PyObject *ret(PyList_New(nbOfTuples));
1105 for(int i=0;i<nbOfTuples;i++)
1107 PyObject *t=PyTuple_New(nbOfComp);
1108 for(int j=0;j<nbOfComp;j++)
1109 PyTuple_SetItem(t,j,PyFloat_FromDouble(vals[i*nbOfComp+j]));
1110 PyList_SetItem(ret,i,t);
1115 static PyObject *convertCharArrToPyListOfTuple(const char *vals, int nbOfComp, int nbOfTuples)
1117 PyObject *ret=PyList_New(nbOfTuples);
1118 INTERP_KERNEL::AutoPtr<char> tmp=new char[nbOfComp+1]; tmp[nbOfComp]='\0';
1119 for(int i=0;i<nbOfTuples;i++)
1121 std::copy(vals+i*nbOfComp,vals+(i+1)*nbOfComp,(char *)tmp);
1122 PyList_SetItem(ret,i,PyString_FromString(tmp));
1127 static double *convertPyToNewDblArr2(PyObject *pyLi, int *size)
1129 if(PyList_Check(pyLi))
1131 *size=PyList_Size(pyLi);
1132 double *tmp=(double *)malloc((*size)*sizeof(double));
1133 for(int i=0;i<*size;i++)
1135 PyObject *o=PyList_GetItem(pyLi,i);
1136 if(PyFloat_Check(o))
1138 double val=PyFloat_AS_DOUBLE(o);
1141 else if(PyInt_Check(o))
1143 long val0=PyInt_AS_LONG(o);
1150 throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : list must contain floats/integers only");
1155 else if(PyTuple_Check(pyLi))
1157 *size=PyTuple_Size(pyLi);
1158 double *tmp=(double *)malloc((*size)*sizeof(double));
1159 for(int i=0;i<*size;i++)
1161 PyObject *o=PyTuple_GetItem(pyLi,i);
1162 if(PyFloat_Check(o))
1164 double val=PyFloat_AS_DOUBLE(o);
1167 else if(PyInt_Check(o))
1169 long val0=PyInt_AS_LONG(o);
1176 throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : tuple must contain floats/integers only");
1182 throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : not a list");
1185 static void fillArrayWithPyListDbl3(PyObject *pyLi, int& nbOfElt, std::vector<double>& ret)
1187 static const char MSG[]="fillArrayWithPyListDbl3 : It appears that the input list or tuple is composed by elts having different sizes !";
1188 if(PyFloat_Check(pyLi))
1194 throw INTERP_KERNEL::Exception(MSG);
1195 double val=PyFloat_AS_DOUBLE(pyLi);
1198 else if(PyInt_Check(pyLi))
1200 long val0=PyInt_AS_LONG(pyLi);
1206 throw INTERP_KERNEL::Exception(MSG);
1209 else if(PyList_Check(pyLi))
1211 int size=PyList_Size(pyLi);
1213 for(int i=0;i<size;i++)
1215 PyObject *o=PyList_GetItem(pyLi,i);
1217 fillArrayWithPyListDbl3(o,tmp1,ret);
1225 throw INTERP_KERNEL::Exception(MSG);
1228 else if(PyTuple_Check(pyLi))
1230 int size=PyTuple_Size(pyLi);
1232 for(int i=0;i<size;i++)
1234 PyObject *o=PyTuple_GetItem(pyLi,i);
1236 fillArrayWithPyListDbl3(o,tmp1,ret);
1244 throw INTERP_KERNEL::Exception(MSG);
1248 throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl3 : Unrecognized type ! Should be a composition of tuple,list,int and float !");
1251 static std::vector<double> fillArrayWithPyListDbl2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp)
1253 std::vector<double> ret;
1254 int size1=-1,size2=-1;
1255 if(PyList_Check(pyLi))
1257 size1=PyList_Size(pyLi);
1258 for(int i=0;i<size1;i++)
1260 PyObject *o=PyList_GetItem(pyLi,i);
1261 fillArrayWithPyListDbl3(o,size2,ret);
1266 else if(PyTuple_Check(pyLi))
1268 size1=PyTuple_Size(pyLi);
1269 for(int i=0;i<size1;i++)
1271 PyObject *o=PyTuple_GetItem(pyLi,i);
1272 fillArrayWithPyListDbl3(o,size2,ret);
1278 throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !");
1280 checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
1284 //convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingUMesh *>(pyLi,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh")
1286 static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, const char *typeStr, typename std::vector<T>& ret)
1289 if(PyList_Check(pyLi))
1291 int size=PyList_Size(pyLi);
1293 for(int i=0;i<size;i++)
1295 PyObject *obj=PyList_GetItem(pyLi,i);
1296 int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
1297 if(!SWIG_IsOK(status))
1299 std::ostringstream oss; oss << "convertFromPyObjVectorOfObj : list is excepted to contain only " << typeStr << " instances !";
1300 throw INTERP_KERNEL::Exception(oss.str().c_str());
1302 T arg=reinterpret_cast< T >(argp);
1306 else if(PyTuple_Check(pyLi))
1308 int size=PyTuple_Size(pyLi);
1310 for(int i=0;i<size;i++)
1312 PyObject *obj=PyTuple_GetItem(pyLi,i);
1313 int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
1314 if(!SWIG_IsOK(status))
1316 std::ostringstream oss; oss << "convertFromPyObjVectorOfObj : tuple is excepted to contain only " << typeStr << " instances !";
1317 throw INTERP_KERNEL::Exception(oss.str().c_str());
1319 T arg=reinterpret_cast< T >(argp);
1323 else if(SWIG_IsOK(SWIG_ConvertPtr(pyLi,&argp,ty,0|0)))
1326 T arg=reinterpret_cast< T >(argp);
1330 throw INTERP_KERNEL::Exception("convertFromPyObjVectorOfObj : not a list nor a tuple");
1334 * if python int -> cpp int sw=1
1335 * if python list[int] -> cpp vector<int> sw=2
1336 * if python tuple[int] -> cpp vector<int> sw=2
1337 * if python DataArrayInt -> cpp DataArrayInt sw=3
1338 * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
1340 * switch between (int,vector<int>,DataArrayInt)
1342 static void convertIntStarLikePyObjToCpp(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple)
1345 if(PyInt_Check(value))
1347 iTyypp=(int)PyInt_AS_LONG(value);
1351 if(PyTuple_Check(value))
1353 int size=PyTuple_Size(value);
1354 stdvecTyypp.resize(size);
1355 for(int i=0;i<size;i++)
1357 PyObject *o=PyTuple_GetItem(value,i);
1359 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1362 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1363 throw INTERP_KERNEL::Exception(oss.str().c_str());
1369 if(PyList_Check(value))
1371 int size=PyList_Size(value);
1372 stdvecTyypp.resize(size);
1373 for(int i=0;i<size;i++)
1375 PyObject *o=PyList_GetItem(value,i);
1377 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1380 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1381 throw INTERP_KERNEL::Exception(oss.str().c_str());
1388 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1389 if(SWIG_IsOK(status))
1391 daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1395 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1396 if(SWIG_IsOK(status))
1398 daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1402 throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
1406 * if python int -> cpp int sw=1
1407 * if python list[int] -> cpp vector<int> sw=2
1408 * if python tuple[int] -> cpp vector<int> sw=2
1409 * if python DataArrayInt -> cpp DataArrayInt sw=3
1410 * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
1412 * switch between (int,vector<int>,DataArrayInt)
1414 static const int *convertIntStarLikePyObjToCppIntStar(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector<int>& stdvecTyypp)
1417 if(PyInt_Check(value))
1419 iTyypp=(int)PyInt_AS_LONG(value);
1423 if(PyTuple_Check(value))
1425 int size=PyTuple_Size(value);
1426 stdvecTyypp.resize(size);
1427 for(int i=0;i<size;i++)
1429 PyObject *o=PyTuple_GetItem(value,i);
1431 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1434 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1435 throw INTERP_KERNEL::Exception(oss.str().c_str());
1439 return &stdvecTyypp[0];
1441 if(PyList_Check(value))
1443 int size=PyList_Size(value);
1444 stdvecTyypp.resize(size);
1445 for(int i=0;i<size;i++)
1447 PyObject *o=PyList_GetItem(value,i);
1449 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1452 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1453 throw INTERP_KERNEL::Exception(oss.str().c_str());
1457 return &stdvecTyypp[0];
1460 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1461 if(SWIG_IsOK(status))
1463 MEDCoupling::DataArrayInt *daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1466 sw=3; sz=daIntTyypp->getNbOfElems();
1467 return daIntTyypp->begin();
1475 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1476 if(SWIG_IsOK(status))
1478 MEDCoupling::DataArrayIntTuple *daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1479 sw=4; sz=daIntTuple->getNumberOfCompo();
1480 return daIntTuple->getConstPointer();
1482 throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
1486 * if python double -> cpp double sw=1
1487 * if python int -> cpp double sw=1
1488 * if python list[double] -> cpp vector<double> sw=2
1489 * if python list[int] -> cpp vector<double> sw=2
1490 * if python tuple[double] -> cpp vector<double> sw=2
1491 * if python tuple[int] -> cpp vector<double> sw=2
1492 * if python DataArrayDouble -> cpp DataArrayDouble sw=3
1494 * switch between (int,vector<int>,DataArrayInt)
1497 void considerPyObjAsATStarLikeObject(PyObject *value, int& sw, T& iTyypp, std::vector<T>& stdvecTyypp, typename MEDCoupling::Traits<T>::ArrayType *& daIntTyypp, swig_type_info *ti)
1500 if(PyFloat_Check(value))
1502 iTyypp=(T)PyFloat_AS_DOUBLE(value);
1506 if(PyInt_Check(value))
1508 iTyypp=(T)PyInt_AS_LONG(value);
1512 if(PyTuple_Check(value))
1514 int size=PyTuple_Size(value);
1515 stdvecTyypp.resize(size);
1516 for(int i=0;i<size;i++)
1518 PyObject *o=PyTuple_GetItem(value,i);
1519 if(PyFloat_Check(o))
1520 stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
1521 else if(PyInt_Check(o))
1522 stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
1525 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1526 throw INTERP_KERNEL::Exception(oss.str().c_str());
1532 if(PyList_Check(value))
1534 int size=PyList_Size(value);
1535 stdvecTyypp.resize(size);
1536 for(int i=0;i<size;i++)
1538 PyObject *o=PyList_GetItem(value,i);
1539 if(PyFloat_Check(o))
1540 stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
1541 else if(PyInt_Check(o))
1542 stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
1545 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1546 throw INTERP_KERNEL::Exception(oss.str().c_str());
1553 int status=SWIG_ConvertPtr(value,&argp,ti,0|0);
1554 if(!SWIG_IsOK(status))
1555 throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
1556 daIntTyypp=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayType * >(argp);
1561 * if python double -> cpp double sw=1
1562 * if python int -> cpp double sw=1
1563 * if python list[double] -> cpp vector<double> sw=2
1564 * if python list[int] -> cpp vector<double> sw=2
1565 * if python tuple[double] -> cpp vector<double> sw=2
1566 * if python tuple[int] -> cpp vector<double> sw=2
1567 * if python DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1569 * switch between (int,vector<int>,DataArrayInt)
1571 static void convertDoubleStarLikePyObjToCpp(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, MEDCoupling::DataArrayDoubleTuple *& daIntTyypp)
1574 if(PyFloat_Check(value))
1576 iTyypp=PyFloat_AS_DOUBLE(value);
1580 if(PyInt_Check(value))
1582 iTyypp=(double)PyInt_AS_LONG(value);
1586 if(PyTuple_Check(value))
1588 int size=PyTuple_Size(value);
1589 stdvecTyypp.resize(size);
1590 for(int i=0;i<size;i++)
1592 PyObject *o=PyTuple_GetItem(value,i);
1593 if(PyFloat_Check(o))
1594 stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1595 else if(PyInt_Check(o))
1596 stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1599 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1600 throw INTERP_KERNEL::Exception(oss.str().c_str());
1606 if(PyList_Check(value))
1608 int size=PyList_Size(value);
1609 stdvecTyypp.resize(size);
1610 for(int i=0;i<size;i++)
1612 PyObject *o=PyList_GetItem(value,i);
1613 if(PyFloat_Check(o))
1614 stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1615 else if(PyInt_Check(o))
1616 stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1619 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1620 throw INTERP_KERNEL::Exception(oss.str().c_str());
1627 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
1628 if(!SWIG_IsOK(status))
1629 throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDoubleTuple");
1630 daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
1635 void convertFPStarLikePyObjToCpp_2(PyObject *value, int& sw, T& val, typename MEDCoupling::Traits<T>::ArrayType *&d, typename MEDCoupling::Traits<T>::ArrayTuple *&e, std::vector<T>& f, swig_type_info *ti_da, swig_type_info *ti_tuple)
1638 if(PyFloat_Check(value))
1640 val=PyFloat_AS_DOUBLE(value);
1644 if(PyInt_Check(value))
1646 val=(T)PyInt_AS_LONG(value);
1650 if(PyTuple_Check(value))
1652 int size=PyTuple_Size(value);
1654 for(int i=0;i<size;i++)
1656 PyObject *o=PyTuple_GetItem(value,i);
1657 if(PyFloat_Check(o))
1658 f[i]=PyFloat_AS_DOUBLE(o);
1659 else if(PyInt_Check(o))
1660 f[i]=(T)PyInt_AS_LONG(o);
1663 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1664 throw INTERP_KERNEL::Exception(oss.str().c_str());
1670 if(PyList_Check(value))
1672 int size=PyList_Size(value);
1674 for(int i=0;i<size;i++)
1676 PyObject *o=PyList_GetItem(value,i);
1677 if(PyFloat_Check(o))
1678 f[i]=PyFloat_AS_DOUBLE(o);
1679 else if(PyInt_Check(o))
1680 f[i]=(T)PyInt_AS_LONG(o);
1683 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1684 throw INTERP_KERNEL::Exception(oss.str().c_str());
1691 int status=SWIG_ConvertPtr(value,&argp,ti_da,0|0);
1692 if(SWIG_IsOK(status))
1694 d=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayType * >(argp);
1698 status=SWIG_ConvertPtr(value,&argp,ti_tuple,0|0);
1699 if(SWIG_IsOK(status))
1701 e=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayTuple * >(argp);
1705 throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
1709 * if value int -> cpp val sw=1
1710 * if value double -> cpp val sw=1
1711 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1712 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1713 * if value list[int,double] -> cpp std::vector<double> sw=4
1714 * if value tuple[int,double] -> cpp std::vector<double> sw=4
1716 static void convertDoubleStarLikePyObjToCpp_2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f)
1718 convertFPStarLikePyObjToCpp_2<double>(value,sw,val,d,e,f,SWIGTYPE_p_MEDCoupling__DataArrayDouble,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple);
1722 * if value int -> cpp val sw=1
1723 * if value double -> cpp val sw=1
1724 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1725 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1726 * if value list[int,double] -> cpp std::vector<double> sw=4
1727 * if value tuple[int,double] -> cpp std::vector<double> sw=4
1729 static void convertFloatStarLikePyObjToCpp_2(PyObject *value, int& sw, float& val, MEDCoupling::DataArrayFloat *&d, MEDCoupling::DataArrayFloatTuple *&e, std::vector<float>& f)
1731 convertFPStarLikePyObjToCpp_2<float>(value,sw,val,d,e,f,SWIGTYPE_p_MEDCoupling__DataArrayFloat,SWIGTYPE_p_MEDCoupling__DataArrayFloatTuple);
1735 * if python int -> cpp int sw=1
1736 * if python list[int] -> cpp vector<int> sw=2
1737 * if python tuple[int] -> cpp vector<int> sw=2
1738 * if python slicp -> cpp pair sw=3 (begin,end,step)
1739 * if python DataArrayInt -> cpp DataArrayInt sw=4 . The returned pointer cannot be the null pointer ! If null an exception is thrown.
1741 * switch between (int,vector<int>,DataArrayInt)
1743 static void convertIntStarOrSliceLikePyObjToCpp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp)
1745 const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple";
1747 if(PyInt_Check(value))
1749 iTyypp=(int)PyInt_AS_LONG(value);
1753 if(PyTuple_Check(value))
1755 int size=PyTuple_Size(value);
1756 stdvecTyypp.resize(size);
1757 for(int i=0;i<size;i++)
1759 PyObject *o=PyTuple_GetItem(value,i);
1761 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1764 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1765 throw INTERP_KERNEL::Exception(oss.str().c_str());
1771 if(PyList_Check(value))
1773 int size=PyList_Size(value);
1774 stdvecTyypp.resize(size);
1775 for(int i=0;i<size;i++)
1777 PyObject *o=PyList_GetItem(value,i);
1779 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1782 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1783 throw INTERP_KERNEL::Exception(oss.str().c_str());
1789 if(PySlice_Check(value))
1791 Py_ssize_t strt=2,stp=2,step=2;
1792 GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
1795 p.second.second=step;
1800 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1801 if(SWIG_IsOK(status))
1803 daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1806 std::ostringstream oss; oss << msg << " Instance in null !";
1807 throw INTERP_KERNEL::Exception(oss.str().c_str());
1812 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1813 if(SWIG_IsOK(status))
1815 MEDCoupling::DataArrayIntTuple *tmp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1818 std::ostringstream oss; oss << msg << " Instance in null !";
1819 throw INTERP_KERNEL::Exception(oss.str().c_str());
1821 stdvecTyypp.resize(tmp->getNumberOfCompo());
1822 std::copy(tmp->getConstPointer(),tmp->getConstPointer()+tmp->getNumberOfCompo(),stdvecTyypp.begin());
1826 throw INTERP_KERNEL::Exception(msg);
1830 * Idem than convertIntStarOrSliceLikePyObjToCpp
1832 static void convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp)
1834 convertIntStarOrSliceLikePyObjToCpp(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
1837 iTyypp=InterpreteNegativeInt(iTyypp,nbelem);
1842 * if python int -> cpp int sw=1
1843 * if python tuple[int] -> cpp vector<int> sw=2
1844 * if python list[int] -> cpp vector<int> sw=2
1845 * if python slice -> cpp pair sw=3
1846 * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 . WARNING The returned pointer can be the null pointer !
1848 static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayIntTuple *& daIntTyypp)
1851 if(PyInt_Check(value))
1853 iTyypp=(int)PyInt_AS_LONG(value);
1857 if(PyTuple_Check(value))
1859 int size=PyTuple_Size(value);
1860 stdvecTyypp.resize(size);
1861 for(int i=0;i<size;i++)
1863 PyObject *o=PyTuple_GetItem(value,i);
1865 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1868 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1869 throw INTERP_KERNEL::Exception(oss.str().c_str());
1875 if(PyList_Check(value))
1877 int size=PyList_Size(value);
1878 stdvecTyypp.resize(size);
1879 for(int i=0;i<size;i++)
1881 PyObject *o=PyList_GetItem(value,i);
1883 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1886 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1887 throw INTERP_KERNEL::Exception(oss.str().c_str());
1893 if(PySlice_Check(value))
1895 Py_ssize_t strt=2,stp=2,step=2;
1896 GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
1899 p.second.second=step;
1904 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1905 if(!SWIG_IsOK(status))
1906 throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayIntTuple");
1907 daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1912 * if python string with size one -> cpp char sw=1
1913 * if python string with size different from one -> cpp string sw=2
1914 * if python tuple[string] or list[string] -> vector<string> sw=3
1915 * if python not null pointer of DataArrayChar -> cpp DataArrayChar sw=4
1916 * switch between (int,string,vector<string>,DataArrayChar)
1918 static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, MEDCoupling::DataArrayChar *& dacType)
1920 const char *msg="4 types accepted : string, list or tuple of strings having same size, not null DataArrayChar instance.";
1922 if(PyString_Check(value))
1924 const char *pt=PyString_AsString(value);
1925 Py_ssize_t sz=PyString_Size(value);
1939 #if PY_VERSION_HEX >= 0x03000000
1940 if(PyUnicode_Check(value))
1943 const char *pt = PyUnicode_AsUTF8AndSize(value, &sz);
1958 if(PyTuple_Check(value))
1960 int size=PyTuple_Size(value);
1961 vsType.resize(size);
1962 for(int i=0;i<size;i++)
1964 PyObject *o=PyTuple_GetItem(value,i);
1967 vsType[i]=convertPyObjectToStr(o);
1969 catch(INTERP_KERNEL::Exception& e)
1971 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1972 throw INTERP_KERNEL::Exception(oss.str().c_str());
1978 if(PyList_Check(value))
1980 int size=PyList_Size(value);
1981 vsType.resize(size);
1982 for(int i=0;i<size;i++)
1984 PyObject *o=PyList_GetItem(value,i);
1987 vsType[i]=convertPyObjectToStr(o);
1989 catch(INTERP_KERNEL::Exception& e)
1991 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1992 throw INTERP_KERNEL::Exception(oss.str().c_str());
1999 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayChar,0|0);
2000 if(SWIG_IsOK(status))
2002 dacType=reinterpret_cast< MEDCoupling::DataArrayChar * >(argp);
2005 std::ostringstream oss; oss << msg << " Instance in null !";
2006 throw INTERP_KERNEL::Exception(oss.str().c_str());
2011 throw INTERP_KERNEL::Exception(msg);
2015 * if value int -> cpp it sw=1
2016 * if value list[int] -> vt sw=2
2017 * if value tuple[int] -> vt sw=2
2018 * if value slice -> pt sw=3
2019 * if value DataArrayInt -> dt sw=4
2020 * if value tuple [int,int] -> cpp it,ip sw=5
2021 * if value tuple [list[int],int] -> cpp vt,ip sw=6
2022 * if value tuple [tuple[int],int] -> cpp vt,ip sw=6
2023 * if value tuple [slice,int] -> cpp pt,ip sw=7
2024 * if value tuple [DaI,int] -> cpp dt,ip sw=8
2025 * if value tuple [int,list[int]] -> cpp it,vc sw=9
2026 * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10
2027 * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10
2028 * if value tuple [slice,list[int]] -> cpp pt,vc sw=11
2029 * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12
2030 * if value tuple [int,tuple[int]] -> cpp it,vc sw=9
2031 * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10
2032 * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10
2033 * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11
2034 * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12
2035 * if value tuple [int,slice] -> cpp it,pc sw=13
2036 * if value tuple [list[int],slice] -> cpp vt,pc sw=14
2037 * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14
2038 * if value tuple [slice,slice] -> cpp pt,pc sw=15
2039 * if value tuple [DaI,slice] -> cpp dt,pc sw=16
2041 * switch between (int,vector<int>,DataArrayInt)
2043 static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
2044 std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
2045 MEDCoupling::DataArrayInt *&dt, MEDCoupling::DataArrayInt *&dc)
2047 if(!PyTuple_Check(value))
2049 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(value,nbTuple,sw,it,vt,pt,dt);
2054 int sz=PyTuple_Size(value);
2056 throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
2057 PyObject *ob0=PyTuple_GetItem(value,0);
2059 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob0,nbTuple,sw1,it,vt,pt,dt);
2060 PyObject *ob1=PyTuple_GetItem(value,1);
2061 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob1,nbCompo,sw2,ic,vc,pc,dc);
2067 * if value int -> cpp val sw=1
2068 * if value double -> cpp val sw=1
2069 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2070 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2071 * if value list[int,double] -> cpp std::vector<double> sw=4
2072 * if value tuple[int,double] -> cpp std::vector<double> sw=4
2074 static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
2075 const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt)
2078 if(PyFloat_Check(value))
2080 val=PyFloat_AS_DOUBLE(value);
2082 if(nbTuplesExpected*nbCompExpected!=1)
2084 std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
2085 throw INTERP_KERNEL::Exception(oss.str().c_str());
2089 if(PyInt_Check(value))
2091 val=(double)PyInt_AS_LONG(value);
2093 if(nbTuplesExpected*nbCompExpected!=1)
2095 std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
2096 throw INTERP_KERNEL::Exception(oss.str().c_str());
2100 if(PyTuple_Check(value) || PyList_Check(value))
2104 int tmp1=nbTuplesExpected,tmp2=nbCompExpected;
2105 std::vector<double> ret=fillArrayWithPyListDbl2(value,tmp1,tmp2);
2110 catch(INTERP_KERNEL::Exception& exc) { throw exc; }
2113 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2114 if(SWIG_IsOK(status))
2116 d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2120 if(d->getNumberOfTuples()==nbTuplesExpected)
2122 if(d->getNumberOfComponents()==nbCompExpected)
2124 return d->getConstPointer();
2128 std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
2129 throw INTERP_KERNEL::Exception(oss.str().c_str());
2134 std::ostringstream oss; oss << msg << " input DataArrayDouble should have a number of tuples equal to " << nbTuplesExpected << " and there are " << d->getNumberOfTuples() << " tuples !";
2135 throw INTERP_KERNEL::Exception(oss.str().c_str());
2142 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2143 throw INTERP_KERNEL::Exception(oss.str().c_str());
2149 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2150 if(SWIG_IsOK(status))
2152 e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2154 if(e->getNumberOfCompo()==nbCompExpected)
2156 if(nbTuplesExpected==1)
2157 return e->getConstPointer();
2160 std::ostringstream oss; oss << msg << "nb of tuples expected to be " << nbTuplesExpected << " , and input DataArrayDoubleTuple has always one tuple by contruction !";
2161 throw INTERP_KERNEL::Exception(oss.str().c_str());
2166 std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
2167 throw INTERP_KERNEL::Exception(oss.str().c_str());
2170 throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2174 * if value int -> cpp val sw=1
2175 * if value double -> cpp val sw=1
2176 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2177 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2178 * if value list[int,double] -> cpp std::vector<double> sw=4
2179 * if value tuple[int,double] -> cpp std::vector<double> sw=4
2181 static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
2182 const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples)
2185 if(PyFloat_Check(value))
2187 val=PyFloat_AS_DOUBLE(value);
2189 if(nbCompExpected!=1)
2191 std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
2192 throw INTERP_KERNEL::Exception(oss.str().c_str());
2197 if(PyInt_Check(value))
2199 val=(double)PyInt_AS_LONG(value);
2201 if(nbCompExpected!=1)
2203 std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
2204 throw INTERP_KERNEL::Exception(oss.str().c_str());
2209 if(PyTuple_Check(value))
2211 int size=PyTuple_Size(value);
2213 for(int i=0;i<size;i++)
2215 PyObject *o=PyTuple_GetItem(value,i);
2216 if(PyFloat_Check(o))
2217 f[i]=PyFloat_AS_DOUBLE(o);
2218 else if(PyInt_Check(o))
2219 f[i]=(double)PyInt_AS_LONG(o);
2222 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
2223 throw INTERP_KERNEL::Exception(oss.str().c_str());
2227 if(size%nbCompExpected!=0)
2229 std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
2230 throw INTERP_KERNEL::Exception(oss.str().c_str());
2232 nbTuples=size/nbCompExpected;
2235 if(PyList_Check(value))
2237 int size=PyList_Size(value);
2239 for(int i=0;i<size;i++)
2241 PyObject *o=PyList_GetItem(value,i);
2242 if(PyFloat_Check(o))
2243 f[i]=PyFloat_AS_DOUBLE(o);
2244 else if(PyInt_Check(o))
2245 f[i]=(double)PyInt_AS_LONG(o);
2248 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
2249 throw INTERP_KERNEL::Exception(oss.str().c_str());
2253 if(size%nbCompExpected!=0)
2255 std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
2256 throw INTERP_KERNEL::Exception(oss.str().c_str());
2258 nbTuples=size/nbCompExpected;
2262 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2263 if(SWIG_IsOK(status))
2265 d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2269 if(d->getNumberOfComponents()==nbCompExpected)
2271 nbTuples=d->getNumberOfTuples();
2272 return d->getConstPointer();
2276 std::ostringstream oss; oss << msg << "nb of components expected to be a multiple of " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
2277 throw INTERP_KERNEL::Exception(oss.str().c_str());
2284 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2285 throw INTERP_KERNEL::Exception(oss.str().c_str());
2288 { nbTuples=0; return 0; }
2291 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2292 if(SWIG_IsOK(status))
2294 e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2298 if(e->getNumberOfCompo()==nbCompExpected)
2301 return e->getConstPointer();
2305 std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
2306 throw INTERP_KERNEL::Exception(oss.str().c_str());
2313 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2314 throw INTERP_KERNEL::Exception(oss.str().c_str());
2317 { nbTuples=0; return 0; }
2320 throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2324 * if value int -> cpp val sw=1
2325 * if value double -> cpp val sw=1
2326 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2327 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2328 * if value list[int,double] -> cpp std::vector<double> sw=4
2329 * if value tuple[int,double] -> cpp std::vector<double> sw=4
2331 static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
2332 const char *msg, bool throwIfNullPt, int& nbTuples)
2334 MEDCoupling::DataArrayDouble *d=0;
2335 MEDCoupling::DataArrayDoubleTuple *e=0;
2337 if(PyFloat_Check(value))
2339 val=PyFloat_AS_DOUBLE(value);
2344 if(PyInt_Check(value))
2346 val=(double)PyInt_AS_LONG(value);
2351 if(PyTuple_Check(value))
2353 int size=PyTuple_Size(value);
2355 for(int i=0;i<size;i++)
2357 PyObject *o=PyTuple_GetItem(value,i);
2358 if(PyFloat_Check(o))
2359 f[i]=PyFloat_AS_DOUBLE(o);
2360 else if(PyInt_Check(o))
2361 f[i]=(double)PyInt_AS_LONG(o);
2364 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
2365 throw INTERP_KERNEL::Exception(oss.str().c_str());
2372 if(PyList_Check(value))
2374 int size=PyList_Size(value);
2376 for(int i=0;i<size;i++)
2378 PyObject *o=PyList_GetItem(value,i);
2379 if(PyFloat_Check(o))
2380 f[i]=PyFloat_AS_DOUBLE(o);
2381 else if(PyInt_Check(o))
2382 f[i]=(double)PyInt_AS_LONG(o);
2385 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
2386 throw INTERP_KERNEL::Exception(oss.str().c_str());
2394 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2395 if(SWIG_IsOK(status))
2397 d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2401 if(d->getNumberOfComponents()==1)
2403 nbTuples=d->getNumberOfTuples();
2404 return d->getConstPointer();
2408 std::ostringstream oss; oss << msg << "nb of components expected to be one, and input has " << d->getNumberOfComponents() << " components !";
2409 throw INTERP_KERNEL::Exception(oss.str().c_str());
2416 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2417 throw INTERP_KERNEL::Exception(oss.str().c_str());
2420 { nbTuples=0; return 0; }
2423 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2424 if(SWIG_IsOK(status))
2426 e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2430 nbTuples=e->getNumberOfCompo();
2431 return e->getConstPointer();
2437 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2438 throw INTERP_KERNEL::Exception(oss.str().c_str());
2441 { nbTuples=0; return 0; }
2444 throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2447 static MEDCoupling::DataArray *CheckAndRetrieveDataArrayInstance(PyObject *obj, const char *msg)
2450 int status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArray,0|0);
2451 if(!SWIG_IsOK(status))
2453 status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2454 if(!SWIG_IsOK(status))
2456 status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
2457 if(!SWIG_IsOK(status))
2459 status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,0|0);
2460 if(!SWIG_IsOK(status))
2462 status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayByte,0|0);
2463 std::ostringstream oss; oss << msg << " ! Accepted instances are DataArrayDouble, DataArrayInt, DataArrayAsciiChar, DataArrayByte !";
2464 throw INTERP_KERNEL::Exception(oss.str().c_str());
2469 return reinterpret_cast< MEDCoupling::DataArray * >(aBasePtrVS);
2472 static PyObject *NewMethWrapCallInitOnlyIfEmptyDictInInput(PyObject *cls, PyObject *args, const char *clsName)
2474 if(!PyTuple_Check(args))
2476 std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
2477 throw INTERP_KERNEL::Exception(oss.str().c_str());
2479 PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
2480 PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
2481 PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
2483 PyObject *tmp0(PyTuple_New(1));
2484 PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
2485 PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
2487 Py_DECREF(selfMeth);
2488 if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==0 )
2489 {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
2490 PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
2491 PyObject *tmp3(PyTuple_New(0));
2492 PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
2495 Py_DECREF(initMeth);
2501 static PyObject *NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral(PyObject *cls, PyObject *args, const char *clsName)
2503 if(!PyTuple_Check(args))
2505 std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
2506 throw INTERP_KERNEL::Exception(oss.str().c_str());
2508 PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
2509 PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
2510 PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
2512 PyObject *tmp0(PyTuple_New(1));
2513 PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
2514 PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
2516 Py_DECREF(selfMeth);
2517 if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
2518 {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
2519 PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
2520 PyObject *zeNumpyRepr(0);
2522 PyObject *tmp1(PyInt_FromLong(0));
2523 zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed
2528 std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
2529 throw INTERP_KERNEL::Exception(oss.str().c_str());
2536 tmp3=tt(zeNumpyRepr);
2538 catch(INTERP_KERNEL::Exception& e)
2540 std::ostringstream oss; oss << clsName << ".__new__ : Invalid type in input " << " : " << e.what();
2541 throw INTERP_KERNEL::Exception(oss.str());
2544 PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
2549 Py_DECREF(initMeth);
2554 struct SinglePyObjToBePutInATuple
2556 PyObject *operator()(PyObject *zeNumpyRepr)
2558 PyObject *tmp3(PyTuple_New(1));
2559 PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr);
2564 struct SinglePyObjExpectToBeAListOfSz2
2566 PyObject *operator()(PyObject *uniqueElt)
2568 if(!PyTuple_Check(uniqueElt) || PyTuple_Size(uniqueElt)!=2)
2569 throw INTERP_KERNEL::Exception("Not a tuple of size 2 !");
2570 Py_XINCREF(uniqueElt);
2575 static PyObject *NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(PyObject *cls, PyObject *args, const char *clsName)
2577 return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral<SinglePyObjToBePutInATuple>(cls,args,clsName);
2580 static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner)
2585 Py_XINCREF(Py_None);
2588 if(dynamic_cast<MEDCoupling::DataArrayPartDefinition *>(pd))
2589 ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__DataArrayPartDefinition,owner);
2591 ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__SlicePartDefinition,owner);
2596 static typename MEDCoupling::Traits<T>::ArrayType *DataArrayT_New(PyObject *elt0, PyObject *nbOfTuples, PyObject *elt2)
2598 const char *msgBase="MEDCoupling::DataArrayDouble::New : Available API are : \n-DataArrayDouble.New()\n-DataArrayDouble.New([1.,3.,4.])\n-DataArrayDouble.New([1.,3.,4.],3)\n-DataArrayDouble.New([1.,3.,4.,5.],2,2)\n-DataArrayDouble.New([1.,3.,4.,5.,7,8.],3,2)\n-DataArrayDouble.New([(1.,3.),(4.,5.),(7,8.)])\n-DataArrayDouble.New(5)\n-DataArrayDouble.New(5,2)";
2599 std::string msg(msgBase);
2601 msg+="\n-DataArrayDouble.New(numpy array with dtype=float64)";
2604 if(PyList_Check(elt0) || PyTuple_Check(elt0))
2608 if(PyInt_Check(nbOfTuples))
2610 int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
2612 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
2615 if(PyInt_Check(elt2))
2616 {//DataArrayDouble.New([1.,3.,4.,5.],2,2)
2617 int nbOfCompo=PyInt_AS_LONG(elt2);
2619 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
2620 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2621 std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,nbOfCompo));
2622 ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2626 throw INTERP_KERNEL::Exception(msg.c_str());
2629 {//DataArrayDouble.New([1.,3.,4.],3)
2630 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2632 std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,tmpp1));
2633 ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2638 throw INTERP_KERNEL::Exception(msg.c_str());
2641 {// DataArrayDouble.New([1.,3.,4.])
2642 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2643 int tmpp1(-1),tmpp2(-1);
2644 std::vector<double> tmp=fillArrayWithPyListDbl2(elt0,tmpp1,tmpp2);
2645 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2649 else if(PyInt_Check(elt0))
2651 int nbOfTuples1(PyInt_AS_LONG(elt0));
2653 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
2658 if(PyInt_Check(nbOfTuples))
2659 {//DataArrayDouble.New(5,2)
2660 int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
2662 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
2663 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2664 ret->alloc(nbOfTuples1,nbOfCompo);
2668 throw INTERP_KERNEL::Exception(msg.c_str());
2671 throw INTERP_KERNEL::Exception(msg.c_str());
2674 {//DataArrayDouble.New(5)
2675 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2676 ret->alloc(nbOfTuples1,1);
2681 else if(PyArray_Check(elt0) && nbOfTuples==NULL && elt2==NULL)
2682 {//DataArrayDouble.New(numpyArray)
2683 return BuildNewInstance< typename MEDCoupling::Traits<T>::ArrayType , T >(elt0,NPYTraits<T>::NPYObjectType,NPYTraits<T>::NPYFunc,MEDCoupling::Traits<T>::NPYStr);
2687 throw INTERP_KERNEL::Exception(msg.c_str());
2688 throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
2692 typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__internal(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value, swig_type_info *ti)
2694 self->checkAllocated();
2695 const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
2696 int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
2700 typename MEDCoupling::Traits<T>::ArrayType *d1=0;
2701 considerPyObjAsATStarLikeObject<T>(value,sw1,i1,v1,d1,ti);
2703 std::vector<int> vt1,vc1;
2704 std::pair<int, std::pair<int,int> > pt1,pc1;
2705 MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
2706 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
2707 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > tmp;
2715 self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
2718 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2719 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2720 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
2723 self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
2726 throw INTERP_KERNEL::Exception(msg);
2735 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
2738 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2739 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2740 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
2743 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
2746 throw INTERP_KERNEL::Exception(msg);
2755 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
2758 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2759 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2760 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
2763 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
2766 throw INTERP_KERNEL::Exception(msg);
2775 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
2778 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2779 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2780 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
2783 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
2786 throw INTERP_KERNEL::Exception(msg);
2795 self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
2798 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2799 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2800 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
2803 self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
2806 throw INTERP_KERNEL::Exception(msg);
2815 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
2818 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2819 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2820 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
2823 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
2826 throw INTERP_KERNEL::Exception(msg);
2835 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
2838 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2839 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2840 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
2843 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
2846 throw INTERP_KERNEL::Exception(msg);
2855 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
2858 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2859 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2860 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
2863 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
2866 throw INTERP_KERNEL::Exception(msg);
2875 self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
2878 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2879 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2880 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
2883 self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
2886 throw INTERP_KERNEL::Exception(msg);
2895 self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
2898 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2899 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2900 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
2903 self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
2906 throw INTERP_KERNEL::Exception(msg);
2915 self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
2918 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2919 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2920 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
2923 self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
2926 throw INTERP_KERNEL::Exception(msg);
2935 self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
2938 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2939 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2940 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
2943 self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
2946 throw INTERP_KERNEL::Exception(msg);
2955 self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
2958 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2959 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2960 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
2963 self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
2966 throw INTERP_KERNEL::Exception(msg);
2975 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
2978 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2979 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
2980 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
2983 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
2986 throw INTERP_KERNEL::Exception(msg);
2995 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
2998 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2999 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
3000 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
3003 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
3006 throw INTERP_KERNEL::Exception(msg);
3015 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
3018 tmp=MEDCoupling::Traits<T>::ArrayType::New();
3019 tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
3020 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
3023 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
3026 throw INTERP_KERNEL::Exception(msg);
3031 throw INTERP_KERNEL::Exception(msg);
3037 PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, swig_type_info *ti)
3039 const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !";
3040 const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
3041 self->checkAllocated();
3042 int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
3044 std::vector<int> vt1,vc1;
3045 std::pair<int, std::pair<int,int> > pt1,pc1;
3046 MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
3048 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
3049 MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType > ret;
3053 if(nbOfComponents==1)
3054 return PyFloat_FromDouble((T)self->getIJSafe(it1,0));
3055 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),ti, SWIG_POINTER_OWN | 0 );
3057 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),ti, SWIG_POINTER_OWN | 0 );
3059 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),ti, SWIG_POINTER_OWN | 0 );
3061 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),ti, SWIG_POINTER_OWN | 0 );
3063 return PyFloat_FromDouble((T)self->getIJSafe(it1,ic1));
3066 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3067 std::vector<int> v2(1,ic1);
3068 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3072 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3073 std::vector<int> v2(1,ic1);
3074 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3078 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3079 std::vector<int> v2(1,ic1);
3080 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3084 ret=self->selectByTupleIdSafe(&it1,&it1+1);
3085 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3089 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3090 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3094 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3095 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3099 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3100 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3104 ret=self->selectByTupleIdSafe(&it1,&it1+1);
3105 int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3106 std::vector<int> v2(nbOfComp);
3107 for(int i=0;i<nbOfComp;i++)
3108 v2[i]=pc1.first+i*pc1.second.second;
3109 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3113 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3114 int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3115 std::vector<int> v2(nbOfComp);
3116 for(int i=0;i<nbOfComp;i++)
3117 v2[i]=pc1.first+i*pc1.second.second;
3118 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3122 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3123 int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3124 std::vector<int> v2(nbOfComp);
3125 for(int i=0;i<nbOfComp;i++)
3126 v2[i]=pc1.first+i*pc1.second.second;
3127 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3131 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3132 int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3133 std::vector<int> v2(nbOfComp);
3134 for(int i=0;i<nbOfComp;i++)
3135 v2[i]=pc1.first+i*pc1.second.second;
3136 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3139 throw INTERP_KERNEL::Exception(msg);
3144 PyObject *DataArrayT_imul__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3146 const char msg[]="Unexpected situation in __imul__ !";
3148 typename MEDCoupling::Traits<T>::ArrayType *a;
3149 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3152 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3157 self->applyLin(val,0.);
3158 Py_XINCREF(trueSelf);
3163 self->multiplyEqual(a);
3164 Py_XINCREF(trueSelf);
3169 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3170 self->multiplyEqual(aaa);
3171 Py_XINCREF(trueSelf);
3176 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3177 self->multiplyEqual(aaa);
3178 Py_XINCREF(trueSelf);
3182 throw INTERP_KERNEL::Exception(msg);
3187 PyObject *DataArrayT_idiv__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3189 const char msg[]="Unexpected situation in __idiv__ !";
3191 typename MEDCoupling::Traits<T>::ArrayType *a;
3192 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3195 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3201 throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
3202 self->applyLin(1./val,0.);
3203 Py_XINCREF(trueSelf);
3208 self->divideEqual(a);
3209 Py_XINCREF(trueSelf);
3214 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3215 self->divideEqual(aaa);
3216 Py_XINCREF(trueSelf);
3221 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3222 self->divideEqual(aaa);
3223 Py_XINCREF(trueSelf);
3227 throw INTERP_KERNEL::Exception(msg);
3232 PyObject *DataArrayT_iadd__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3234 const char msg[]="Unexpected situation in __iadd__ !";
3236 typename MEDCoupling::Traits<T>::ArrayType *a;
3237 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3240 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3245 self->applyLin(1.,val);
3246 Py_XINCREF(trueSelf);
3252 Py_XINCREF(trueSelf);
3257 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3258 self->addEqual(aaa);
3259 Py_XINCREF(trueSelf);
3264 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3265 self->addEqual(aaa);
3266 Py_XINCREF(trueSelf);
3270 throw INTERP_KERNEL::Exception(msg);
3275 PyObject *DataArrayT_isub__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3277 const char msg[]="Unexpected situation in __isub__ !";
3279 typename MEDCoupling::Traits<T>::ArrayType *a;
3280 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3283 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3288 self->applyLin(1.,-val);
3289 Py_XINCREF(trueSelf);
3294 self->substractEqual(a);
3295 Py_XINCREF(trueSelf);
3300 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3301 self->substractEqual(aaa);
3302 Py_XINCREF(trueSelf);
3307 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3308 self->substractEqual(aaa);
3309 Py_XINCREF(trueSelf);
3313 throw INTERP_KERNEL::Exception(msg);
3322 struct SWIGTITraits<double>
3323 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3326 struct SWIGTITraits<float>
3327 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3330 struct SWIGTITraits<int>
3331 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3333 swig_type_info *SWIGTITraits<double>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
3334 swig_type_info *SWIGTITraits<float>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3335 swig_type_info *SWIGTITraits<int>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3336 swig_type_info *SWIGTITraits<double>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
3337 swig_type_info *SWIGTITraits<float>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3338 swig_type_info *SWIGTITraits<int>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3341 PyTypeObject *NPYTraits<double>::NPYFunc=&PyCallBackDataArrayDouble_RefType;
3343 PyTypeObject *NPYTraits<float>::NPYFunc=&PyCallBackDataArrayFloat_RefType;
3347 typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value)
3349 return DataArrayT__setitem__internal<T>(self,obj,value,SWIGTITraits<T>::TI);
3353 PyObject *DataArrayT__getitem(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj)
3355 return DataArrayT__getitem__internal<T>(self,obj,SWIGTITraits<T>::TI);
3359 PyObject *DataArrayT_imul(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3361 return DataArrayT_imul__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3365 PyObject *DataArrayT_idiv(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3367 return DataArrayT_idiv__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3371 PyObject *DataArrayT_iadd(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3373 return DataArrayT_iadd__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3377 PyObject *DataArrayT_isub(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3379 return DataArrayT_isub__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3383 typename MEDCoupling::Traits<T>::ArrayType *DataArrayFPT_rmul(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj)
3385 const char msg[]="Unexpected situation in __rmul__ !";
3387 typename MEDCoupling::Traits<T>::ArrayType *a;
3388 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3391 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3396 typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> ret(self->deepCopy());
3397 ret->applyLin(val,0.);
3402 typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> aaa(aa->buildDA(1,self->getNumberOfComponents()));
3403 return MEDCoupling::Traits<T>::ArrayType::Multiply(self,aaa);
3407 typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
3408 return MEDCoupling::Traits<T>::ArrayType::Multiply(self,aaa);
3411 throw INTERP_KERNEL::Exception(msg);