From: Anthony Geay Date: Mon, 27 Aug 2018 15:55:00 +0000 (+0200) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7484b0f70252b52ef920f5233ae24279aa357591;p=tools%2Fmedcoupling.git WIP --- diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index fcbe7d8eb..304801ca2 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -1317,21 +1317,29 @@ std::vector MEDCoupling::ReadFieldsGaussN return ReadFieldsOnSameMesh(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,its); } +namespace MEDCoupling +{ + MEDCoupling::MEDCouplingFieldDouble *ReadFieldCellLike(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) + { + MCAuto ff(MEDFileField1TS::New(fileName,fieldName,iteration,order)); + MCAuto mm(MEDFileMesh::New(fileName,meshName)); + MCAuto m(mm->getMeshAtLevel(meshDimRelToMax,false)); + MEDFileMesh *mPtr(mm); + MEDFileUMesh *muPtr=dynamic_cast(mPtr); + MCAuto ret(ff->getFieldOnMeshAtLevel(type,m)); + if(muPtr) + { + const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax)); + if(num) + ret->renumberCells(num->begin()); + } + return ret.retn(); + } +} + MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) { - MCAuto ff(MEDFileField1TS::New(fileName,fieldName,iteration,order)); - MCAuto mm(MEDFileMesh::New(fileName,meshName)); - MCAuto m(mm->getMeshAtLevel(meshDimRelToMax,false)); - MEDFileMesh *mPtr(mm); - MEDFileUMesh *muPtr=dynamic_cast(mPtr); - MCAuto ret(ff->getFieldOnMeshAtLevel(ON_CELLS,m)); - if(muPtr) - { - const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax)); - if(num) - ret->renumberCells(num->begin()); - } - return ret.retn(); + return ReadFieldCellLike(ON_CELLS,fileName,meshName,meshDimRelToMax,fieldName,iteration,order); } MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) @@ -1378,36 +1386,12 @@ MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldNode(const std::strin MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) { - MCAuto ff(MEDFileField1TS::New(fileName,fieldName,iteration,order)); - MCAuto mm(MEDFileMesh::New(fileName,meshName)); - MCAuto m(mm->getMeshAtLevel(meshDimRelToMax,false)); - MEDFileMesh *mPtr(mm); - MEDFileUMesh *muPtr=dynamic_cast(mPtr); - MCAuto ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_PT,m)); - if(muPtr) - { - const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax)); - if(num) - ret->renumberCells(num->begin()); - } - return ret.retn(); + return ReadFieldCellLike(ON_GAUSS_PT,fileName,meshName,meshDimRelToMax,fieldName,iteration,order); } MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) { - MCAuto ff(MEDFileField1TS::New(fileName,fieldName,iteration,order)); - MCAuto mm(MEDFileMesh::New(fileName,meshName)); - MCAuto m(mm->getMeshAtLevel(meshDimRelToMax,false)); - MEDFileMesh *mPtr(mm); - MEDFileUMesh *muPtr=dynamic_cast(mPtr); - MCAuto ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_NE,m)); - if(muPtr) - { - const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax)); - if(num) - ret->renumberCells(num->begin()); - } - return ret.retn(); + return ReadFieldCellLike(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,iteration,order); } void MEDCoupling::WriteMesh(const std::string& fileName, const MEDCoupling::MEDCouplingMesh *mesh, bool writeFromScratch)