From: Anthony Geay Date: Wed, 29 Apr 2020 22:19:40 +0000 (+0200) Subject: MEDFileUMesh.LoadPartCoords is OK X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fagy%2Fpara_mesh_opt_3;p=tools%2Fmedcoupling.git MEDFileUMesh.LoadPartCoords is OK --- diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index f3d05fa5e..91eb1d774 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -2478,6 +2478,13 @@ MEDFileUMesh *MEDFileUMesh::LoadPartOf(med_idt fid, const std::string& mName, co return ret.retn(); } +void MEDFileUMesh::LoadPartCoords(const std::string& fileName, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax, +MCAuto& coords, MCAuto& partCoords, MCAuto& famCoords, MCAuto& numCoords, MCAuto& nameCoords) +{ + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUMeshL2::LoadPartCoords(fid,infosOnComp,mName,dt,it,nMin,nMax,coords,partCoords,famCoords,numCoords,nameCoords); +} + std::size_t MEDFileUMesh::getHeapMemorySizeWithoutChildren() const { std::size_t ret(MEDFileMesh::getHeapMemorySizeWithoutChildren()); diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index b966a04a0..c621b9e34 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -268,6 +268,8 @@ namespace MEDCoupling MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileUMesh"); } MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(med_idt fid, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static void LoadPartCoords(const std::string& fileName, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax, +MCAuto& coords, MCAuto& partCoords, MCAuto& famCoords, MCAuto& numCoords, MCAuto& nameCoords); MEDLOADER_EXPORT static const char *GetSpeStr4ExtMesh() { return SPE_FAM_STR_EXTRUDED_MESH; } MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 5b4704df1..e9d3f2d14 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -648,7 +648,8 @@ void MEDFileUMeshL2::loadCoords(med_idt fid, const std::vector& inf _coords->setInfoOnComponent(i,infosOnComp[i]); } -void MEDFileUMeshL2::loadPartCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax) +void MEDFileUMeshL2::LoadPartCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax, +MCAuto& _coords, MCAuto& _part_coords, MCAuto& _fam_coords, MCAuto& _num_coords, MCAuto& _name_coords) { med_bool changement,transformation; med_int spaceDim((int)infosOnComp.size()),nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); @@ -673,7 +674,7 @@ void MEDFileUMeshL2::loadPartCoords(med_idt fid, const std::vector& _fam_coords=FromMedIntArray(miFamCoord); } else - _fam_coords=0; + _fam_coords=nullptr; if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0) { MCAuto miNumCoord=DataArrayMedInt::New(); @@ -682,7 +683,7 @@ void MEDFileUMeshL2::loadPartCoords(med_idt fid, const std::vector& _num_coords=FromMedIntArray(miNumCoord); } else - _num_coords=0; + _num_coords=nullptr; if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0) { _name_coords=DataArrayAsciiChar::New(); @@ -691,11 +692,16 @@ void MEDFileUMeshL2::loadPartCoords(med_idt fid, const std::vector& _name_coords->reAlloc(nbNodesToLoad);//not a bug to avoid the memory corruption due to last \0 at the end } else - _name_coords=0; + _name_coords=nullptr; MEDfilterClose(&filter2); _coords->setInfoOnComponents(infosOnComp); } +void MEDFileUMeshL2::loadPartCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax) +{ + LoadPartCoords(fid,infosOnComp,mName,dt,it,nMin,nMax,_coords,_part_coords,_fam_coords,_num_coords,_name_coords); +} + void MEDFileUMeshL2::sortTypes() { std::set mdims; diff --git a/src/MEDLoader/MEDFileMeshLL.hxx b/src/MEDLoader/MEDFileMeshLL.hxx index 2abe8819a..7552e158f 100644 --- a/src/MEDLoader/MEDFileMeshLL.hxx +++ b/src/MEDLoader/MEDFileMeshLL.hxx @@ -137,6 +137,8 @@ namespace MEDCoupling MCAuto getCoordsGlobalNum() const { return _global_num_coords; } MCAuto getCoordsName() const { return _name_coords; } static void WriteCoords(med_idt fid, const std::string& mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayIdType *famCoords, const DataArrayIdType *numCoords, const DataArrayAsciiChar *nameCoords, const DataArrayIdType *globalNumCoords); + static void LoadPartCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax, +MCAuto& _coords, MCAuto& _part_coords, MCAuto& _fam_coords, MCAuto& _num_coords, MCAuto& _name_coords); private: void sortTypes(); private: diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 4ff7d28cc..782723003 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -1457,6 +1457,22 @@ namespace MEDCoupling return MEDFileUMesh::LoadPartOf(fileName,mName,typesCpp2,slicPerTyp,dt,it,mrs); } + static PyObject *LoadPartCoords(const std::string& fileName, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax) + { + MCAuto coords; + MCAuto partCoords; + MCAuto famCoords,numCoords; + MCAuto nameCoord; + MEDFileUMesh::LoadPartCoords(fileName,infosOnComp,mName,dt,it,nMin,nMax,coords,partCoords,famCoords,numCoords,nameCoord); + PyObject *ret(PyTuple_New(5)); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(coords.retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,convertPartDefinition(partCoords.retn(),SWIG_POINTER_OWN | 0)); + PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(famCoords.retn()),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(numCoords.retn()),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(nameCoord.retn()),SWIGTYPE_p_MEDCoupling__DataArrayAsciiChar, SWIG_POINTER_OWN | 0 )); + return ret; + } + PyObject *__getstate__() { std::vector a0;