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 extension 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::DeallocType::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::DeallocType::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::DeallocType::C_DEALLOC_WITH_OFFSET,sz0,sz1);
203 PyObject *ref=PyWeakref_NewRef(reinterpret_cast<PyObject *>(eltOwning),NULL);
204 typename MEDCoupling::MemArray<T>::Deallocator tmp(MEDCoupling::MemArray<T>::COffsetDeallocator);
205 void **tmp2 = reinterpret_cast<void**>(&tmp); // MSVC2010 does not support constructor()
206 const char *dataEltOwning(PyArray_BYTES(eltOwning));//In case of input array is a sub array of a 2D,3D... array there is an offset
208 if(data!=dataEltOwning)
210 offset=data>dataEltOwning?-((int64_t)(std::distance(dataEltOwning,data))):(int64_t)std::distance(data,dataEltOwning);
212 void **objs=new void *[3]; objs[0]=ref; objs[1]=*tmp2; objs[2]=new int64_t(offset);
213 mma.setParameterForDeallocator(objs);
214 mma.setSpecificDeallocator(numarrdeal);
217 else if(PyArray_ISBEHAVED_RO(elt0))
218 ret->useArray(reinterpret_cast<const T *>(data),false,MEDCoupling::DeallocType::CPP_DEALLOC,sz0,sz1);
223 int NumpyArrSetBaseObjectExt(PyArrayObject *arr, PyObject *obj)
226 PyErr_SetString(PyExc_ValueError,
227 "Cannot set the NumPy array 'base' "
228 "dependency to NULL after initialization");
232 * Allow the base to be set only once. Once the object which
233 * owns the data is set, it doesn't make sense to change it.
235 if (PyArray_BASE(arr) != NULL) {
237 PyErr_SetString(PyExc_ValueError,
238 "Cannot set the NumPy array 'base' "
239 "dependency more than once");
244 * Don't allow infinite chains of views, always set the base
245 * to the first owner of the data.
246 * That is, either the first object which isn't an array,
247 * or the first object which owns its own data.
250 while (PyArray_Check(obj) && (PyObject *)arr != obj) {
251 PyArrayObject *obj_arr = (PyArrayObject *)obj;
255 /* If this array owns its own data, stop collapsing */
256 if (PyArray_CHKFLAGS(obj_arr, MED_NUMPY_OWNDATA )) {
260 tmp = PyArray_BASE(obj_arr);
261 /* If there's no base, stop collapsing */
265 /* Stop the collapse new base when the would not be of the same
266 * type (i.e. different subclass).
268 if (Py_TYPE(tmp) != Py_TYPE(arr)) {
278 /* Disallow circular references */
279 if ((PyObject *)arr == obj) {
281 PyErr_SetString(PyExc_ValueError,
282 "Cannot create a circular NumPy array 'base' dependency");
291 template<class MCData, class T>
292 PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, int nbTuples, int nbComp)
294 if(!self->isAllocated())
296 std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : this is not allocated !";
297 throw INTERP_KERNEL::Exception(oss.str().c_str());
299 MEDCoupling::MemArray<T>& mem=self->accessToMemArray();
302 std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : number of components of this is 0 ! Should be > 0 !";
303 throw INTERP_KERNEL::Exception(oss.str().c_str());
305 int nbDims=nbComp==1?1:2;
307 dim[0]=(npy_intp)nbTuples; dim[1]=nbComp;
308 const T *bg=self->getConstPointer();
309 PyObject *ret(PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast<T *>(bg)));
310 if(mem.isDeallocatorCalled())
312 if(mem.getDeallocator()!=numarrdeal)
313 {// case for the first call of toNumPyArray
314 PyObject *ref(PyWeakref_NewRef(ret,NULL));
315 typename MEDCoupling::MemArray<T>::Deallocator tmp(mem.getDeallocator());
316 void **tmp2 = reinterpret_cast<void**>(&tmp); // MSVC2010 does not support constructor()
317 void **objs=new void *[3]; objs[0]=reinterpret_cast<void*>(ref); objs[1]=*tmp2; objs[2]=new int64_t(0);
318 mem.setParameterForDeallocator(objs);
319 mem.setSpecificDeallocator(numarrdeal);
323 {// case for the second and other call of toNumPyArray
324 void **objs=(void **)mem.getParameterForDeallocator();
325 PyObject *weakRefOnOwner=(PyObject *)objs[0];
326 PyObject *obj=PyWeakref_GetObject(weakRefOnOwner);
328 {//the previous numArray exists let numpy deals the numpy array each other by declaring the still alive instance as base
330 NumpyArrSetBaseObjectExt((PyArrayObject*)ret,obj);
333 {//the previous numArray no more exists -> declare the newly created numpy array as the first one.
334 Py_XDECREF(weakRefOnOwner);
335 PyObject *ref=PyWeakref_NewRef(ret,NULL);
343 template<class MCData, class T>
344 PyObject *ToNumPyArray(MCData *self, int npyObjectType, const char *MCDataStr)
346 return ToNumPyArrayUnderground<MCData,T>(self,npyObjectType,MCDataStr,self->getNumberOfTuples(),self->getNumberOfComponents());
349 SWIGINTERN PyObject *MEDCoupling_DataArrayInt_toNumPyArray(MEDCoupling::DataArrayInt *self);
350 SWIGINTERN PyObject *MEDCoupling_DataArrayDouble_toNumPyArray(MEDCoupling::DataArrayDouble *self);
355 PyObject *ToCSRMatrix(const std::vector<std::map<int,double> >& m, int nbCols)
357 int nbRows((int)m.size());
358 MEDCoupling::MCAuto<MEDCoupling::DataArrayInt> indPtr(MEDCoupling::DataArrayInt::New()),indices(MEDCoupling::DataArrayInt::New());
359 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> data(MEDCoupling::DataArrayDouble::New());
360 indPtr->alloc(nbRows+1,1);
361 int *intPtr_ptr(indPtr->getPointer()); intPtr_ptr[0]=0; intPtr_ptr++;
363 for(std::vector<std::map<int,double> >::const_iterator it0=m.begin();it0!=m.end();it0++,intPtr_ptr++)
365 sz2+=(int)(*it0).size();
368 indices->alloc(sz2,1); data->alloc(sz2,1);
369 int *indices_ptr(indices->getPointer());
370 double *data_ptr(data->getPointer());
371 for(std::vector<std::map<int,double> >::const_iterator it0=m.begin();it0!=m.end();it0++)
372 for(std::map<int,double>::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++,indices_ptr++,data_ptr++)
374 *indices_ptr=(*it1).first;
375 *data_ptr=(*it1).second;
377 PyObject *a(MEDCoupling_DataArrayDouble_toNumPyArray(data)),*b(MEDCoupling_DataArrayInt_toNumPyArray(indices)),*c(MEDCoupling_DataArrayInt_toNumPyArray(indPtr));
379 PyObject *args(PyTuple_New(1)),*args0(PyTuple_New(3)),*kw(PyDict_New()),*kw1(PyTuple_New(2));
380 PyTuple_SetItem(args0,0,a); PyTuple_SetItem(args0,1,b); PyTuple_SetItem(args0,2,c); PyTuple_SetItem(args,0,args0);
381 PyTuple_SetItem(kw1,0,PyInt_FromLong(nbRows)); PyTuple_SetItem(kw1,1,PyInt_FromLong(nbCols));
382 PyObject *tmp1(PyString_FromString("shape"));
383 PyDict_SetItem(kw,tmp1,kw1); Py_DECREF(tmp1); Py_DECREF(kw1);
384 PyObject* pdict=PyDict_New();
385 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
386 PyObject *tmp(PyRun_String("from scipy.sparse import csr_matrix", Py_single_input, pdict, pdict));
388 throw INTERP_KERNEL::Exception("Problem during loading csr_matrix in scipy.sparse ! Is Scipy module available in present ?");
389 PyObject *csrMatrixCls=PyDict_GetItemString(pdict,"csr_matrix");
391 throw INTERP_KERNEL::Exception("csr_matrix not found in scipy.sparse ! Is Scipy module available in present ?");
392 PyObject *ret(PyObject_Call(csrMatrixCls,args,kw));
393 Py_DECREF(pdict); Py_XDECREF(tmp); Py_DECREF(args); Py_DECREF(kw);
399 static PyObject *convertDataArrayChar(MEDCoupling::DataArrayChar *dac, int owner)
407 if(dynamic_cast<MEDCoupling::DataArrayByte *>(dac))
408 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayByte,owner);
409 if(dynamic_cast<MEDCoupling::DataArrayAsciiChar *>(dac))
410 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,owner);
412 throw INTERP_KERNEL::Exception("Not recognized type of DataArrayChar on downcast !");
416 static PyObject *convertDataArray(MEDCoupling::DataArray *dac, int owner)
424 if(dynamic_cast<MEDCoupling::DataArrayDouble *>(dac))
425 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayDouble,owner);
426 if(dynamic_cast<MEDCoupling::DataArrayInt *>(dac))
427 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayInt,owner);
428 if(dynamic_cast<MEDCoupling::DataArrayFloat *>(dac))
429 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayFloat,owner);
430 if(dynamic_cast<MEDCoupling::DataArrayByte *>(dac))
431 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayByte,owner);
432 if(dynamic_cast<MEDCoupling::DataArrayAsciiChar *>(dac))
433 ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,owner);
435 throw INTERP_KERNEL::Exception("Not recognized type of DataArray on downcast !");
439 static PyObject *convertIntArrToPyList(const int *ptr, int size)
441 PyObject *ret=PyList_New(size);
442 for(int i=0;i<size;i++)
443 PyList_SetItem(ret,i,PyInt_FromLong(ptr[i]));
447 static PyObject *convertIntArrToPyList2(const std::vector<int>& v)
450 PyObject *ret=PyList_New(size);
451 for(int i=0;i<size;i++)
452 PyList_SetItem(ret,i,PyInt_FromLong(v[i]));
456 static PyObject *convertIntArrToPyList3(const std::set<int>& v)
459 PyObject *ret=PyList_New(size);
460 std::set<int>::const_iterator it=v.begin();
461 for(int i=0;i<size;i++,it++)
462 PyList_SetItem(ret,i,PyInt_FromLong(*it));
466 static bool convertPyObjectToStrNT(PyObject *obj, std::string& ret)
468 if(PyString_Check(obj))
470 ret=PyString_AsString(obj);
473 #if PY_VERSION_HEX >= 0x03000000
474 else if(PyUnicode_Check(obj))
476 ret=PyUnicode_AsUTF8(obj);
483 static std::string convertPyObjectToStr(PyObject *obj, const char *msg=NULL)
486 if(PyString_Check(obj))
487 ret=PyString_AsString(obj);
488 #if PY_VERSION_HEX >= 0x03000000
489 else if(PyUnicode_Check(obj))
490 ret=PyUnicode_AsUTF8(obj);
494 std::ostringstream oss;
498 oss << "PyWrap convertPyObjectToStr : expect a string like py object !";
499 throw INTERP_KERNEL::Exception(oss.str());
504 static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples)
506 PyObject *ret=PyList_New(nbOfTuples);
507 for(int i=0;i<nbOfTuples;i++)
509 PyObject *t=PyTuple_New(nbOfComp);
510 for(int j=0;j<nbOfComp;j++)
511 PyTuple_SetItem(t,j,PyInt_FromLong(vals[i*nbOfComp+j]));
512 PyList_SetItem(ret,i,t);
517 static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
519 if(PyList_Check(pyLi))
521 *size=PyList_Size(pyLi);
522 int *tmp=new int[*size];
523 for(int i=0;i<*size;i++)
525 PyObject *o=PyList_GetItem(pyLi,i);
528 int val=(int)PyInt_AS_LONG(o);
534 throw INTERP_KERNEL::Exception("list must contain integers only");
539 else if(PyTuple_Check(pyLi))
541 *size=PyTuple_Size(pyLi);
542 int *tmp=new int[*size];
543 for(int i=0;i<*size;i++)
545 PyObject *o=PyTuple_GetItem(pyLi,i);
548 int val=(int)PyInt_AS_LONG(o);
554 throw INTERP_KERNEL::Exception("tuple must contain integers only");
561 throw INTERP_KERNEL::Exception("convertPyToNewIntArr2 : not a list");
565 static PyObject *convertFromVectorPairInt(const std::vector< std::pair<int,int> >& arr)
567 PyObject *ret=PyList_New(arr.size());
568 for(std::size_t i=0;i<arr.size();i++)
570 PyObject *t=PyTuple_New(2);
571 PyTuple_SetItem(t,0,PyInt_FromLong(arr[i].first));
572 PyTuple_SetItem(t,1,PyInt_FromLong(arr[i].second));
573 PyList_SetItem(ret,i,t);
578 static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair<int,int> >& arr)
580 const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !";
581 if(PyList_Check(pyLi))
583 int size=PyList_Size(pyLi);
585 for(int i=0;i<size;i++)
587 PyObject *o=PyList_GetItem(pyLi,i);
590 int sz2=PyTuple_Size(o);
592 throw INTERP_KERNEL::Exception(msg);
593 PyObject *o_0=PyTuple_GetItem(o,0);
594 if(!PyInt_Check(o_0))
595 throw INTERP_KERNEL::Exception(msg);
596 PyObject *o_1=PyTuple_GetItem(o,1);
597 if(!PyInt_Check(o_1))
598 throw INTERP_KERNEL::Exception(msg);
599 arr[i].first=(int)PyInt_AS_LONG(o_0);
600 arr[i].second=(int)PyInt_AS_LONG(o_1);
603 throw INTERP_KERNEL::Exception(msg);
606 else if(PyTuple_Check(pyLi))
608 int size=PyTuple_Size(pyLi);
610 for(int i=0;i<size;i++)
612 PyObject *o=PyTuple_GetItem(pyLi,i);
615 int sz2=PyTuple_Size(o);
617 throw INTERP_KERNEL::Exception(msg);
618 PyObject *o_0=PyTuple_GetItem(o,0);
619 if(!PyInt_Check(o_0))
620 throw INTERP_KERNEL::Exception(msg);
621 PyObject *o_1=PyTuple_GetItem(o,1);
622 if(!PyInt_Check(o_1))
623 throw INTERP_KERNEL::Exception(msg);
624 arr[i].first=(int)PyInt_AS_LONG(o_0);
625 arr[i].second=(int)PyInt_AS_LONG(o_1);
628 throw INTERP_KERNEL::Exception(msg);
632 throw INTERP_KERNEL::Exception(msg);
635 static void convertPyToVectorPairStringInt(PyObject *pyLi, std::vector< std::pair<std::string,int> >& arr)
637 const char msg[]="convertPyToVectorPairStringInt : list must contain tuples of 2 integers only or tuple must contain tuples of 1 string and 1 integer only !";
638 if(PyList_Check(pyLi))
640 int size=PyList_Size(pyLi);
642 for(int i=0;i<size;i++)
644 PyObject *o=PyList_GetItem(pyLi,i);
647 int sz2=PyTuple_Size(o);
649 throw INTERP_KERNEL::Exception(msg);
650 PyObject *o_0=PyTuple_GetItem(o,0);
651 PyObject *o_1=PyTuple_GetItem(o,1);
652 arr[i].first=convertPyObjectToStr(o_0,msg);
653 if(!PyInt_Check(o_1))
654 throw INTERP_KERNEL::Exception(msg);
655 arr[i].second=(int)PyInt_AS_LONG(o_1);
658 throw INTERP_KERNEL::Exception(msg);
661 else if(PyTuple_Check(pyLi))
663 int size=PyTuple_Size(pyLi);
665 for(int i=0;i<size;i++)
667 PyObject *o=PyTuple_GetItem(pyLi,i);
670 int sz2=PyTuple_Size(o);
672 throw INTERP_KERNEL::Exception(msg);
673 PyObject *o_0=PyTuple_GetItem(o,0);
674 PyObject *o_1=PyTuple_GetItem(o,1);
675 arr[i].first=convertPyObjectToStr(o_0,msg);
676 if(!PyInt_Check(o_1))
677 throw INTERP_KERNEL::Exception(msg);
678 arr[i].second=(int)PyInt_AS_LONG(o_1);
681 throw INTERP_KERNEL::Exception(msg);
685 throw INTERP_KERNEL::Exception(msg);
688 static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
690 if(PyList_Check(pyLi))
692 int size=PyList_Size(pyLi);
694 for(int i=0;i<size;i++)
696 PyObject *o=PyList_GetItem(pyLi,i);
699 int val=(int)PyInt_AS_LONG(o);
703 throw INTERP_KERNEL::Exception("list must contain integers only");
706 else if(PyTuple_Check(pyLi))
708 int size=PyTuple_Size(pyLi);
710 for(int i=0;i<size;i++)
712 PyObject *o=PyTuple_GetItem(pyLi,i);
715 int val=(int)PyInt_AS_LONG(o);
719 throw INTERP_KERNEL::Exception("tuple must contain integers only");
724 throw INTERP_KERNEL::Exception("convertPyToNewIntArr3 : not a list nor a tuple");
728 static void convertPyToNewIntArr4(PyObject *pyLi, int recurseLev, int nbOfSubPart, std::vector<int>& arr)
731 throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : invalid list of integers level of recursion !");
733 if(PyList_Check(pyLi))
735 int size=PyList_Size(pyLi);
736 for(int i=0;i<size;i++)
738 PyObject *o=PyList_GetItem(pyLi,i);
741 int val=(int)PyInt_AS_LONG(o);
746 std::vector<int> arr2;
747 convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
748 if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
750 std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " << recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
751 throw INTERP_KERNEL::Exception(oss.str().c_str());
753 arr.insert(arr.end(),arr2.begin(),arr2.end());
757 else if(PyTuple_Check(pyLi))
759 int size=PyTuple_Size(pyLi);
760 for(int i=0;i<size;i++)
762 PyObject *o=PyTuple_GetItem(pyLi,i);
765 int val=(int)PyInt_AS_LONG(o);
770 std::vector<int> arr2;
771 convertPyToNewIntArr4(o,recurseLev-1,nbOfSubPart,arr2);
772 if(nbOfSubPart>=1 && nbOfSubPart!=(int)arr2.size())
774 std::ostringstream oss; oss << "convertPyToNewIntArr4 : input list at lev " << recurseLev << " invalid nb of subpart elts expected " << nbOfSubPart << " having " << arr2.size() << " !";
775 throw INTERP_KERNEL::Exception(oss.str().c_str());
777 arr.insert(arr.end(),arr2.begin(),arr2.end());
782 throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : not a list nor a tuple recursively !");
785 static void checkFillArrayWithPyList(int size1, int size2, int& nbOfTuples, int& nbOfComp)
789 if(nbOfComp==-1) { nbOfTuples=size1; nbOfComp=size2; }
790 else { if(nbOfComp==size2) { nbOfTuples=size1; } else
792 std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
793 oss << " whereas nb of components expected is " << nbOfComp << " !";
794 throw INTERP_KERNEL::Exception(oss.str().c_str());
801 if((nbOfTuples!=size1 || nbOfComp!=size2))
803 if(size2!=1 || size1!=nbOfComp*nbOfTuples)
805 std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
806 oss << " whereas nb of tuples expected is " << nbOfTuples << " and number of components expected is " << nbOfComp << " !";
807 throw INTERP_KERNEL::Exception(oss.str().c_str());
813 if(nbOfTuples==size1)
817 std::ostringstream oss; oss << "fillArrayWithPyListDbl2 : mismatch between nb of elemts : Input has " << size1 << " tuples and " << size2 << " components";
818 oss << " whereas nb of tuples expected is " << nbOfTuples << " !";
819 throw INTERP_KERNEL::Exception(oss.str().c_str());
825 static void fillArrayWithPyListInt3(PyObject *pyLi, int& nbOfElt, std::vector<int>& ret)
827 static const char MSG[]="fillArrayWithPyListInt3 : It appears that the input list or tuple is composed by elts having different sizes !";
828 if(PyInt_Check(pyLi))
830 long val=PyInt_AS_LONG(pyLi);
835 throw INTERP_KERNEL::Exception(MSG);
838 else if(PyList_Check(pyLi))
840 int size=PyList_Size(pyLi);
842 for(int i=0;i<size;i++)
844 PyObject *o=PyList_GetItem(pyLi,i);
846 fillArrayWithPyListInt3(o,tmp1,ret);
854 throw INTERP_KERNEL::Exception(MSG);
857 else if(PyTuple_Check(pyLi))
859 int size=PyTuple_Size(pyLi);
861 for(int i=0;i<size;i++)
863 PyObject *o=PyTuple_GetItem(pyLi,i);
865 fillArrayWithPyListInt3(o,tmp1,ret);
873 throw INTERP_KERNEL::Exception(MSG);
877 throw INTERP_KERNEL::Exception("fillArrayWithPyListInt3 : Unrecognized type ! Should be a composition of tuple,list,int !");
880 static std::vector<int> fillArrayWithPyListInt2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp)
882 std::vector<int> ret;
883 int size1=-1,size2=-1;
884 if(PyList_Check(pyLi))
886 size1=PyList_Size(pyLi);
887 for(int i=0;i<size1;i++)
889 PyObject *o=PyList_GetItem(pyLi,i);
890 fillArrayWithPyListInt3(o,size2,ret);
895 else if(PyTuple_Check(pyLi))
897 size1=PyTuple_Size(pyLi);
898 for(int i=0;i<size1;i++)
900 PyObject *o=PyTuple_GetItem(pyLi,i);
901 fillArrayWithPyListInt3(o,size2,ret);
907 throw INTERP_KERNEL::Exception("fillArrayWithPyListInt2 : Unrecognized type ! Should be a tuple or a list !");
909 checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
913 static bool fillStringVector(PyObject *pyLi, std::vector<std::string>& vec)
915 if(PyList_Check(pyLi))
917 Py_ssize_t sz=PyList_Size(pyLi);
919 for(int i=0;i<sz;i++)
921 PyObject *o=PyList_GetItem(pyLi,i);
922 if(!convertPyObjectToStrNT(o,vec[i]))
927 else if(PyTuple_Check(pyLi))
929 Py_ssize_t sz=PyTuple_Size(pyLi);
931 for(int i=0;i<sz;i++)
933 PyObject *o=PyTuple_GetItem(pyLi,i);
934 if(!convertPyObjectToStrNT(o,vec[i]))
942 static void convertPyToVectorOfVectorOfString(PyObject *pyLi, std::vector< std::vector<std::string> >& arr)
944 const char msg[]="convertPyToVectorOfVectorOfString : expecting list of list of strings !";
945 if(PyList_Check(pyLi))
947 Py_ssize_t sz=PyList_Size(pyLi);
949 for(int i=0;i<sz;i++)
951 PyObject *o=PyList_GetItem(pyLi,i);
952 if(!fillStringVector(o,arr[i]))
953 throw INTERP_KERNEL::Exception(msg);
956 else if(PyTuple_Check(pyLi))
958 Py_ssize_t sz=PyTuple_Size(pyLi);
960 for(int i=0;i<sz;i++)
962 PyObject *o=PyTuple_GetItem(pyLi,i);
963 if(!fillStringVector(o,arr[i]))
964 throw INTERP_KERNEL::Exception(msg);
968 throw INTERP_KERNEL::Exception(msg);
971 static bool fillIntVector(PyObject *pyLi, std::vector<int>& vec)
973 if(PyList_Check(pyLi))
975 Py_ssize_t sz=PyList_Size(pyLi);
977 for(int i=0;i<sz;i++)
979 PyObject *o=PyList_GetItem(pyLi,i);
981 vec[i]=PyInt_AS_LONG(o);
987 else if(PyTuple_Check(pyLi))
989 Py_ssize_t sz=PyTuple_Size(pyLi);
991 for(int i=0;i<sz;i++)
993 PyObject *o=PyTuple_GetItem(pyLi,i);
995 vec[i]=PyInt_AS_LONG(o);
1005 static void convertPyToVectorOfVectorOfInt(PyObject *pyLi, std::vector< std::vector<int> >& arr)
1007 const char msg[]="convertPyToVectorOfVectorOfInt : expecting list of list of strings !";
1008 if(PyList_Check(pyLi))
1010 Py_ssize_t sz=PyList_Size(pyLi);
1012 for(int i=0;i<sz;i++)
1014 PyObject *o=PyList_GetItem(pyLi,i);
1015 if(!fillIntVector(o,arr[i]))
1016 throw INTERP_KERNEL::Exception(msg);
1019 else if(PyTuple_Check(pyLi))
1021 Py_ssize_t sz=PyTuple_Size(pyLi);
1023 for(int i=0;i<sz;i++)
1025 PyObject *o=PyTuple_GetItem(pyLi,i);
1026 if(!fillIntVector(o,arr[i]))
1027 throw INTERP_KERNEL::Exception(msg);
1031 throw INTERP_KERNEL::Exception(msg);
1034 static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< std::pair<std::string, std::vector<std::string> > >& arr)
1036 const char msg[]="convertPyToVectorPairStringVecString : expecting list of tuples containing each exactly 2 items : one string and one vector of string !";
1037 if(PyList_Check(pyLi))
1039 Py_ssize_t sz=PyList_Size(pyLi);
1041 for(int i=0;i<sz;i++)
1043 PyObject *o=PyList_GetItem(pyLi,i);
1044 if(PyTuple_Check(o))
1046 int sz2=PyTuple_Size(o);
1048 throw INTERP_KERNEL::Exception(msg);
1049 std::pair<std::string, std::vector<std::string> > item;
1050 PyObject *o_0=PyTuple_GetItem(o,0);
1051 item.first=convertPyObjectToStr(o_0,msg);
1052 PyObject *o_1=PyTuple_GetItem(o,1);
1053 if(!fillStringVector(o_1,item.second))
1054 throw INTERP_KERNEL::Exception(msg);
1058 throw INTERP_KERNEL::Exception(msg);
1061 else if(PyTuple_Check(pyLi))
1063 Py_ssize_t sz=PyTuple_Size(pyLi);
1065 for(int i=0;i<sz;i++)
1067 PyObject *o=PyTuple_GetItem(pyLi,i);
1068 if(PyTuple_Check(o))
1070 int sz2=PyTuple_Size(o);
1072 throw INTERP_KERNEL::Exception(msg);
1073 std::pair<std::string, std::vector<std::string> > item;
1074 PyObject *o_0=PyTuple_GetItem(o,0);
1075 item.first=convertPyObjectToStr(o_0,msg);
1076 PyObject *o_1=PyTuple_GetItem(o,1);
1077 if(!fillStringVector(o_1,item.second))
1078 throw INTERP_KERNEL::Exception(msg);
1082 throw INTERP_KERNEL::Exception(msg);
1086 throw INTERP_KERNEL::Exception(msg);
1090 PyObject *convertDblArrToPyList(const T *ptr, int size)
1092 PyObject *ret(PyList_New(size));
1093 for(int i=0;i<size;i++)
1094 PyList_SetItem(ret,i,PyFloat_FromDouble(ptr[i]));
1098 static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
1101 PyObject *ret(PyList_New(size));
1102 for(int i=0;i<size;i++)
1103 PyList_SetItem(ret,i,PyFloat_FromDouble(v[i]));
1108 PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, int nbOfTuples)
1110 PyObject *ret(PyList_New(nbOfTuples));
1111 for(int i=0;i<nbOfTuples;i++)
1113 PyObject *t=PyTuple_New(nbOfComp);
1114 for(int j=0;j<nbOfComp;j++)
1115 PyTuple_SetItem(t,j,PyFloat_FromDouble(vals[i*nbOfComp+j]));
1116 PyList_SetItem(ret,i,t);
1121 static PyObject *convertCharArrToPyListOfTuple(const char *vals, int nbOfComp, int nbOfTuples)
1123 PyObject *ret=PyList_New(nbOfTuples);
1124 INTERP_KERNEL::AutoPtr<char> tmp=new char[nbOfComp+1]; tmp[nbOfComp]='\0';
1125 for(int i=0;i<nbOfTuples;i++)
1127 std::copy(vals+i*nbOfComp,vals+(i+1)*nbOfComp,(char *)tmp);
1128 PyList_SetItem(ret,i,PyString_FromString(tmp));
1133 static double *convertPyToNewDblArr2(PyObject *pyLi, int *size)
1135 if(PyList_Check(pyLi))
1137 *size=PyList_Size(pyLi);
1138 double *tmp=(double *)malloc((*size)*sizeof(double));
1139 for(int i=0;i<*size;i++)
1141 PyObject *o=PyList_GetItem(pyLi,i);
1142 if(PyFloat_Check(o))
1144 double val=PyFloat_AS_DOUBLE(o);
1147 else if(PyInt_Check(o))
1149 long val0=PyInt_AS_LONG(o);
1156 throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : list must contain floats/integers only");
1161 else if(PyTuple_Check(pyLi))
1163 *size=PyTuple_Size(pyLi);
1164 double *tmp=(double *)malloc((*size)*sizeof(double));
1165 for(int i=0;i<*size;i++)
1167 PyObject *o=PyTuple_GetItem(pyLi,i);
1168 if(PyFloat_Check(o))
1170 double val=PyFloat_AS_DOUBLE(o);
1173 else if(PyInt_Check(o))
1175 long val0=PyInt_AS_LONG(o);
1182 throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : tuple must contain floats/integers only");
1188 throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : not a list");
1191 static void fillArrayWithPyListDbl3(PyObject *pyLi, int& nbOfElt, std::vector<double>& ret)
1193 static const char MSG[]="fillArrayWithPyListDbl3 : It appears that the input list or tuple is composed by elts having different sizes !";
1194 if(PyFloat_Check(pyLi))
1200 throw INTERP_KERNEL::Exception(MSG);
1201 double val=PyFloat_AS_DOUBLE(pyLi);
1204 else if(PyInt_Check(pyLi))
1206 long val0=PyInt_AS_LONG(pyLi);
1212 throw INTERP_KERNEL::Exception(MSG);
1215 else if(PyList_Check(pyLi))
1217 int size=PyList_Size(pyLi);
1219 for(int i=0;i<size;i++)
1221 PyObject *o=PyList_GetItem(pyLi,i);
1223 fillArrayWithPyListDbl3(o,tmp1,ret);
1231 throw INTERP_KERNEL::Exception(MSG);
1234 else if(PyTuple_Check(pyLi))
1236 int size=PyTuple_Size(pyLi);
1238 for(int i=0;i<size;i++)
1240 PyObject *o=PyTuple_GetItem(pyLi,i);
1242 fillArrayWithPyListDbl3(o,tmp1,ret);
1250 throw INTERP_KERNEL::Exception(MSG);
1254 throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl3 : Unrecognized type ! Should be a composition of tuple,list,int and float !");
1257 static std::vector<double> fillArrayWithPyListDbl2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp)
1259 std::vector<double> ret;
1260 int size1=-1,size2=-1;
1261 if(PyList_Check(pyLi))
1263 size1=PyList_Size(pyLi);
1264 for(int i=0;i<size1;i++)
1266 PyObject *o=PyList_GetItem(pyLi,i);
1267 fillArrayWithPyListDbl3(o,size2,ret);
1272 else if(PyTuple_Check(pyLi))
1274 size1=PyTuple_Size(pyLi);
1275 for(int i=0;i<size1;i++)
1277 PyObject *o=PyTuple_GetItem(pyLi,i);
1278 fillArrayWithPyListDbl3(o,size2,ret);
1284 throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !");
1286 checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
1290 //convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingUMesh *>(pyLi,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh")
1292 static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, const char *typeStr, typename std::vector<T>& ret)
1295 if(PyList_Check(pyLi))
1297 int size=PyList_Size(pyLi);
1299 for(int i=0;i<size;i++)
1301 PyObject *obj=PyList_GetItem(pyLi,i);
1302 int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
1303 if(!SWIG_IsOK(status))
1305 std::ostringstream oss; oss << "convertFromPyObjVectorOfObj : list is excepted to contain only " << typeStr << " instances !";
1306 throw INTERP_KERNEL::Exception(oss.str().c_str());
1308 T arg=reinterpret_cast< T >(argp);
1312 else if(PyTuple_Check(pyLi))
1314 int size=PyTuple_Size(pyLi);
1316 for(int i=0;i<size;i++)
1318 PyObject *obj=PyTuple_GetItem(pyLi,i);
1319 int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
1320 if(!SWIG_IsOK(status))
1322 std::ostringstream oss; oss << "convertFromPyObjVectorOfObj : tuple is excepted to contain only " << typeStr << " instances !";
1323 throw INTERP_KERNEL::Exception(oss.str().c_str());
1325 T arg=reinterpret_cast< T >(argp);
1329 else if(SWIG_IsOK(SWIG_ConvertPtr(pyLi,&argp,ty,0|0)))
1332 T arg=reinterpret_cast< T >(argp);
1336 throw INTERP_KERNEL::Exception("convertFromPyObjVectorOfObj : not a list nor a tuple");
1340 * if python int -> cpp int sw=1
1341 * if python list[int] -> cpp vector<int> sw=2
1342 * if python tuple[int] -> cpp vector<int> sw=2
1343 * if python DataArrayInt -> cpp DataArrayInt sw=3
1344 * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
1346 * switch between (int,vector<int>,DataArrayInt)
1348 static void convertIntStarLikePyObjToCpp(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple)
1351 if(PyInt_Check(value))
1353 iTyypp=(int)PyInt_AS_LONG(value);
1357 if(PyTuple_Check(value))
1359 int size=PyTuple_Size(value);
1360 stdvecTyypp.resize(size);
1361 for(int i=0;i<size;i++)
1363 PyObject *o=PyTuple_GetItem(value,i);
1365 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1368 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1369 throw INTERP_KERNEL::Exception(oss.str().c_str());
1375 if(PyList_Check(value))
1377 int size=PyList_Size(value);
1378 stdvecTyypp.resize(size);
1379 for(int i=0;i<size;i++)
1381 PyObject *o=PyList_GetItem(value,i);
1383 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1386 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1387 throw INTERP_KERNEL::Exception(oss.str().c_str());
1394 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1395 if(SWIG_IsOK(status))
1397 daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1401 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1402 if(SWIG_IsOK(status))
1404 daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1408 throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
1412 * if python int -> cpp int sw=1
1413 * if python list[int] -> cpp vector<int> sw=2
1414 * if python tuple[int] -> cpp vector<int> sw=2
1415 * if python DataArrayInt -> cpp DataArrayInt sw=3
1416 * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
1418 * switch between (int,vector<int>,DataArrayInt)
1420 static const int *convertIntStarLikePyObjToCppIntStar(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector<int>& stdvecTyypp)
1423 if(PyInt_Check(value))
1425 iTyypp=(int)PyInt_AS_LONG(value);
1429 if(PyTuple_Check(value))
1431 int size=PyTuple_Size(value);
1432 stdvecTyypp.resize(size);
1433 for(int i=0;i<size;i++)
1435 PyObject *o=PyTuple_GetItem(value,i);
1437 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1440 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1441 throw INTERP_KERNEL::Exception(oss.str().c_str());
1445 return &stdvecTyypp[0];
1447 if(PyList_Check(value))
1449 int size=PyList_Size(value);
1450 stdvecTyypp.resize(size);
1451 for(int i=0;i<size;i++)
1453 PyObject *o=PyList_GetItem(value,i);
1455 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1458 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1459 throw INTERP_KERNEL::Exception(oss.str().c_str());
1463 return &stdvecTyypp[0];
1466 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1467 if(SWIG_IsOK(status))
1469 MEDCoupling::DataArrayInt *daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1472 sw=3; sz=daIntTyypp->getNbOfElems();
1473 return daIntTyypp->begin();
1481 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1482 if(SWIG_IsOK(status))
1484 MEDCoupling::DataArrayIntTuple *daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1485 sw=4; sz=daIntTuple->getNumberOfCompo();
1486 return daIntTuple->getConstPointer();
1488 throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
1492 * if python double -> cpp double sw=1
1493 * if python int -> cpp double sw=1
1494 * if python list[double] -> cpp vector<double> sw=2
1495 * if python list[int] -> cpp vector<double> sw=2
1496 * if python tuple[double] -> cpp vector<double> sw=2
1497 * if python tuple[int] -> cpp vector<double> sw=2
1498 * if python DataArrayDouble -> cpp DataArrayDouble sw=3
1500 * switch between (int,vector<int>,DataArrayInt)
1503 void considerPyObjAsATStarLikeObject(PyObject *value, int& sw, T& iTyypp, std::vector<T>& stdvecTyypp, typename MEDCoupling::Traits<T>::ArrayType *& daIntTyypp, swig_type_info *ti)
1506 if(PyFloat_Check(value))
1508 iTyypp=(T)PyFloat_AS_DOUBLE(value);
1512 if(PyInt_Check(value))
1514 iTyypp=(T)PyInt_AS_LONG(value);
1518 if(PyTuple_Check(value))
1520 int size=PyTuple_Size(value);
1521 stdvecTyypp.resize(size);
1522 for(int i=0;i<size;i++)
1524 PyObject *o=PyTuple_GetItem(value,i);
1525 if(PyFloat_Check(o))
1526 stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
1527 else if(PyInt_Check(o))
1528 stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
1531 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1532 throw INTERP_KERNEL::Exception(oss.str().c_str());
1538 if(PyList_Check(value))
1540 int size=PyList_Size(value);
1541 stdvecTyypp.resize(size);
1542 for(int i=0;i<size;i++)
1544 PyObject *o=PyList_GetItem(value,i);
1545 if(PyFloat_Check(o))
1546 stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
1547 else if(PyInt_Check(o))
1548 stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
1551 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1552 throw INTERP_KERNEL::Exception(oss.str().c_str());
1559 int status=SWIG_ConvertPtr(value,&argp,ti,0|0);
1560 if(!SWIG_IsOK(status))
1561 throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
1562 daIntTyypp=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayType * >(argp);
1567 * if python double -> cpp double sw=1
1568 * if python int -> cpp double sw=1
1569 * if python list[double] -> cpp vector<double> sw=2
1570 * if python list[int] -> cpp vector<double> sw=2
1571 * if python tuple[double] -> cpp vector<double> sw=2
1572 * if python tuple[int] -> cpp vector<double> sw=2
1573 * if python DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1575 * switch between (int,vector<int>,DataArrayInt)
1577 static void convertDoubleStarLikePyObjToCpp(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, MEDCoupling::DataArrayDoubleTuple *& daIntTyypp)
1580 if(PyFloat_Check(value))
1582 iTyypp=PyFloat_AS_DOUBLE(value);
1586 if(PyInt_Check(value))
1588 iTyypp=(double)PyInt_AS_LONG(value);
1592 if(PyTuple_Check(value))
1594 int size=PyTuple_Size(value);
1595 stdvecTyypp.resize(size);
1596 for(int i=0;i<size;i++)
1598 PyObject *o=PyTuple_GetItem(value,i);
1599 if(PyFloat_Check(o))
1600 stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1601 else if(PyInt_Check(o))
1602 stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1605 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1606 throw INTERP_KERNEL::Exception(oss.str().c_str());
1612 if(PyList_Check(value))
1614 int size=PyList_Size(value);
1615 stdvecTyypp.resize(size);
1616 for(int i=0;i<size;i++)
1618 PyObject *o=PyList_GetItem(value,i);
1619 if(PyFloat_Check(o))
1620 stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
1621 else if(PyInt_Check(o))
1622 stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
1625 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1626 throw INTERP_KERNEL::Exception(oss.str().c_str());
1633 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
1634 if(!SWIG_IsOK(status))
1635 throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDoubleTuple");
1636 daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
1641 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)
1644 if(PyFloat_Check(value))
1646 val=PyFloat_AS_DOUBLE(value);
1650 if(PyInt_Check(value))
1652 val=(T)PyInt_AS_LONG(value);
1656 if(PyTuple_Check(value))
1658 int size=PyTuple_Size(value);
1660 for(int i=0;i<size;i++)
1662 PyObject *o=PyTuple_GetItem(value,i);
1663 if(PyFloat_Check(o))
1664 f[i]=PyFloat_AS_DOUBLE(o);
1665 else if(PyInt_Check(o))
1666 f[i]=(T)PyInt_AS_LONG(o);
1669 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
1670 throw INTERP_KERNEL::Exception(oss.str().c_str());
1676 if(PyList_Check(value))
1678 int size=PyList_Size(value);
1680 for(int i=0;i<size;i++)
1682 PyObject *o=PyList_GetItem(value,i);
1683 if(PyFloat_Check(o))
1684 f[i]=PyFloat_AS_DOUBLE(o);
1685 else if(PyInt_Check(o))
1686 f[i]=(T)PyInt_AS_LONG(o);
1689 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
1690 throw INTERP_KERNEL::Exception(oss.str().c_str());
1697 int status=SWIG_ConvertPtr(value,&argp,ti_da,0|0);
1698 if(SWIG_IsOK(status))
1700 d=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayType * >(argp);
1704 status=SWIG_ConvertPtr(value,&argp,ti_tuple,0|0);
1705 if(SWIG_IsOK(status))
1707 e=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayTuple * >(argp);
1711 throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
1715 * if value int -> cpp val sw=1
1716 * if value double -> cpp val sw=1
1717 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1718 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1719 * if value list[int,double] -> cpp std::vector<double> sw=4
1720 * if value tuple[int,double] -> cpp std::vector<double> sw=4
1722 static void convertDoubleStarLikePyObjToCpp_2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f)
1724 convertFPStarLikePyObjToCpp_2<double>(value,sw,val,d,e,f,SWIGTYPE_p_MEDCoupling__DataArrayDouble,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple);
1728 * if value int -> cpp val sw=1
1729 * if value double -> cpp val sw=1
1730 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
1731 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
1732 * if value list[int,double] -> cpp std::vector<double> sw=4
1733 * if value tuple[int,double] -> cpp std::vector<double> sw=4
1735 static void convertFloatStarLikePyObjToCpp_2(PyObject *value, int& sw, float& val, MEDCoupling::DataArrayFloat *&d, MEDCoupling::DataArrayFloatTuple *&e, std::vector<float>& f)
1737 convertFPStarLikePyObjToCpp_2<float>(value,sw,val,d,e,f,SWIGTYPE_p_MEDCoupling__DataArrayFloat,SWIGTYPE_p_MEDCoupling__DataArrayFloatTuple);
1741 * if python int -> cpp int sw=1
1742 * if python list[int] -> cpp vector<int> sw=2
1743 * if python tuple[int] -> cpp vector<int> sw=2
1744 * if python slicp -> cpp pair sw=3 (begin,end,step)
1745 * if python DataArrayInt -> cpp DataArrayInt sw=4 . The returned pointer cannot be the null pointer ! If null an exception is thrown.
1747 * switch between (int,vector<int>,DataArrayInt)
1749 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)
1751 const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple";
1753 if(PyInt_Check(value))
1755 iTyypp=(int)PyInt_AS_LONG(value);
1759 if(PyTuple_Check(value))
1761 int size=PyTuple_Size(value);
1762 stdvecTyypp.resize(size);
1763 for(int i=0;i<size;i++)
1765 PyObject *o=PyTuple_GetItem(value,i);
1767 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1770 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1771 throw INTERP_KERNEL::Exception(oss.str().c_str());
1777 if(PyList_Check(value))
1779 int size=PyList_Size(value);
1780 stdvecTyypp.resize(size);
1781 for(int i=0;i<size;i++)
1783 PyObject *o=PyList_GetItem(value,i);
1785 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1788 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1789 throw INTERP_KERNEL::Exception(oss.str().c_str());
1795 if(PySlice_Check(value))
1797 Py_ssize_t strt=2,stp=2,step=2;
1798 GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
1801 p.second.second=step;
1806 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
1807 if(SWIG_IsOK(status))
1809 daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
1812 std::ostringstream oss; oss << msg << " Instance in null !";
1813 throw INTERP_KERNEL::Exception(oss.str().c_str());
1818 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1819 if(SWIG_IsOK(status))
1821 MEDCoupling::DataArrayIntTuple *tmp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1824 std::ostringstream oss; oss << msg << " Instance in null !";
1825 throw INTERP_KERNEL::Exception(oss.str().c_str());
1827 stdvecTyypp.resize(tmp->getNumberOfCompo());
1828 std::copy(tmp->getConstPointer(),tmp->getConstPointer()+tmp->getNumberOfCompo(),stdvecTyypp.begin());
1832 throw INTERP_KERNEL::Exception(msg);
1836 * Idem than convertIntStarOrSliceLikePyObjToCpp
1838 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)
1840 convertIntStarOrSliceLikePyObjToCpp(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
1843 iTyypp=InterpreteNegativeInt(iTyypp,nbelem);
1848 * if python int -> cpp int sw=1
1849 * if python tuple[int] -> cpp vector<int> sw=2
1850 * if python list[int] -> cpp vector<int> sw=2
1851 * if python slice -> cpp pair sw=3
1852 * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 . WARNING The returned pointer can be the null pointer !
1854 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)
1857 if(PyInt_Check(value))
1859 iTyypp=(int)PyInt_AS_LONG(value);
1863 if(PyTuple_Check(value))
1865 int size=PyTuple_Size(value);
1866 stdvecTyypp.resize(size);
1867 for(int i=0;i<size;i++)
1869 PyObject *o=PyTuple_GetItem(value,i);
1871 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1874 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
1875 throw INTERP_KERNEL::Exception(oss.str().c_str());
1881 if(PyList_Check(value))
1883 int size=PyList_Size(value);
1884 stdvecTyypp.resize(size);
1885 for(int i=0;i<size;i++)
1887 PyObject *o=PyList_GetItem(value,i);
1889 stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
1892 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
1893 throw INTERP_KERNEL::Exception(oss.str().c_str());
1899 if(PySlice_Check(value))
1901 Py_ssize_t strt=2,stp=2,step=2;
1902 GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
1905 p.second.second=step;
1910 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
1911 if(!SWIG_IsOK(status))
1912 throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayIntTuple");
1913 daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
1918 * if python string with size one -> cpp char sw=1
1919 * if python string with size different from one -> cpp string sw=2
1920 * if python tuple[string] or list[string] -> vector<string> sw=3
1921 * if python not null pointer of DataArrayChar -> cpp DataArrayChar sw=4
1922 * switch between (int,string,vector<string>,DataArrayChar)
1924 static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, MEDCoupling::DataArrayChar *& dacType)
1926 const char *msg="4 types accepted : string, list or tuple of strings having same size, not null DataArrayChar instance.";
1928 if(PyString_Check(value))
1930 const char *pt=PyString_AsString(value);
1931 Py_ssize_t sz=PyString_Size(value);
1945 #if PY_VERSION_HEX >= 0x03000000
1946 if(PyUnicode_Check(value))
1949 const char *pt = PyUnicode_AsUTF8AndSize(value, &sz);
1964 if(PyTuple_Check(value))
1966 int size=PyTuple_Size(value);
1967 vsType.resize(size);
1968 for(int i=0;i<size;i++)
1970 PyObject *o=PyTuple_GetItem(value,i);
1973 vsType[i]=convertPyObjectToStr(o);
1975 catch(INTERP_KERNEL::Exception& e)
1977 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1978 throw INTERP_KERNEL::Exception(oss.str().c_str());
1984 if(PyList_Check(value))
1986 int size=PyList_Size(value);
1987 vsType.resize(size);
1988 for(int i=0;i<size;i++)
1990 PyObject *o=PyList_GetItem(value,i);
1993 vsType[i]=convertPyObjectToStr(o);
1995 catch(INTERP_KERNEL::Exception& e)
1997 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
1998 throw INTERP_KERNEL::Exception(oss.str().c_str());
2005 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayChar,0|0);
2006 if(SWIG_IsOK(status))
2008 dacType=reinterpret_cast< MEDCoupling::DataArrayChar * >(argp);
2011 std::ostringstream oss; oss << msg << " Instance in null !";
2012 throw INTERP_KERNEL::Exception(oss.str().c_str());
2017 throw INTERP_KERNEL::Exception(msg);
2021 * if value int -> cpp it sw=1
2022 * if value list[int] -> vt sw=2
2023 * if value tuple[int] -> vt sw=2
2024 * if value slice -> pt sw=3
2025 * if value DataArrayInt -> dt sw=4
2026 * if value tuple [int,int] -> cpp it,ip sw=5
2027 * if value tuple [list[int],int] -> cpp vt,ip sw=6
2028 * if value tuple [tuple[int],int] -> cpp vt,ip sw=6
2029 * if value tuple [slice,int] -> cpp pt,ip sw=7
2030 * if value tuple [DaI,int] -> cpp dt,ip sw=8
2031 * if value tuple [int,list[int]] -> cpp it,vc sw=9
2032 * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10
2033 * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10
2034 * if value tuple [slice,list[int]] -> cpp pt,vc sw=11
2035 * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12
2036 * if value tuple [int,tuple[int]] -> cpp it,vc sw=9
2037 * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10
2038 * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10
2039 * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11
2040 * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12
2041 * if value tuple [int,slice] -> cpp it,pc sw=13
2042 * if value tuple [list[int],slice] -> cpp vt,pc sw=14
2043 * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14
2044 * if value tuple [slice,slice] -> cpp pt,pc sw=15
2045 * if value tuple [DaI,slice] -> cpp dt,pc sw=16
2047 * switch between (int,vector<int>,DataArrayInt)
2049 static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
2050 std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
2051 MEDCoupling::DataArrayInt *&dt, MEDCoupling::DataArrayInt *&dc)
2053 if(!PyTuple_Check(value))
2055 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(value,nbTuple,sw,it,vt,pt,dt);
2060 int sz=PyTuple_Size(value);
2062 throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
2063 PyObject *ob0=PyTuple_GetItem(value,0);
2065 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob0,nbTuple,sw1,it,vt,pt,dt);
2066 PyObject *ob1=PyTuple_GetItem(value,1);
2067 convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(ob1,nbCompo,sw2,ic,vc,pc,dc);
2073 * if value int -> cpp val sw=1
2074 * if value double -> cpp val sw=1
2075 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2076 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2077 * if value list[int,double] -> cpp std::vector<double> sw=4
2078 * if value tuple[int,double] -> cpp std::vector<double> sw=4
2080 static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
2081 const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt)
2084 if(PyFloat_Check(value))
2086 val=PyFloat_AS_DOUBLE(value);
2088 if(nbTuplesExpected*nbCompExpected!=1)
2090 std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
2091 throw INTERP_KERNEL::Exception(oss.str().c_str());
2095 if(PyInt_Check(value))
2097 val=(double)PyInt_AS_LONG(value);
2099 if(nbTuplesExpected*nbCompExpected!=1)
2101 std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
2102 throw INTERP_KERNEL::Exception(oss.str().c_str());
2106 if(PyTuple_Check(value) || PyList_Check(value))
2110 int tmp1=nbTuplesExpected,tmp2=nbCompExpected;
2111 std::vector<double> ret=fillArrayWithPyListDbl2(value,tmp1,tmp2);
2116 catch(INTERP_KERNEL::Exception& exc) { throw exc; }
2119 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2120 if(SWIG_IsOK(status))
2122 d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2126 if(d->getNumberOfTuples()==nbTuplesExpected)
2128 if(d->getNumberOfComponents()==nbCompExpected)
2130 return d->getConstPointer();
2134 std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
2135 throw INTERP_KERNEL::Exception(oss.str().c_str());
2140 std::ostringstream oss; oss << msg << " input DataArrayDouble should have a number of tuples equal to " << nbTuplesExpected << " and there are " << d->getNumberOfTuples() << " tuples !";
2141 throw INTERP_KERNEL::Exception(oss.str().c_str());
2148 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2149 throw INTERP_KERNEL::Exception(oss.str().c_str());
2155 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2156 if(SWIG_IsOK(status))
2158 e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2160 if(e->getNumberOfCompo()==nbCompExpected)
2162 if(nbTuplesExpected==1)
2163 return e->getConstPointer();
2166 std::ostringstream oss; oss << msg << "nb of tuples expected to be " << nbTuplesExpected << " , and input DataArrayDoubleTuple has always one tuple by construction !";
2167 throw INTERP_KERNEL::Exception(oss.str().c_str());
2172 std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
2173 throw INTERP_KERNEL::Exception(oss.str().c_str());
2176 throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2180 * if value int -> cpp val sw=1
2181 * if value double -> cpp val sw=1
2182 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2183 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2184 * if value list[int,double] -> cpp std::vector<double> sw=4
2185 * if value tuple[int,double] -> cpp std::vector<double> sw=4
2187 static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
2188 const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples)
2191 if(PyFloat_Check(value))
2193 val=PyFloat_AS_DOUBLE(value);
2195 if(nbCompExpected!=1)
2197 std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
2198 throw INTERP_KERNEL::Exception(oss.str().c_str());
2203 if(PyInt_Check(value))
2205 val=(double)PyInt_AS_LONG(value);
2207 if(nbCompExpected!=1)
2209 std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
2210 throw INTERP_KERNEL::Exception(oss.str().c_str());
2215 if(PyTuple_Check(value))
2217 int size=PyTuple_Size(value);
2219 for(int i=0;i<size;i++)
2221 PyObject *o=PyTuple_GetItem(value,i);
2222 if(PyFloat_Check(o))
2223 f[i]=PyFloat_AS_DOUBLE(o);
2224 else if(PyInt_Check(o))
2225 f[i]=(double)PyInt_AS_LONG(o);
2228 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
2229 throw INTERP_KERNEL::Exception(oss.str().c_str());
2233 if(size%nbCompExpected!=0)
2235 std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
2236 throw INTERP_KERNEL::Exception(oss.str().c_str());
2238 nbTuples=size/nbCompExpected;
2241 if(PyList_Check(value))
2243 int size=PyList_Size(value);
2245 for(int i=0;i<size;i++)
2247 PyObject *o=PyList_GetItem(value,i);
2248 if(PyFloat_Check(o))
2249 f[i]=PyFloat_AS_DOUBLE(o);
2250 else if(PyInt_Check(o))
2251 f[i]=(double)PyInt_AS_LONG(o);
2254 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
2255 throw INTERP_KERNEL::Exception(oss.str().c_str());
2259 if(size%nbCompExpected!=0)
2261 std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
2262 throw INTERP_KERNEL::Exception(oss.str().c_str());
2264 nbTuples=size/nbCompExpected;
2268 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2269 if(SWIG_IsOK(status))
2271 d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2275 if(d->getNumberOfComponents()==nbCompExpected)
2277 nbTuples=d->getNumberOfTuples();
2278 return d->getConstPointer();
2282 std::ostringstream oss; oss << msg << "nb of components expected to be a multiple of " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
2283 throw INTERP_KERNEL::Exception(oss.str().c_str());
2290 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2291 throw INTERP_KERNEL::Exception(oss.str().c_str());
2294 { nbTuples=0; return 0; }
2297 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2298 if(SWIG_IsOK(status))
2300 e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2304 if(e->getNumberOfCompo()==nbCompExpected)
2307 return e->getConstPointer();
2311 std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
2312 throw INTERP_KERNEL::Exception(oss.str().c_str());
2319 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2320 throw INTERP_KERNEL::Exception(oss.str().c_str());
2323 { nbTuples=0; return 0; }
2326 throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2330 * if value int -> cpp val sw=1
2331 * if value double -> cpp val sw=1
2332 * if value DataArrayDouble -> cpp DataArrayDouble sw=2
2333 * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
2334 * if value list[int,double] -> cpp std::vector<double> sw=4
2335 * if value tuple[int,double] -> cpp std::vector<double> sw=4
2337 static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
2338 const char *msg, bool throwIfNullPt, int& nbTuples)
2340 MEDCoupling::DataArrayDouble *d=0;
2341 MEDCoupling::DataArrayDoubleTuple *e=0;
2343 if(PyFloat_Check(value))
2345 val=PyFloat_AS_DOUBLE(value);
2350 if(PyInt_Check(value))
2352 val=(double)PyInt_AS_LONG(value);
2357 if(PyTuple_Check(value))
2359 int size=PyTuple_Size(value);
2361 for(int i=0;i<size;i++)
2363 PyObject *o=PyTuple_GetItem(value,i);
2364 if(PyFloat_Check(o))
2365 f[i]=PyFloat_AS_DOUBLE(o);
2366 else if(PyInt_Check(o))
2367 f[i]=(double)PyInt_AS_LONG(o);
2370 std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
2371 throw INTERP_KERNEL::Exception(oss.str().c_str());
2378 if(PyList_Check(value))
2380 int size=PyList_Size(value);
2382 for(int i=0;i<size;i++)
2384 PyObject *o=PyList_GetItem(value,i);
2385 if(PyFloat_Check(o))
2386 f[i]=PyFloat_AS_DOUBLE(o);
2387 else if(PyInt_Check(o))
2388 f[i]=(double)PyInt_AS_LONG(o);
2391 std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
2392 throw INTERP_KERNEL::Exception(oss.str().c_str());
2400 int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2401 if(SWIG_IsOK(status))
2403 d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
2407 if(d->getNumberOfComponents()==1)
2409 nbTuples=d->getNumberOfTuples();
2410 return d->getConstPointer();
2414 std::ostringstream oss; oss << msg << "nb of components expected to be one, and input has " << d->getNumberOfComponents() << " components !";
2415 throw INTERP_KERNEL::Exception(oss.str().c_str());
2422 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2423 throw INTERP_KERNEL::Exception(oss.str().c_str());
2426 { nbTuples=0; return 0; }
2429 status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
2430 if(SWIG_IsOK(status))
2432 e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
2436 nbTuples=e->getNumberOfCompo();
2437 return e->getConstPointer();
2443 std::ostringstream oss; oss << msg << " null pointer not accepted!";
2444 throw INTERP_KERNEL::Exception(oss.str().c_str());
2447 { nbTuples=0; return 0; }
2450 throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
2453 static MEDCoupling::DataArray *CheckAndRetrieveDataArrayInstance(PyObject *obj, const char *msg)
2456 int status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArray,0|0);
2457 if(!SWIG_IsOK(status))
2459 status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
2460 if(!SWIG_IsOK(status))
2462 status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
2463 if(!SWIG_IsOK(status))
2465 status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,0|0);
2466 if(!SWIG_IsOK(status))
2468 status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayByte,0|0);
2469 std::ostringstream oss; oss << msg << " ! Accepted instances are DataArrayDouble, DataArrayInt, DataArrayAsciiChar, DataArrayByte !";
2470 throw INTERP_KERNEL::Exception(oss.str().c_str());
2475 return reinterpret_cast< MEDCoupling::DataArray * >(aBasePtrVS);
2478 static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner)
2483 Py_XINCREF(Py_None);
2486 if(dynamic_cast<MEDCoupling::DataArrayPartDefinition *>(pd))
2487 ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__DataArrayPartDefinition,owner);
2489 ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__SlicePartDefinition,owner);
2494 static typename MEDCoupling::Traits<T>::ArrayType *DataArrayT_New(PyObject *elt0, PyObject *nbOfTuples, PyObject *elt2)
2496 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)";
2497 std::string msg(msgBase);
2499 msg+="\n-DataArrayDouble.New(numpy array with dtype=float64)";
2502 if(PyList_Check(elt0) || PyTuple_Check(elt0))
2506 if(PyInt_Check(nbOfTuples))
2508 int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
2510 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
2513 if(PyInt_Check(elt2))
2514 {//DataArrayDouble.New([1.,3.,4.,5.],2,2)
2515 int nbOfCompo=PyInt_AS_LONG(elt2);
2517 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
2518 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2519 std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,nbOfCompo));
2520 ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2524 throw INTERP_KERNEL::Exception(msg.c_str());
2527 {//DataArrayDouble.New([1.,3.,4.],3)
2528 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2530 std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,tmpp1));
2531 ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2536 throw INTERP_KERNEL::Exception(msg.c_str());
2539 {// DataArrayDouble.New([1.,3.,4.])
2540 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2541 int tmpp1(-1),tmpp2(-1);
2542 std::vector<double> tmp=fillArrayWithPyListDbl2(elt0,tmpp1,tmpp2);
2543 ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
2547 else if(PyInt_Check(elt0))
2549 int nbOfTuples1(PyInt_AS_LONG(elt0));
2551 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
2556 if(PyInt_Check(nbOfTuples))
2557 {//DataArrayDouble.New(5,2)
2558 int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
2560 throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
2561 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2562 ret->alloc(nbOfTuples1,nbOfCompo);
2566 throw INTERP_KERNEL::Exception(msg.c_str());
2569 throw INTERP_KERNEL::Exception(msg.c_str());
2572 {//DataArrayDouble.New(5)
2573 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
2574 ret->alloc(nbOfTuples1,1);
2579 else if(PyArray_Check(elt0) && nbOfTuples==NULL && elt2==NULL)
2580 {//DataArrayDouble.New(numpyArray)
2581 return BuildNewInstance< typename MEDCoupling::Traits<T>::ArrayType , T >(elt0,NPYTraits<T>::NPYObjectType,NPYTraits<T>::NPYFunc,MEDCoupling::Traits<T>::NPYStr);
2585 throw INTERP_KERNEL::Exception(msg.c_str());
2586 throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
2590 typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__internal(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value, swig_type_info *ti)
2592 self->checkAllocated();
2593 const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
2594 int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
2598 typename MEDCoupling::Traits<T>::ArrayType *d1=0;
2599 considerPyObjAsATStarLikeObject<T>(value,sw1,i1,v1,d1,ti);
2601 std::vector<int> vt1,vc1;
2602 std::pair<int, std::pair<int,int> > pt1,pc1;
2603 MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
2604 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
2605 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > tmp;
2613 self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
2616 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2617 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2618 self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
2621 self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
2624 throw INTERP_KERNEL::Exception(msg);
2633 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
2636 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2637 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2638 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
2641 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
2644 throw INTERP_KERNEL::Exception(msg);
2653 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
2656 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2657 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2658 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
2661 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
2664 throw INTERP_KERNEL::Exception(msg);
2673 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
2676 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2677 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2678 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
2681 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
2684 throw INTERP_KERNEL::Exception(msg);
2693 self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
2696 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2697 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2698 self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
2701 self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
2704 throw INTERP_KERNEL::Exception(msg);
2713 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
2716 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2717 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2718 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
2721 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
2724 throw INTERP_KERNEL::Exception(msg);
2733 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
2736 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2737 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2738 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
2741 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
2744 throw INTERP_KERNEL::Exception(msg);
2753 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
2756 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2757 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2758 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
2761 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
2764 throw INTERP_KERNEL::Exception(msg);
2773 self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
2776 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2777 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2778 self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
2781 self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
2784 throw INTERP_KERNEL::Exception(msg);
2793 self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
2796 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2797 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2798 self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
2801 self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
2804 throw INTERP_KERNEL::Exception(msg);
2813 self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
2816 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2817 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2818 self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
2821 self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
2824 throw INTERP_KERNEL::Exception(msg);
2833 self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
2836 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2837 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2838 self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
2841 self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
2844 throw INTERP_KERNEL::Exception(msg);
2853 self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
2856 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2857 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2858 self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
2861 self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
2864 throw INTERP_KERNEL::Exception(msg);
2873 self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
2876 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2877 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2878 self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
2881 self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
2884 throw INTERP_KERNEL::Exception(msg);
2893 self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
2896 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2897 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2898 self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
2901 self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
2904 throw INTERP_KERNEL::Exception(msg);
2913 self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
2916 tmp=MEDCoupling::Traits<T>::ArrayType::New();
2917 tmp->useArray(&v1[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,v1.size());
2918 self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
2921 self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
2924 throw INTERP_KERNEL::Exception(msg);
2929 throw INTERP_KERNEL::Exception(msg);
2935 PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, swig_type_info *ti)
2937 const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !";
2938 const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
2939 self->checkAllocated();
2940 int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
2942 std::vector<int> vt1,vc1;
2943 std::pair<int, std::pair<int,int> > pt1,pc1;
2944 MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
2946 convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
2947 MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType > ret;
2951 if(nbOfComponents==1)
2952 return PyFloat_FromDouble((T)self->getIJSafe(it1,0));
2953 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),ti, SWIG_POINTER_OWN | 0 );
2955 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),ti, SWIG_POINTER_OWN | 0 );
2957 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),ti, SWIG_POINTER_OWN | 0 );
2959 return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),ti, SWIG_POINTER_OWN | 0 );
2961 return PyFloat_FromDouble((T)self->getIJSafe(it1,ic1));
2964 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
2965 std::vector<int> v2(1,ic1);
2966 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
2970 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
2971 std::vector<int> v2(1,ic1);
2972 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
2976 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
2977 std::vector<int> v2(1,ic1);
2978 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
2982 ret=self->selectByTupleIdSafe(&it1,&it1+1);
2983 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
2987 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
2988 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
2992 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
2993 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
2997 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
2998 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
3002 ret=self->selectByTupleIdSafe(&it1,&it1+1);
3003 int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3004 std::vector<int> v2(nbOfComp);
3005 for(int i=0;i<nbOfComp;i++)
3006 v2[i]=pc1.first+i*pc1.second.second;
3007 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3011 ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
3012 int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3013 std::vector<int> v2(nbOfComp);
3014 for(int i=0;i<nbOfComp;i++)
3015 v2[i]=pc1.first+i*pc1.second.second;
3016 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3020 ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
3021 int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3022 std::vector<int> v2(nbOfComp);
3023 for(int i=0;i<nbOfComp;i++)
3024 v2[i]=pc1.first+i*pc1.second.second;
3025 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3029 ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
3030 int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
3031 std::vector<int> v2(nbOfComp);
3032 for(int i=0;i<nbOfComp;i++)
3033 v2[i]=pc1.first+i*pc1.second.second;
3034 return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
3037 throw INTERP_KERNEL::Exception(msg);
3041 bool isCSRMatrix(PyObject *m)
3043 #if defined(WITH_NUMPY) && defined(WITH_SCIPY)
3044 PyObject* pdict(PyDict_New());
3045 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
3046 PyObject *tmp(PyRun_String("from scipy.sparse import csr_matrix", Py_single_input, pdict, pdict));
3048 throw INTERP_KERNEL::Exception("Problem during loading csr_matrix in scipy.sparse ! Is Scipy module available in present ?");
3049 PyObject *csrMatrixCls=PyDict_GetItemString(pdict,"csr_matrix");
3051 throw INTERP_KERNEL::Exception("csr_matrix not found in scipy.sparse ! Is Scipy module available in present ?");
3052 bool ret(PyObject_IsInstance(m,csrMatrixCls));
3053 Py_DECREF(pdict); Py_XDECREF(tmp);
3060 void convertCSR_MCDataToVectMapIntDouble(const MEDCoupling::DataArrayInt *indptrPtr, const MEDCoupling::DataArrayInt *indicesPtr, const MEDCoupling::DataArrayDouble *dataPtr, std::vector<std::map<int,double> >& mCpp)
3062 auto nbOfRows(indptrPtr->getNumberOfTuples()-1);
3064 throw INTERP_KERNEL::Exception("pywrap of MEDCouplingRemapper::setMatrix : input CSR matrix looks bad regarding indptr array !");
3065 mCpp.resize(nbOfRows);
3066 auto indPtrCPtr(indptrPtr->begin());
3067 auto indicesCPtr(indicesPtr->begin());
3068 auto dataCPtr(dataPtr->begin());
3069 for(auto i=0;i<nbOfRows;i++)
3071 auto& line(mCpp[i]);
3072 for(auto j=indPtrCPtr[i];j<indPtrCPtr[i+1];j++)
3074 line[indicesCPtr[j]]=dataCPtr[j];
3079 void convertToVectMapIntDouble(PyObject *pyobj, std::vector<std::map<int,double> >& mCpp)
3081 if(!PyList_Check(pyobj))
3082 throw INTERP_KERNEL::Exception("convertToVectMapIntDouble : input is not a python list !");
3084 Py_ssize_t sz(PyList_Size(pyobj));
3086 for(Py_ssize_t i=0;i<sz;i++)
3088 PyObject *elt(PyList_GetItem(pyobj,i));
3089 if(!PyDict_Check(elt))
3091 std::ostringstream oss; oss << "convertToVectMapIntDouble : at pos # " << i << " of pylist a dict is exepect !";
3092 throw INTERP_KERNEL::Exception(oss.str());
3094 PyObject *key, *value;
3096 std::map<int,double>& mapCpp(mCpp[i]);
3097 while(PyDict_Next(elt,&pos,&key,&value))
3099 if(!PyInt_Check(key))
3101 std::ostringstream oss; oss << "convertToVectMapIntDouble : at pos # " << i << " of pylist the dict contains at pos " << pos << " a key not mappable to pyint !";
3102 throw INTERP_KERNEL::Exception(oss.str());
3104 if(!PyFloat_Check(value))
3106 std::ostringstream oss; oss << "convertToVectMapIntDouble : at pos # " << i << " of pylist the dict contains at pos " << pos << " the value not mappable to pyfloat !";
3107 throw INTERP_KERNEL::Exception(oss.str());
3109 mapCpp[(int)PyInt_AS_LONG(key)]=PyFloat_AS_DOUBLE(value);
3115 PyObject *DataArrayT_imul__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3117 const char msg[]="Unexpected situation in __imul__ !";
3119 typename MEDCoupling::Traits<T>::ArrayType *a;
3120 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3123 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3128 self->applyLin(val,0.);
3129 Py_XINCREF(trueSelf);
3134 self->multiplyEqual(a);
3135 Py_XINCREF(trueSelf);
3140 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3141 self->multiplyEqual(aaa);
3142 Py_XINCREF(trueSelf);
3147 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
3148 self->multiplyEqual(aaa);
3149 Py_XINCREF(trueSelf);
3153 throw INTERP_KERNEL::Exception(msg);
3158 PyObject *DataArrayT_idiv__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3160 const char msg[]="Unexpected situation in __idiv__ !";
3162 typename MEDCoupling::Traits<T>::ArrayType *a;
3163 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3166 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3172 throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
3173 self->applyLin(1./val,0.);
3174 Py_XINCREF(trueSelf);
3179 self->divideEqual(a);
3180 Py_XINCREF(trueSelf);
3185 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3186 self->divideEqual(aaa);
3187 Py_XINCREF(trueSelf);
3192 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
3193 self->divideEqual(aaa);
3194 Py_XINCREF(trueSelf);
3198 throw INTERP_KERNEL::Exception(msg);
3203 PyObject *DataArrayT_iadd__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3205 const char msg[]="Unexpected situation in __iadd__ !";
3207 typename MEDCoupling::Traits<T>::ArrayType *a;
3208 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3211 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3216 self->applyLin(1.,val);
3217 Py_XINCREF(trueSelf);
3223 Py_XINCREF(trueSelf);
3228 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3229 self->addEqual(aaa);
3230 Py_XINCREF(trueSelf);
3235 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
3236 self->addEqual(aaa);
3237 Py_XINCREF(trueSelf);
3241 throw INTERP_KERNEL::Exception(msg);
3246 PyObject *DataArrayT_isub__internal(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self, swig_type_info *ti_da, swig_type_info *ti_tuple)
3248 const char msg[]="Unexpected situation in __isub__ !";
3250 typename MEDCoupling::Traits<T>::ArrayType *a;
3251 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3254 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,ti_da,ti_tuple);
3259 self->applyLin(1.,-val);
3260 Py_XINCREF(trueSelf);
3265 self->substractEqual(a);
3266 Py_XINCREF(trueSelf);
3271 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(aa->buildDA(1,self->getNumberOfComponents()));
3272 self->substractEqual(aaa);
3273 Py_XINCREF(trueSelf);
3278 MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
3279 self->substractEqual(aaa);
3280 Py_XINCREF(trueSelf);
3284 throw INTERP_KERNEL::Exception(msg);
3293 struct SWIGTITraits<double>
3294 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3297 struct SWIGTITraits<float>
3298 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3301 struct SWIGTITraits<int>
3302 { static swig_type_info *TI; static swig_type_info *TI_TUPLE; };
3304 swig_type_info *SWIGTITraits<double>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
3305 swig_type_info *SWIGTITraits<float>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3306 swig_type_info *SWIGTITraits<int>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3307 swig_type_info *SWIGTITraits<double>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
3308 swig_type_info *SWIGTITraits<float>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3309 swig_type_info *SWIGTITraits<int>::TI_TUPLE=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
3312 PyTypeObject *NPYTraits<double>::NPYFunc=&PyCallBackDataArrayDouble_RefType;
3314 PyTypeObject *NPYTraits<float>::NPYFunc=&PyCallBackDataArrayFloat_RefType;
3318 typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value)
3320 return DataArrayT__setitem__internal<T>(self,obj,value,SWIGTITraits<T>::TI);
3324 PyObject *DataArrayT__getitem(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj)
3326 return DataArrayT__getitem__internal<T>(self,obj,SWIGTITraits<T>::TI);
3330 PyObject *DataArrayT_imul(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3332 return DataArrayT_imul__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3336 PyObject *DataArrayT_idiv(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3338 return DataArrayT_idiv__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3342 PyObject *DataArrayT_iadd(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3344 return DataArrayT_iadd__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3348 PyObject *DataArrayT_isub(PyObject *trueSelf, PyObject *obj, typename MEDCoupling::Traits<T>::ArrayType *self)
3350 return DataArrayT_isub__internal<T>(trueSelf,obj,self,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3354 typename MEDCoupling::Traits<T>::ArrayType *DataArrayFPT_rmul(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj)
3356 const char msg[]="Unexpected situation in __rmul__ !";
3358 typename MEDCoupling::Traits<T>::ArrayType *a;
3359 typename MEDCoupling::Traits<T>::ArrayTuple *aa;
3362 convertFPStarLikePyObjToCpp_2<T>(obj,sw,val,a,aa,bb,SWIGTITraits<T>::TI,SWIGTITraits<T>::TI_TUPLE);
3367 typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> ret(self->deepCopy());
3368 ret->applyLin(val,0.);
3373 typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> aaa(aa->buildDA(1,self->getNumberOfComponents()));
3374 return MEDCoupling::Traits<T>::ArrayType::Multiply(self,aaa);
3378 typename MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType> aaa(MEDCoupling::Traits<T>::ArrayType::New()); aaa->useArray(&bb[0],false,MEDCoupling::DeallocType::CPP_DEALLOC,1,(int)bb.size());
3379 return MEDCoupling::Traits<T>::ArrayType::Multiply(self,aaa);
3382 throw INTERP_KERNEL::Exception(msg);