From aaa619923c7f907d6b337a09e855e02395793cdf Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 6 Jul 2010 09:17:49 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDLoader/Swig/libMEDLoader_Swig.i | 38 ++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/MEDLoader/Swig/libMEDLoader_Swig.i b/src/MEDLoader/Swig/libMEDLoader_Swig.i index 5a5b6087a..147334ac0 100644 --- a/src/MEDLoader/Swig/libMEDLoader_Swig.i +++ b/src/MEDLoader/Swig/libMEDLoader_Swig.i @@ -34,7 +34,9 @@ #endif %newobject MEDLoader::ReadUMeshFromFile; +%newobject MEDLoader::ReadFieldDouble; %newobject MEDLoader::ReadFieldDoubleCell; +%newobject MEDLoader::ReadFieldDoubleNode; class MEDLoader { @@ -46,9 +48,38 @@ public: static std::vector GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName); %extend { - static PyObject *GetCellFieldIterations(const char *fileName, const char *fieldName) + static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) { - std::vector< std::pair > res=MEDLoader::GetCellFieldIterations(fileName,fieldName); + std::vector< std::pair > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName); + PyObject *ret=PyList_New(res.size()); + int rk=0; + for(std::vector< std::pair >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) + { + PyObject *elt=PyTuple_New(2); + PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first)); + PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second)); + PyList_SetItem(ret,rk,elt); + } + return ret; + } + + static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) + { + std::vector< std::pair > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName); + PyObject *ret=PyList_New(res.size()); + int rk=0; + for(std::vector< std::pair >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) + { + PyObject *elt=PyTuple_New(2); + PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first)); + PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second)); + PyList_SetItem(ret,rk,elt); + } + return ret; + } + static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) + { + std::vector< std::pair > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName); PyObject *ret=PyList_New(res.size()); int rk=0; for(std::vector< std::pair >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) @@ -61,10 +92,11 @@ public: return ret; } } - //std::vector< std::pair > GetNodeFieldIterations(const char *fileName, const char *fieldName); static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDouble(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); + static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); static void WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch); static void WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch); static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f); -- 2.39.2