- throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayIntTuple");
- daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
- sw=4;
-}
-
-/*!
- * if value int -> cpp it sw=1
- * if value list[int] -> vt sw=2
- * if value tuple[int] -> vt sw=2
- * if value slice -> pt sw=3
- * if value DataArrayInt -> dt sw=4
- * if value tuple [int,int] -> cpp it,ip sw=5
- * if value tuple [list[int],int] -> cpp vt,ip sw=6
- * if value tuple [tuple[int],int] -> cpp vt,ip sw=6
- * if value tuple [slice,int] -> cpp pt,ip sw=7
- * if value tuple [DaI,int] -> cpp dt,ip sw=8
- * if value tuple [int,list[int]] -> cpp it,vc sw=9
- * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10
- * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10
- * if value tuple [slice,list[int]] -> cpp pt,vc sw=11
- * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12
- * if value tuple [int,tuple[int]] -> cpp it,vc sw=9
- * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10
- * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10
- * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11
- * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12
- * if value tuple [int,slice] -> cpp it,pc sw=13
- * if value tuple [list[int],slice] -> cpp vt,pc sw=14
- * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14
- * if value tuple [slice,slice] -> cpp pt,pc sw=15
- * if value tuple [DaI,slice] -> cpp dt,pc sw=16
- *
- * switch between (int,vector<int>,DataArrayInt)
- */
-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)
-{
- if(!PyTuple_Check(value))
- {
- convertObjToPossibleCpp2(value,nbTuple,sw,it,vt,pt,dt);
- return ;
- }
- else
- {
- int sz=PyTuple_Size(value);
- if(sz!=2)
- throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
- PyObject *ob0=PyTuple_GetItem(value,0);
- int sw1,sw2;
- convertObjToPossibleCpp2(ob0,nbTuple,sw1,it,vt,pt,dt);
- PyObject *ob1=PyTuple_GetItem(value,1);
- convertObjToPossibleCpp2(ob1,nbCompo,sw2,ic,vc,pc,dc);
- sw=4*sw2+sw1;
- }
-}
-
-/*!
- * if value int -> cpp val sw=1
- * if value double -> cpp val sw=1
- * if value DataArrayDouble -> cpp DataArrayDouble sw=2
- * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
- * 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)
-{
- sw=-1;
- if(PyFloat_Check(value))
- {
- val=PyFloat_AS_DOUBLE(value);
- sw=1;
- return;
- }
- if(PyInt_Check(value))
- {
- val=(double)PyInt_AS_LONG(value);
- sw=1;
- return;
- }
- if(PyTuple_Check(value))
- {
- int size=PyTuple_Size(value);
- f.resize(size);
- for(int i=0;i<size;i++)
- {
- PyObject *o=PyTuple_GetItem(value,i);
- if(PyFloat_Check(o))
- f[i]=PyFloat_AS_DOUBLE(o);
- else if(PyInt_Check(o))
- f[i]=(double)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 !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- sw=4;
- return;
- }
- if(PyList_Check(value))
- {
- int size=PyList_Size(value);
- f.resize(size);
- for(int i=0;i<size;i++)
- {
- PyObject *o=PyList_GetItem(value,i);
- if(PyFloat_Check(o))
- f[i]=PyFloat_AS_DOUBLE(o);
- else if(PyInt_Check(o))
- f[i]=(double)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 !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- sw=4;
- return;
- }
- void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
- if(SWIG_IsOK(status))
- {
- d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
- sw=2;
- return ;
- }
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
- if(SWIG_IsOK(status))
- {
- e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
- sw=3;
- return ;
- }
- throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
-}
-
-/*!
- * if value int -> cpp val sw=1
- * if value double -> cpp val sw=1
- * if value DataArrayDouble -> cpp DataArrayDouble sw=2
- * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
- * 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,
- const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt) throw(INTERP_KERNEL::Exception)
-{
- sw=-1;
- if(PyFloat_Check(value))
- {
- val=PyFloat_AS_DOUBLE(value);
- sw=1;
- if(nbTuplesExpected*nbCompExpected!=1)
- {
- std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- return &val;
- }
- if(PyInt_Check(value))
- {
- val=(double)PyInt_AS_LONG(value);
- sw=1;
- if(nbTuplesExpected*nbCompExpected!=1)
- {
- std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- return &val;
- }
- if(PyTuple_Check(value) || PyList_Check(value))
- {
- try
- {
- int tmp1=nbTuplesExpected,tmp2=nbCompExpected;
- std::vector<double> ret=fillArrayWithPyListDbl2(value,tmp1,tmp2);
- sw=4;
- f=ret;
- return &f[0];
- }
- catch(INTERP_KERNEL::Exception& e) { throw e; }
- }
- void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
- if(SWIG_IsOK(status))
- {
- d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
- sw=2;
- if(d)
- {
- if(d->getNumberOfTuples()==nbTuplesExpected)
- {
- if(d->getNumberOfComponents()==nbCompExpected)
- {
- return d->getConstPointer();
- }
- else
- {
- std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- {
- std::ostringstream oss; oss << msg << " input DataArrayDouble should have a number of tuples equal to " << nbTuplesExpected << " and there are " << d->getNumberOfTuples() << " tuples !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- {
- if(throwIfNullPt)
- {
- std::ostringstream oss; oss << msg << " null pointer not accepted!";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- else
- return 0;
- }
- }
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
- if(SWIG_IsOK(status))
- {
- e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
- sw=3;
- if(e->getNumberOfCompo()==nbCompExpected)
- {
- if(nbTuplesExpected==1)
- return e->getConstPointer();
- else
- {
- std::ostringstream oss; oss << msg << "nb of tuples expected to be " << nbTuplesExpected << " , and input DataArrayDoubleTuple has always one tuple by contruction !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- {
- std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
-}
-
-/*!
- * if value int -> cpp val sw=1
- * if value double -> cpp val sw=1
- * if value DataArrayDouble -> cpp DataArrayDouble sw=2
- * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
- * 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,
- const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
-{
- sw=-1;
- if(PyFloat_Check(value))
- {
- val=PyFloat_AS_DOUBLE(value);
- sw=1;
- if(nbCompExpected!=1)
- {
- std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- nbTuples=1;
- return &val;
- }
- if(PyInt_Check(value))
- {
- val=(double)PyInt_AS_LONG(value);
- sw=1;
- if(nbCompExpected!=1)
- {
- std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- nbTuples=1;
- return &val;
- }
- if(PyTuple_Check(value))
- {
- int size=PyTuple_Size(value);
- f.resize(size);
- for(int i=0;i<size;i++)
- {
- PyObject *o=PyTuple_GetItem(value,i);
- if(PyFloat_Check(o))
- f[i]=PyFloat_AS_DOUBLE(o);
- else if(PyInt_Check(o))
- f[i]=(double)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 !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- sw=4;
- if(size%nbCompExpected!=0)
- {
- std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- nbTuples=size/nbCompExpected;
- return &f[0];
- }
- if(PyList_Check(value))
- {
- int size=PyList_Size(value);
- f.resize(size);
- for(int i=0;i<size;i++)
- {
- PyObject *o=PyList_GetItem(value,i);
- if(PyFloat_Check(o))
- f[i]=PyFloat_AS_DOUBLE(o);
- else if(PyInt_Check(o))
- f[i]=(double)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 !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- sw=4;
- if(size%nbCompExpected!=0)
- {
- std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- nbTuples=size/nbCompExpected;
- return &f[0];
- }
- void *argp;
- int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
- if(SWIG_IsOK(status))
- {
- d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
- sw=2;
- if(d)
- {
- if(d->getNumberOfComponents()==nbCompExpected)
- {
- nbTuples=d->getNumberOfTuples();
- return d->getConstPointer();
- }
- else
- {
- std::ostringstream oss; oss << msg << "nb of components expected to be a multiple of " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- {
- if(throwIfNullPt)
- {
- std::ostringstream oss; oss << msg << " null pointer not accepted!";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- else
- return 0;
- }
- }
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
- if(SWIG_IsOK(status))
- {
- e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
- sw=3;
- if(e->getNumberOfCompo()==nbCompExpected)
- {
- nbTuples=1;
- return e->getConstPointer();
- }
- else
- {
- std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");