// Copyright (C) 2007-2013 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 // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // Author : Anthony Geay (CEA/DEN) #include static PyObject* convertMEDFileMesh(ParaMEDMEM::MEDFileMesh* mesh, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; if(dynamic_cast(mesh)) ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileUMesh,owner); if(dynamic_cast(mesh)) ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileCMesh,owner); if(dynamic_cast(mesh)) ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileCurveLinearMesh,owner); if(!ret) throw INTERP_KERNEL::Exception("Not recognized type of MEDFileMesh on downcast !"); return ret; } static PyObject* convertMEDFileParameter1TS(ParaMEDMEM::MEDFileParameter1TS* p1ts, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; if(dynamic_cast(p1ts)) ret=SWIG_NewPointerObj((void*)p1ts,SWIGTYPE_p_ParaMEDMEM__MEDFileParameterDouble1TS,owner); if(dynamic_cast(p1ts)) ret=SWIG_NewPointerObj((void*)p1ts,SWIGTYPE_p_ParaMEDMEM__MEDFileParameterDouble1TSWTI,owner); if(!ret) throw INTERP_KERNEL::Exception("Not recognized type of MEDFileParameter1TS on downcast !"); return ret; } static std::vector > convertTimePairIdsFromPy(PyObject *pyLi) throw(INTERP_KERNEL::Exception) { std::vector > ret; if(PyList_Check(pyLi)) { int size=PyList_Size(pyLi); ret.resize(size); for(int i=0;i p; int size2=PyTuple_Size(o); if(size2!=2) throw INTERP_KERNEL::Exception("tuples in list must be of size 2 (dt,it) !"); PyObject *o0=PyTuple_GetItem(o,0); if(PyInt_Check(o0)) p.first=(int)PyInt_AS_LONG(o0); else throw INTERP_KERNEL::Exception("First elem of tuples in list must be integer : dt !"); PyObject *o1=PyTuple_GetItem(o,1); if(PyInt_Check(o1)) p.second=(int)PyInt_AS_LONG(o1); else throw INTERP_KERNEL::Exception("Second elem of tuples in list must be integer : dt !"); ret[i]=p; } else throw INTERP_KERNEL::Exception("list must contain tuples only"); } } else throw INTERP_KERNEL::Exception("convertTimePairIdsFromPy : not a list"); return ret; } static void converPyListToVecString(PyObject *pyLi, std::vector& v) { if(PyList_Check(pyLi)) { int size=PyList_Size(pyLi); v.resize(size); for(int i=0;i& li) { int sz=li.size(); PyObject *ret=PyList_New(sz); for(int i=0;i, std::string > >& vec) { int sz=(int)vec.size(); PyObject *ret=PyList_New(sz); for(int i=0;i > convertVecPairStStFromPy(PyObject *pyLi) { std::vector< std::pair > ret; const char *msg="convertVecPairStStFromPy : Expecting PyList of Tuples of size 2 ! The first elt in tuple is one string and the 2nd one a string !"; if(PyList_Check(pyLi)) { int size=PyList_Size(pyLi); ret.resize(size); for(int i=0;i p; int size2=PyTuple_Size(o); if(size2!=2) throw INTERP_KERNEL::Exception(msg); PyObject *o0=PyTuple_GetItem(o,0); if(PyString_Check(o0)) p.second=std::string(PyString_AsString(o0)); else throw INTERP_KERNEL::Exception(msg); PyObject *o1=PyTuple_GetItem(o,1); if(PyString_Check(o1)) p.second=std::string(PyString_AsString(o1)); else throw INTERP_KERNEL::Exception(msg); ret[i]=p; } else throw INTERP_KERNEL::Exception(msg); } return ret; } throw INTERP_KERNEL::Exception(msg); } std::vector< std::pair, std::string > > convertVecPairVecStFromPy(PyObject *pyLi) { std::vector< std::pair, std::string > > ret; const char *msg="convertVecPairVecStFromPy : Expecting PyList of Tuples of size 2 ! The first elt in tuple is a list of strings and the 2nd one a string !"; if(PyList_Check(pyLi)) { int size=PyList_Size(pyLi); ret.resize(size); for(int i=0;i, std::string> p; int size2=PyTuple_Size(o); if(size2!=2) throw INTERP_KERNEL::Exception(msg); PyObject *o0=PyTuple_GetItem(o,0); if(PyList_Check(o0)) { int size2=PyList_Size(o0); p.first.resize(size2); for(int j=0;j