-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef __MEDCOUPLINGDATAARRAYTYPEMAPS_I__
+#define __MEDCOUPLINGDATAARRAYTYPEMAPS_I__
#include "InterpKernelAutoPtr.hxx"
+#include "MEDCouplingDataArrayTraits.hxx"
+
+#include <sstream>
/*!
* This method is an extention of PySlice_GetIndices but less
return val;
}
-#ifdef WITH_NUMPY
-#include <numpy/arrayobject.h>
-
-// specific DataArray deallocator callback. This deallocator is used both in the constructor of DataArray and in the toNumPyArr
-// method. This dellocator uses weakref to determine if the linked numArr is still alive or not. If alive the ownership is given to it.
-// if no more alive the "standart" DataArray deallocator is called.
-void numarrdeal(void *pt, void *wron)
-{
- void **wronc=(void **)wron;
- PyObject *weakRefOnOwner=reinterpret_cast<PyObject *>(wronc[0]);
- PyObject *obj=PyWeakref_GetObject(weakRefOnOwner);
- if(obj!=Py_None)
- {
- Py_XINCREF(obj);
- PyArrayObject *objC=reinterpret_cast<PyArrayObject *>(obj);
- objC->flags|=NPY_OWNDATA;
- Py_XDECREF(weakRefOnOwner);
- Py_XDECREF(obj);
- }
- else
- {
- typedef void (*MyDeallocator)(void *,void *);
- MyDeallocator deall=(MyDeallocator)wronc[1];
- deall(pt,NULL);
- Py_XDECREF(weakRefOnOwner);
- }
- delete [] wronc;
-}
-
-template<class MCData>
-struct PyCallBackDataArraySt {
- PyObject_HEAD
- MCData *_pt_mc;
-};
-
-typedef struct PyCallBackDataArraySt<ParaMEDMEM::DataArrayInt> PyCallBackDataArrayInt;
-typedef struct PyCallBackDataArraySt<ParaMEDMEM::DataArrayDouble> PyCallBackDataArrayDouble;
-
-extern "C"
-{
- static int callbackmcdataarray___init__(PyObject *self, PyObject *args, PyObject *kwargs) { return 0; }
-
- static PyObject *callbackmcdataarrayint___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
- {
- PyCallBackDataArrayInt *self = (PyCallBackDataArrayInt *) ( type->tp_alloc(type, 0) );
- return (PyObject *)self;
- }
-
- static PyObject *callbackmcdataarraydouble___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
- {
- PyCallBackDataArrayDouble *self = (PyCallBackDataArrayDouble *) ( type->tp_alloc(type, 0) );
- return (PyObject *)self;
- }
-
- static void callbackmcdataarray_dealloc(PyObject *self)
- {
- Py_TYPE(self)->tp_free(self);
- }
-
- // real callback called when a numpy arr having more than one DataArray instance client on it is destroyed.
- // In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients.
- static PyObject *callbackmcdataarrayint_call(PyCallBackDataArrayInt *self, PyObject *args, PyObject *kw)
- {
- if(self->_pt_mc)
- {
- ParaMEDMEM::MemArray<int>& mma=self->_pt_mc->accessToMemArray();
- mma.destroy();
- }
- Py_XINCREF(Py_None);
- return Py_None;
- }
-
- // real callback called when a numpy arr having more than one DataArray instance client on it is destroyed.
- // In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients.
- static PyObject *callbackmcdataarraydouble_call(PyCallBackDataArrayDouble *self, PyObject *args, PyObject *kw)
- {
- if(self->_pt_mc)
- {
- ParaMEDMEM::MemArray<double>& mma=self->_pt_mc->accessToMemArray();
- mma.destroy();
- }
- Py_XINCREF(Py_None);
- return Py_None;
- }
-}
-
-PyTypeObject PyCallBackDataArrayInt_RefType = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "callbackmcdataarrayint",
- sizeof(PyCallBackDataArrayInt),
- 0,
- callbackmcdataarray_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- (ternaryfunc)callbackmcdataarrayint_call, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- callbackmcdataarray___init__, /*tp_init*/
- PyType_GenericAlloc, /*tp_alloc*/
- callbackmcdataarrayint___new__, /*tp_new*/
- PyObject_GC_Del, /*tp_free*/
-};
-
-PyTypeObject PyCallBackDataArrayDouble_RefType = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "callbackmcdataarraydouble",
- sizeof(PyCallBackDataArrayDouble),
- 0,
- callbackmcdataarray_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- (ternaryfunc)callbackmcdataarraydouble_call, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- callbackmcdataarray___init__, /*tp_init*/
- PyType_GenericAlloc, /*tp_alloc*/
- callbackmcdataarraydouble___new__, /*tp_new*/
- PyObject_GC_Del, /*tp_free*/
-};
-
// this is the second type of specific deallocator, only valid for the constructor of DataArrays taking numpy array
// in input when an another DataArray is already client of this.
template<class MCData>
if(itemSize!=PyArray_STRIDE(elt0,1))
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 !");
const char *data=PyArray_BYTES(elt0);
- typename ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<MCData> ret=MCData::New();
+ typename MEDCoupling::MCAuto<MCData> ret=MCData::New();
if(PyArray_ISBEHAVED(elt0))//aligned and writeable and in machine byte-order
{
PyArrayObject *elt0C=reinterpret_cast<PyArrayObject *>(elt0);
- PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & NPY_OWNDATA)?elt0C:NULL;
- int mask=NPY_OWNDATA; mask=~mask;
+ PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & MED_NUMPY_OWNDATA)?elt0C:NULL;
+ int mask=MED_NUMPY_OWNDATA; mask=~mask;
elt0C->flags&=mask;
PyObject *deepestObj=elt0;
PyObject *base=elt0C->base;
if(base) deepestObj=base;
+ bool isSpetialCase(false);
while(base)
{
if(PyArray_Check(base))
{
PyArrayObject *baseC=reinterpret_cast<PyArrayObject *>(base);
- eltOwning=(PyArray_FLAGS(baseC) & NPY_OWNDATA)?baseC:eltOwning;
+ eltOwning=(PyArray_FLAGS(baseC) & MED_NUMPY_OWNDATA)?baseC:eltOwning;
baseC->flags&=mask;
base=baseC->base;
if(base) deepestObj=base;
}
else
- break;
+ {
+ isSpetialCase=true;
+ break;
+ }
+ }
+ if(isSpetialCase)
+ {// 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.
+ std::size_t nbOfElems(sz0*sz1);
+ T *dataCpy=(T*)malloc(sizeof(T)*nbOfElems);
+ std::copy(reinterpret_cast<const T*>(data),reinterpret_cast<const T*>(data)+nbOfElems,dataCpy);
+ ret->useArray(dataCpy,true,MEDCoupling::C_DEALLOC,sz0,sz1);
+ return ret.retn();
}
- typename ParaMEDMEM::MemArray<T>& mma=ret->accessToMemArray();
+ typename MEDCoupling::MemArray<T>& mma=ret->accessToMemArray();
if(eltOwning==NULL)
{
PyCallBackDataArraySt<MCData> *cb=PyObject_GC_New(PyCallBackDataArraySt<MCData>,pytype);
cb->_pt_mc=ret;
- ret->useArray(reinterpret_cast<const T *>(data),true,ParaMEDMEM::C_DEALLOC,sz0,sz1);
+ ret->useArray(reinterpret_cast<const T *>(data),true,MEDCoupling::C_DEALLOC,sz0,sz1);
PyObject *ref=PyWeakref_NewRef(deepestObj,(PyObject *)cb);
void **objs=new void *[2]; objs[0]=cb; objs[1]=ref;
mma.setParameterForDeallocator(objs);
}
else
{
- ret->useArray(reinterpret_cast<const T *>(data),true,ParaMEDMEM::C_DEALLOC,sz0,sz1);
+ ret->useArray(reinterpret_cast<const T *>(data),true,MEDCoupling::C_DEALLOC,sz0,sz1);
PyObject *ref=PyWeakref_NewRef(reinterpret_cast<PyObject *>(eltOwning),NULL);
- typename ParaMEDMEM::MemArray<T>::Deallocator tmp(ParaMEDMEM::MemArray<T>::CDeallocator);
+ typename MEDCoupling::MemArray<T>::Deallocator tmp(MEDCoupling::MemArray<T>::CDeallocator);
void **tmp2 = reinterpret_cast<void**>(&tmp); // MSVC2010 does not support constructor()
void **objs=new void *[2]; objs[0]=ref; objs[1]=*tmp2;
mma.setParameterForDeallocator(objs);
}
}
else if(PyArray_ISBEHAVED_RO(elt0))
- ret->useArray(reinterpret_cast<const T *>(data),false,ParaMEDMEM::CPP_DEALLOC,sz0,sz1);
+ ret->useArray(reinterpret_cast<const T *>(data),false,MEDCoupling::CPP_DEALLOC,sz0,sz1);
return ret.retn();
}
/* If this array owns its own data, stop collapsing */
- if (PyArray_CHKFLAGS(obj_arr, NPY_OWNDATA)) {
+ if (PyArray_CHKFLAGS(obj_arr, MED_NUMPY_OWNDATA )) {
break;
}
std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : this is not allocated !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- ParaMEDMEM::MemArray<T>& mem=self->accessToMemArray();
+ MEDCoupling::MemArray<T>& mem=self->accessToMemArray();
if(nbComp==0)
{
std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : number of components of this is 0 ! Should be > 0 !";
if(mem.getDeallocator()!=numarrdeal)
{// case for the first call of toNumPyArray
PyObject *ref(PyWeakref_NewRef(ret,NULL));
- typename ParaMEDMEM::MemArray<T>::Deallocator tmp(mem.getDeallocator());
+ typename MEDCoupling::MemArray<T>::Deallocator tmp(mem.getDeallocator());
void **tmp2 = reinterpret_cast<void**>(&tmp); // MSVC2010 does not support constructor()
void **objs=new void *[2]; objs[0]=reinterpret_cast<void*>(ref); objs[1]=*tmp2;
mem.setParameterForDeallocator(objs);
return ToNumPyArrayUnderground<MCData,T>(self,npyObjectType,MCDataStr,self->getNumberOfTuples(),self->getNumberOfComponents());
}
-SWIGINTERN PyObject *ParaMEDMEM_DataArrayInt_toNumPyArray(ParaMEDMEM::DataArrayInt *self);
-SWIGINTERN PyObject *ParaMEDMEM_DataArrayDouble_toNumPyArray(ParaMEDMEM::DataArrayDouble *self);
+SWIGINTERN PyObject *MEDCoupling_DataArrayInt_toNumPyArray(MEDCoupling::DataArrayInt *self);
+SWIGINTERN PyObject *MEDCoupling_DataArrayDouble_toNumPyArray(MEDCoupling::DataArrayDouble *self);
PyObject *ToCSRMatrix(const std::vector<std::map<int,double> >& m, int nbCols) throw(INTERP_KERNEL::Exception)
{
int nbRows((int)m.size());
- ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayInt> indPtr(ParaMEDMEM::DataArrayInt::New()),indices(ParaMEDMEM::DataArrayInt::New());
- ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> data(ParaMEDMEM::DataArrayDouble::New());
+ MEDCoupling::MCAuto<MEDCoupling::DataArrayInt> indPtr(MEDCoupling::DataArrayInt::New()),indices(MEDCoupling::DataArrayInt::New());
+ MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> data(MEDCoupling::DataArrayDouble::New());
indPtr->alloc(nbRows+1,1);
int *intPtr_ptr(indPtr->getPointer()); intPtr_ptr[0]=0; intPtr_ptr++;
int sz2(0);
*indices_ptr=(*it1).first;
*data_ptr=(*it1).second;
}
- PyObject *a(ParaMEDMEM_DataArrayDouble_toNumPyArray(data)),*b(ParaMEDMEM_DataArrayInt_toNumPyArray(indices)),*c(ParaMEDMEM_DataArrayInt_toNumPyArray(indPtr));
+ PyObject *a(MEDCoupling_DataArrayDouble_toNumPyArray(data)),*b(MEDCoupling_DataArrayInt_toNumPyArray(indices)),*c(MEDCoupling_DataArrayInt_toNumPyArray(indPtr));
//
PyObject *args(PyTuple_New(1)),*args0(PyTuple_New(3)),*kw(PyDict_New()),*kw1(PyTuple_New(2));
PyTuple_SetItem(args0,0,a); PyTuple_SetItem(args0,1,b); PyTuple_SetItem(args0,2,c); PyTuple_SetItem(args,0,args0);
return ret;
}
-#endif
-
-static PyObject *convertDataArrayChar(ParaMEDMEM::DataArrayChar *dac, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertDataArrayChar(MEDCoupling::DataArrayChar *dac, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
if(!dac)
Py_XINCREF(Py_None);
return Py_None;
}
- if(dynamic_cast<ParaMEDMEM::DataArrayByte *>(dac))
- ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,owner);
- if(dynamic_cast<ParaMEDMEM::DataArrayAsciiChar *>(dac))
- ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayAsciiChar,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayByte *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayByte,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayAsciiChar *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,owner);
if(!ret)
throw INTERP_KERNEL::Exception("Not recognized type of DataArrayChar on downcast !");
return ret;
}
-static PyObject *convertDataArray(ParaMEDMEM::DataArray *dac, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertDataArray(MEDCoupling::DataArray *dac, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
if(!dac)
Py_XINCREF(Py_None);
return Py_None;
}
- if(dynamic_cast<ParaMEDMEM::DataArrayDouble *>(dac))
- ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,owner);
- if(dynamic_cast<ParaMEDMEM::DataArrayInt *>(dac))
- ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,owner);
- if(dynamic_cast<ParaMEDMEM::DataArrayByte *>(dac))
- ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,owner);
- if(dynamic_cast<ParaMEDMEM::DataArrayAsciiChar *>(dac))
- ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayAsciiChar,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayDouble *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayDouble,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayInt *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayInt,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayFloat *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayFloat,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayByte *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayByte,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayAsciiChar *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,owner);
if(!ret)
throw INTERP_KERNEL::Exception("Not recognized type of DataArray on downcast !");
return ret;
throw INTERP_KERNEL::Exception(msg);
}
-static PyObject *convertDblArrToPyList(const double *ptr, int size) throw(INTERP_KERNEL::Exception)
+template<class T>
+PyObject *convertDblArrToPyList(const T *ptr, int size) throw(INTERP_KERNEL::Exception)
{
- PyObject *ret=PyList_New(size);
+ PyObject *ret(PyList_New(size));
for(int i=0;i<size;i++)
PyList_SetItem(ret,i,PyFloat_FromDouble(ptr[i]));
return ret;
static PyObject *convertDblArrToPyList2(const std::vector<double>& v) throw(INTERP_KERNEL::Exception)
{
- int size=v.size();
- PyObject *ret=PyList_New(size);
+ int size(v.size());
+ PyObject *ret(PyList_New(size));
for(int i=0;i<size;i++)
PyList_SetItem(ret,i,PyFloat_FromDouble(v[i]));
return ret;
}
-static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
+template<class T>
+PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
{
- PyObject *ret=PyList_New(nbOfTuples);
+ PyObject *ret(PyList_New(nbOfTuples));
for(int i=0;i<nbOfTuples;i++)
{
PyObject *t=PyTuple_New(nbOfComp);
return ret;
}
-//convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(pyLi,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh")
+//convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingUMesh *>(pyLi,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh")
template<class T>
static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, const char *typeStr, typename std::vector<T>& ret)
{
*
* switch between (int,vector<int>,DataArrayInt)
*/
-static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, ParaMEDMEM::DataArrayInt *& daIntTyypp, ParaMEDMEM::DataArrayIntTuple *&daIntTuple) throw(INTERP_KERNEL::Exception)
+static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple) throw(INTERP_KERNEL::Exception)
{
sw=-1;
if(PyInt_Check(value))
return;
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
if(SWIG_IsOK(status))
{
- daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
+ daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
sw=3;
return;
}
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
if(SWIG_IsOK(status))
{
- daIntTuple=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
+ daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
sw=4;
return ;
}
*
* switch between (int,vector<int>,DataArrayInt)
*/
-static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, ParaMEDMEM::DataArrayDouble *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+template<class T>
+void convertObjToPossibleCpp4(PyObject *value, int& sw, T& iTyypp, std::vector<T>& stdvecTyypp, typename MEDCoupling::Traits<T>::ArrayType *& daIntTyypp, swig_type_info *ti) throw(INTERP_KERNEL::Exception)
{
sw=-1;
if(PyFloat_Check(value))
{
- iTyypp=PyFloat_AS_DOUBLE(value);
+ iTyypp=(T)PyFloat_AS_DOUBLE(value);
sw=1;
return;
}
if(PyInt_Check(value))
{
- iTyypp=(double)PyInt_AS_LONG(value);
+ iTyypp=(T)PyInt_AS_LONG(value);
sw=1;
return;
}
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyFloat_Check(o))
- stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
+ stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
else if(PyInt_Check(o))
- stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
+ stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
else
{
std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
{
PyObject *o=PyList_GetItem(value,i);
if(PyFloat_Check(o))
- stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
+ stdvecTyypp[i]=(T)PyFloat_AS_DOUBLE(o);
else if(PyInt_Check(o))
- stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
+ stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
else
{
std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
return;
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,ti,0|0);
if(!SWIG_IsOK(status))
throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
- daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ daIntTyypp=reinterpret_cast< typename MEDCoupling::Traits<T>::ArrayType * >(argp);
sw=3;
}
*
* switch between (int,vector<int>,DataArrayInt)
*/
-static void convertObjToPossibleCpp44(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, ParaMEDMEM::DataArrayDoubleTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+static void convertObjToPossibleCpp44(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, MEDCoupling::DataArrayDoubleTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
{
sw=-1;
if(PyFloat_Check(value))
return;
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
if(!SWIG_IsOK(status))
throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDoubleTuple");
- daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
+ daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
sw=3;
}
*
* switch between (int,vector<int>,DataArrayInt)
*/
-static void convertObjToPossibleCpp2(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+static void convertObjToPossibleCpp2(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
{
const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple";
sw=-1;
return ;
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
if(SWIG_IsOK(status))
{
- daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
+ daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
if(!daIntTyypp)
{
std::ostringstream oss; oss << msg << " Instance in null !";
sw=4;
return ;
}
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
if(SWIG_IsOK(status))
{
- ParaMEDMEM::DataArrayIntTuple *tmp=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
+ MEDCoupling::DataArrayIntTuple *tmp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
if(!tmp)
{
std::ostringstream oss; oss << msg << " Instance in null !";
/*!
* Idem than convertObjToPossibleCpp2
*/
-static void convertObjToPossibleCpp2WithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+static void convertObjToPossibleCpp2WithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
{
convertObjToPossibleCpp2(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
if(sw==1)
* if python slice -> cpp pair sw=3
* if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 . WARNING The returned pointer can be the null pointer !
*/
-static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayIntTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+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) throw(INTERP_KERNEL::Exception)
{
sw=-1;
if(PyInt_Check(value))
return ;
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
if(!SWIG_IsOK(status))
throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayIntTuple");
- daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
+ daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
sw=4;
}
* if python not null pointer of DataArrayChar -> cpp DataArrayChar sw=4
* switch between (int,string,vector<string>,DataArrayChar)
*/
-static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, ParaMEDMEM::DataArrayChar *& dacType) throw(INTERP_KERNEL::Exception)
+static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, MEDCoupling::DataArrayChar *& dacType) throw(INTERP_KERNEL::Exception)
{
const char *msg="4 types accepted : string, list or tuple of strings having same size, not null DataArrayChar instance.";
sw=-1;
return;
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayChar,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayChar,0|0);
if(SWIG_IsOK(status))
{
- dacType=reinterpret_cast< ParaMEDMEM::DataArrayChar * >(argp);
+ dacType=reinterpret_cast< MEDCoupling::DataArrayChar * >(argp);
if(!dacType)
{
std::ostringstream oss; oss << msg << " Instance in null !";
*/
static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
- ParaMEDMEM::DataArrayInt *&dt, ParaMEDMEM::DataArrayInt *&dc) throw(INTERP_KERNEL::Exception)
+ MEDCoupling::DataArrayInt *&dt, MEDCoupling::DataArrayInt *&dc) throw(INTERP_KERNEL::Exception)
{
if(!PyTuple_Check(value))
{
* if value list[int,double] -> cpp std::vector<double> sw=4
* if value tuple[int,double] -> cpp std::vector<double> sw=4
*/
-static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f)
+static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f)
{
sw=-1;
if(PyFloat_Check(value))
return;
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
if(SWIG_IsOK(status))
{
- d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
sw=2;
return ;
}
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
if(SWIG_IsOK(status))
{
- e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
+ e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
sw=3;
return ;
}
* if value list[int,double] -> cpp std::vector<double> sw=4
* if value tuple[int,double] -> cpp std::vector<double> sw=4
*/
-static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f,
+static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt) throw(INTERP_KERNEL::Exception)
{
sw=-1;
catch(INTERP_KERNEL::Exception& exc) { throw exc; }
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
if(SWIG_IsOK(status))
{
- d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
sw=2;
if(d)
{
return 0;
}
}
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
if(SWIG_IsOK(status))
{
- e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
+ e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
sw=3;
if(e->getNumberOfCompo()==nbCompExpected)
{
* if value list[int,double] -> cpp std::vector<double> sw=4
* if value tuple[int,double] -> cpp std::vector<double> sw=4
*/
-static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f,
+static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
{
sw=-1;
return &f[0];
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
if(SWIG_IsOK(status))
{
- d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
sw=2;
if(d)
{
{ nbTuples=0; return 0; }
}
}
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
if(SWIG_IsOK(status))
{
- e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
+ e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
sw=3;
if(e)
{
static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
const char *msg, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
{
- ParaMEDMEM::DataArrayDouble *d=0;
- ParaMEDMEM::DataArrayDoubleTuple *e=0;
+ MEDCoupling::DataArrayDouble *d=0;
+ MEDCoupling::DataArrayDoubleTuple *e=0;
sw=-1;
if(PyFloat_Check(value))
{
return &f[0];
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
if(SWIG_IsOK(status))
{
- d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ d=reinterpret_cast< MEDCoupling::DataArrayDouble * >(argp);
sw=2;
if(d)
{
{ nbTuples=0; return 0; }
}
}
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayDoubleTuple,0|0);
if(SWIG_IsOK(status))
{
- e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
+ e=reinterpret_cast< MEDCoupling::DataArrayDoubleTuple * >(argp);
sw=3;
if(e)
{
return &stdvecTyypp[0];
}
void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
if(SWIG_IsOK(status))
{
- ParaMEDMEM::DataArrayInt *daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
+ MEDCoupling::DataArrayInt *daIntTyypp=reinterpret_cast< MEDCoupling::DataArrayInt * >(argp);
if(daIntTyypp)
{
sw=3; sz=daIntTyypp->getNbOfElems();
return 0;
}
}
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayIntTuple,0|0);
if(SWIG_IsOK(status))
{
- ParaMEDMEM::DataArrayIntTuple *daIntTuple=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
+ MEDCoupling::DataArrayIntTuple *daIntTuple=reinterpret_cast< MEDCoupling::DataArrayIntTuple * >(argp);
sw=4; sz=daIntTuple->getNumberOfCompo();
return daIntTuple->getConstPointer();
}
throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
}
-static ParaMEDMEM::DataArray *CheckAndRetrieveDataArrayInstance(PyObject *obj, const char *msg)
+static MEDCoupling::DataArray *CheckAndRetrieveDataArrayInstance(PyObject *obj, const char *msg)
{
void *aBasePtrVS=0;
- int status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArray,0|0);
+ int status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArray,0|0);
if(!SWIG_IsOK(status))
{
- status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayDouble,0|0);
if(!SWIG_IsOK(status))
{
- status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+ status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0);
if(!SWIG_IsOK(status))
{
- status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArrayAsciiChar,0|0);
+ status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar,0|0);
if(!SWIG_IsOK(status))
{
- status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,0|0);
+ status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_MEDCoupling__DataArrayByte,0|0);
std::ostringstream oss; oss << msg << " ! Accepted instances are DataArrayDouble, DataArrayInt, DataArrayAsciiChar, DataArrayByte !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
}
}
- return reinterpret_cast< ParaMEDMEM::DataArray * >(aBasePtrVS);
+ return reinterpret_cast< MEDCoupling::DataArray * >(aBasePtrVS);
+}
+
+static PyObject *NewMethWrapCallInitOnlyIfEmptyDictInInput(PyObject *cls, PyObject *args, const char *clsName)
+{
+ if(!PyTuple_Check(args))
+ {
+ std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
+ PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
+ PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
+ //
+ PyObject *tmp0(PyTuple_New(1));
+ PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
+ PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
+ Py_DECREF(tmp0);
+ Py_DECREF(selfMeth);
+ if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==0 )
+ {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
+ PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
+ PyObject *tmp3(PyTuple_New(0));
+ PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
+ Py_XDECREF(tmp2);
+ Py_DECREF(tmp3);
+ Py_DECREF(initMeth);
+ }
+ return instance;
+}
+
+static PyObject *NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(PyObject *cls, PyObject *args, const char *clsName)
+{
+ if(!PyTuple_Check(args))
+ {
+ std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
+ PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
+ PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
+ //
+ PyObject *tmp0(PyTuple_New(1));
+ PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
+ PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
+ Py_DECREF(tmp0);
+ Py_DECREF(selfMeth);
+ if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
+ {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
+ PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
+ PyObject *zeNumpyRepr(0);
+ {
+ PyObject *tmp1(PyInt_FromLong(0));
+ zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed
+ Py_DECREF(tmp1);
+ }
+ {
+ PyObject *tmp3(PyTuple_New(1));
+ PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr);
+ PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
+ Py_XDECREF(tmp2);
+ Py_DECREF(tmp3);
+ }
+ Py_DECREF(initMeth);
+ }
+ return instance;
+}
+
+static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner) throw(INTERP_KERNEL::Exception)
+{
+ PyObject *ret=0;
+ if(!pd)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
+ if(dynamic_cast<MEDCoupling::DataArrayPartDefinition *>(pd))
+ ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__DataArrayPartDefinition,owner);
+ else
+ ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__SlicePartDefinition,owner);
+ return ret;
+}
+
+template<class T>
+static typename MEDCoupling::Traits<T>::ArrayType *DataArrayT_New(PyObject *elt0, PyObject *nbOfTuples, PyObject *elt2)
+{
+ 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)";
+ std::string msg(msgBase);
+#ifdef WITH_NUMPY
+ msg+="\n-DataArrayDouble.New(numpy array with dtype=float64)";
+#endif
+ msg+=" !";
+ if(PyList_Check(elt0) || PyTuple_Check(elt0))
+ {
+ if(nbOfTuples)
+ {
+ if(PyInt_Check(nbOfTuples))
+ {
+ int nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
+ if(nbOfTuples1<0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
+ if(elt2)
+ {
+ if(PyInt_Check(elt2))
+ {//DataArrayDouble.New([1.,3.,4.,5.],2,2)
+ int nbOfCompo=PyInt_AS_LONG(elt2);
+ if(nbOfCompo<0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
+ MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
+ std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,nbOfCompo));
+ ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
+ return ret.retn();
+ }
+ else
+ throw INTERP_KERNEL::Exception(msg.c_str());
+ }
+ else
+ {//DataArrayDouble.New([1.,3.,4.],3)
+ MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
+ int tmpp1(-1);
+ std::vector<double> tmp(fillArrayWithPyListDbl2(elt0,nbOfTuples1,tmpp1));
+ ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
+ return ret.retn();
+ }
+ }
+ else
+ throw INTERP_KERNEL::Exception(msg.c_str());
+ }
+ else
+ {// DataArrayDouble.New([1.,3.,4.])
+ MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
+ int tmpp1(-1),tmpp2(-1);
+ std::vector<double> tmp=fillArrayWithPyListDbl2(elt0,tmpp1,tmpp2);
+ ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
+ return ret.retn();
+ }
+ }
+ else if(PyInt_Check(elt0))
+ {
+ int nbOfTuples1(PyInt_AS_LONG(elt0));
+ if(nbOfTuples1<0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
+ if(nbOfTuples)
+ {
+ if(!elt2)
+ {
+ if(PyInt_Check(nbOfTuples))
+ {//DataArrayDouble.New(5,2)
+ int nbOfCompo=PyInt_AS_LONG(nbOfTuples);
+ if(nbOfCompo<0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
+ MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
+ ret->alloc(nbOfTuples1,nbOfCompo);
+ return ret.retn();
+ }
+ else
+ throw INTERP_KERNEL::Exception(msg.c_str());
+ }
+ else
+ throw INTERP_KERNEL::Exception(msg.c_str());
+ }
+ else
+ {//DataArrayDouble.New(5)
+ MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
+ ret->alloc(nbOfTuples1,1);
+ return ret.retn();
+ }
+ }
+#ifdef WITH_NUMPY
+ else if(PyArray_Check(elt0) && nbOfTuples==NULL && elt2==NULL)
+ {//DataArrayDouble.New(numpyArray)
+ return BuildNewInstance< typename MEDCoupling::Traits<T>::ArrayType , T >(elt0,NPYTraits<T>::NPYObjectType,NPYTraits<T>::NPYFunc,MEDCoupling::Traits<T>::NPYStr);
+ }
+#endif
+ else
+ throw INTERP_KERNEL::Exception(msg.c_str());
+ throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
+}
+
+template<class T>
+typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__internal(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value, swig_type_info *ti)
+{
+ self->checkAllocated();
+ const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
+ int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
+ int sw1,sw2;
+ T i1;
+ std::vector<T> v1;
+ typename MEDCoupling::Traits<T>::ArrayType *d1=0;
+ convertObjToPossibleCpp4<T>(value,sw1,i1,v1,d1,ti);
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > tmp;
+ switch(sw2)
+ {
+ case 1:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 2:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 3:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 4:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 5:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 6:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 7:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 8:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 9:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 10:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 11:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 12:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 13:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 14:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 15:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 16:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=MEDCoupling::Traits<T>::ArrayType::New();
+ tmp->useArray(&v1[0],false,MEDCoupling::CPP_DEALLOC,1,v1.size());
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ return self;
+}
+
+template<class T>
+PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, swig_type_info *ti)
+{
+ const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !";
+ const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
+ self->checkAllocated();
+ int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ MEDCoupling::DataArrayInt *dt1=0,*dc1=0;
+ int sw;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCoupling::MCAuto<typename MEDCoupling::Traits<T>::ArrayType > ret;
+ switch(sw)
+ {
+ case 1:
+ if(nbOfComponents==1)
+ return PyFloat_FromDouble((T)self->getIJSafe(it1,0));
+ return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),ti, SWIG_POINTER_OWN | 0 );
+ case 2:
+ return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size())),ti, SWIG_POINTER_OWN | 0 );
+ case 3:
+ return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second)),ti, SWIG_POINTER_OWN | 0 );
+ case 4:
+ return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),ti, SWIG_POINTER_OWN | 0 );
+ case 5:
+ return PyFloat_FromDouble((T)self->getIJSafe(it1,ic1));
+ case 6:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ std::vector<int> v2(1,ic1);
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 7:
+ {
+ ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
+ std::vector<int> v2(1,ic1);
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 8:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ std::vector<int> v2(1,ic1);
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 9:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 10:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 11:
+ {
+ ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 12:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(vc1)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 13:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 14:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 15:
+ {
+ ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
+ int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ case 16:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret->keepSelectedComponents(v2)),ti, SWIG_POINTER_OWN | 0 );
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
+
+template<class T>
+struct SWIGTITraits
+{ };
+
+template<>
+struct SWIGTITraits<double>
+{ static swig_type_info *TI; };
+
+template<>
+struct SWIGTITraits<float>
+{ static swig_type_info *TI; };
+
+swig_type_info *SWIGTITraits<double>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayDouble is null when called here ! Postpone initialization at inlined initializeMe()
+swig_type_info *SWIGTITraits<float>::TI=NULL;//unfortunately SWIGTYPE_p_MEDCoupling__DataArrayFloat is null when called here ! Postpone initialization at inlined initializeMe()
+
+PyTypeObject *NPYTraits<double>::NPYFunc=&PyCallBackDataArrayDouble_RefType;
+
+PyTypeObject *NPYTraits<float>::NPYFunc=&PyCallBackDataArrayFloat_RefType;
+
+template<class T>
+typename MEDCoupling::Traits<T>::ArrayType *DataArrayT__setitem__(typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj, PyObject *value)
+{
+ return DataArrayT__setitem__internal<T>(self,obj,value,SWIGTITraits<T>::TI);
+}
+
+template<class T>
+PyObject *DataArrayT__getitem(const typename MEDCoupling::Traits<T>::ArrayType *self, PyObject *obj)
+{
+ return DataArrayT__getitem__internal<T>(self,obj,SWIGTITraits<T>::TI);
+}
+
+#endif