From: Anthony Geay Date: Wed, 18 Jan 2017 15:28:26 +0000 (+0100) Subject: After meshsupport the struture elements... X-Git-Tag: V8_3_0a2~38^2~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b22dfe1adf8544bb427331b2884e24f422675e83;p=tools%2Fmedcoupling.git After meshsupport the struture elements... --- diff --git a/src/MEDLoader/CMakeLists.txt b/src/MEDLoader/CMakeLists.txt index 78a427e02..eb670a399 100644 --- a/src/MEDLoader/CMakeLists.txt +++ b/src/MEDLoader/CMakeLists.txt @@ -70,6 +70,7 @@ SET(medloader_SOURCES MEDFileFieldOverView.cxx MEDFileMeshReadSelector.cxx MEDFileMeshSupport.cxx + MEDFileStructureElement.cxx SauvMedConvertor.cxx SauvReader.cxx SauvWriter.cxx diff --git a/src/MEDLoader/MEDFileData.cxx b/src/MEDLoader/MEDFileData.cxx index f5a33b391..95db854ad 100644 --- a/src/MEDLoader/MEDFileData.cxx +++ b/src/MEDLoader/MEDFileData.cxx @@ -70,6 +70,7 @@ std::vector MEDFileData::getDirectChildrenWithNull() co ret.push_back((const MEDFileMeshes *)_meshes); ret.push_back((const MEDFileParameters *)_params); ret.push_back((const MEDFileMeshSupports *)_mesh_supports); + ret.push_back((const MEDFileStructureElements *)_struct_elems); return ret; } @@ -310,6 +311,7 @@ try _meshes=MEDFileMeshes::New(fid); _params=MEDFileParameters::New(fid); _mesh_supports=MEDFileMeshSupports::New(fid); + _struct_elems=MEDFileStructureElements::New(fid); } catch(INTERP_KERNEL::Exception& e) { @@ -327,6 +329,8 @@ void MEDFileData::writeLL(med_idt fid) const _params->writeLL(fid); if(_mesh_supports.isNotNull()) _mesh_supports->writeLL(fid); + if(_struct_elems.isNotNull()) + _struct_elems->writeLL(fid); } std::string MEDFileData::getHeader() const diff --git a/src/MEDLoader/MEDFileData.hxx b/src/MEDLoader/MEDFileData.hxx index e2dbfb799..f9713a86b 100644 --- a/src/MEDLoader/MEDFileData.hxx +++ b/src/MEDLoader/MEDFileData.hxx @@ -26,6 +26,7 @@ #include "MEDFileField.hxx" #include "MEDFileMesh.hxx" #include "MEDFileMeshSupport.hxx" +#include "MEDFileStructureElement.hxx" namespace MEDCoupling { @@ -73,6 +74,7 @@ namespace MEDCoupling MCAuto _meshes; MCAuto _params; MCAuto _mesh_supports; + MCAuto _struct_elems; std::string _header; }; } diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index fae586ac4..24b61d534 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -34,6 +34,8 @@ #include #include +extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO]; +extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO]; extern med_geometry_type typmai3[34]; using namespace MEDCoupling; @@ -7397,3 +7399,14 @@ MEDFileMesh *MEDFileMeshesIterator::nextt() else return 0; } + +INTERP_KERNEL::NormalizedCellType MEDFileMesh::ConvertFromMEDFile(med_geometry_type geoType) +{ + med_geometry_type *pos(std::find(typmai,typmai+MED_N_CELL_FIXED_GEO,geoType)); + if(pos==typmai+MED_N_CELL_FIXED_GEO) + { + std::ostringstream oss; oss << "MEDFileMesh::ConvertFromMEDFile : no entry with " << geoType << " !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + return typmai2[std::distance(typmai,pos)]; +} diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index de52190bf..88c859a3b 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -195,6 +195,7 @@ namespace MEDCoupling const MEDFileEquivalences *getEquivalences() const { return _equiv; } void killEquivalences() { _equiv=(MEDFileEquivalences *)0; } void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); } + static INTERP_KERNEL::NormalizedCellType ConvertFromMEDFile(med_geometry_type geoType); protected: MEDFileMesh(); //! protected because no way in MED file API to specify this name diff --git a/src/MEDLoader/MEDFileStructureElement.cxx b/src/MEDLoader/MEDFileStructureElement.cxx new file mode 100644 index 000000000..140c9e9cc --- /dev/null +++ b/src/MEDLoader/MEDFileStructureElement.cxx @@ -0,0 +1,92 @@ +// Copyright (C) 2007-2017 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, or (at your option) any later version. +// +// 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 (EDF R&D) + +#include "MEDFileStructureElement.hxx" +#include "MEDLoaderBase.hxx" +#include "MEDFileMeshLL.hxx" +#include "MEDFileSafeCaller.txx" + +#include "InterpKernelAutoPtr.hxx" + +using namespace MEDCoupling; + +MEDFileStructureElement *MEDFileStructureElement::New(med_idt fid, int idSE) +{ + return new MEDFileStructureElement(fid,idSE); +} + +MEDFileStructureElement::MEDFileStructureElement(med_idt fid, int idSE) +{ + INTERP_KERNEL::AutoPtr modelName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),supportMeshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + med_geometry_type sgeoType; + med_entity_type entiyType; + int nConsAttr(0),nVarAttr(0); + { + med_bool anyPfl; + int nnode(0),ncell(0); + MEDstructElementInfo(fid,idSE+1,modelName,&_id_type,&_dim,supportMeshName,&entiyType,&nnode,&ncell,&sgeoType,&nConsAttr,&anyPfl,&nVarAttr); + } + _model_name=MEDLoaderBase::buildStringFromFortran(modelName,MED_NAME_SIZE); + _geo_type=MEDFileMesh::ConvertFromMEDFile(sgeoType); +} + +MEDFileStructureElements *MEDFileStructureElements::New(med_idt fid) +{ + return new MEDFileStructureElements(fid); +} + +MEDFileStructureElements *MEDFileStructureElements::New() +{ + return new MEDFileStructureElements; +} + +std::vector MEDFileStructureElements::getDirectChildrenWithNull() const +{ + std::vector ret; + for(std::vector< MCAuto >::const_iterator it=_elems.begin();it!=_elems.end();it++) + ret.push_back(*it); + return ret; +} + +std::size_t MEDFileStructureElements::getHeapMemorySizeWithoutChildren() const +{ + return _elems.capacity()*sizeof(MEDFileStructureElement); +} + +void MEDFileStructureElements::writeLL(med_idt fid) const +{ +} + +MEDFileStructureElements::MEDFileStructureElements(med_idt fid) +{ + int nbSE(MEDnStructElement(fid)); + _elems.resize(nbSE); + for(int i=0;i getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const; + void writeLL(med_idt fid) const; + private: + MEDFileStructureElement(med_idt fid, int idSE); + private: + int _id_type; + std::string _model_name; + INTERP_KERNEL::NormalizedCellType _geo_type; + int _dim; + }; + + class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone + { + public: + MEDLOADER_EXPORT static MEDFileStructureElements *New(med_idt fid); + MEDLOADER_EXPORT static MEDFileStructureElements *New(); + public: + std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const; + void writeLL(med_idt fid) const; + private: + MEDFileStructureElements(med_idt fid); + MEDFileStructureElements(); + ~MEDFileStructureElements(); + private: + std::vector< MCAuto > _elems; + }; +} + +#endif