X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileMeshSupport.cxx;h=c1fb5c051c7b8ee8b05625dbf3244940d2d280aa;hb=88916ccf9c681624b682d10a62c1ee376324c946;hp=15dcaadc77765d674793f25eb90253f4d033c865;hpb=bcd51c51ef9f0373bf70a4aceb2638003545603e;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileMeshSupport.cxx b/src/MEDLoader/MEDFileMeshSupport.cxx index 15dcaadc7..c1fb5c051 100644 --- a/src/MEDLoader/MEDFileMeshSupport.cxx +++ b/src/MEDLoader/MEDFileMeshSupport.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2017 CEA/DEN, EDF R&D +// Copyright (C) 2007-2019 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 @@ -27,6 +27,12 @@ using namespace MEDCoupling; +MEDFileMeshSupports *MEDFileMeshSupports::New(const std::string& fileName) +{ + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid); +} + MEDFileMeshSupports *MEDFileMeshSupports::New(med_idt fid) { return new MEDFileMeshSupports(fid); @@ -83,3 +89,53 @@ void MEDFileMeshSupports::writeLL(med_idt fid) const if((*it).isNotNull()) (*it)->writeLL(fid); } + +std::vector MEDFileMeshSupports::getSupMeshNames() const +{ + std::vector ret; + for(std::vector< MCAuto >::const_iterator it=_supports.begin();it!=_supports.end();it++) + if((*it).isNotNull()) + ret.push_back((*it)->getName()); + return ret; +} + +const MEDFileUMesh *MEDFileMeshSupports::getSupMeshWithName(const std::string& name) const +{ + std::vector mns; + for(std::vector< MCAuto >::const_iterator it=_supports.begin();it!=_supports.end();it++) + { + if((*it).isNotNull()) + { + std::string na((*it)->getName()); + if(na==name) + return *it; + else + mns.push_back(na); + } + } + std::ostringstream oss; + oss << "MEDFileMeshSupports::getSupMeshWithName : no such name \"" << name << "\". Possibilities are :"; + std::copy(mns.begin(),mns.end(),std::ostream_iterator(oss,",")); + oss << " !"; + throw INTERP_KERNEL::Exception(oss.str()); +} + +int MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const +{ + const MEDFileUMesh *sup(getSupMeshWithName(name)); + switch(entity) + { + case ON_NODES: + return sup->getNumberOfNodes(); + case ON_CELLS: + { + std::vector gt(sup->getAllGeoTypes()); + if(gt.size()!=1) + throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : on cells only one geometric type allowed !"); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt[0])); + return sup->getNumberOfCellsAtLevel(0)*cm.getNumberOfNodes(); + } + default: + throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : not recognized entity type !"); + } +}