X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileMeshSupport.cxx;h=5e1697ab9cf50c055d6e57144c0492eb5441da52;hb=662a2a2393a25baef77e42f74204b11b70a9646c;hp=1e101c0c29655c35f65f5219b026b38063804fa1;hpb=5d5f680dee17d1bae83f6b756358bd5af512d4e4;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileMeshSupport.cxx b/src/MEDLoader/MEDFileMeshSupport.cxx index 1e101c0c2..5e1697ab9 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-2023 CEA, EDF // // 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); @@ -39,16 +45,16 @@ MEDFileMeshSupports *MEDFileMeshSupports::New() MEDFileMeshSupports::MEDFileMeshSupports(med_idt fid) { - int nbSM(MEDnSupportMesh(fid)); + med_int nbSM(MEDnSupportMesh(fid)); _supports.resize(nbSM); for(int i=0;i msn(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr description(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); med_axis_type axType; - int nAxis(MEDsupportMeshnAxis(fid,i+1)); + med_int nAxis(MEDsupportMeshnAxis(fid,i+1)); INTERP_KERNEL::AutoPtr axisName(new char[MED_SNAME_SIZE*nAxis+1]),axisUnit(new char[MED_SNAME_SIZE*nAxis+1]); - int spaceDim(0),meshDim(0); + med_int spaceDim(0),meshDim(0); MEDFILESAFECALLERRD0(MEDsupportMeshInfo,(fid,i+1,msn,&spaceDim,&meshDim,description,&axType,axisName,axisUnit)); std::string name(MEDLoaderBase::buildStringFromFortran(msn,MED_NAME_SIZE)); _supports[i]=MEDFileUMesh::New(fid,name); @@ -84,6 +90,15 @@ void MEDFileMeshSupports::writeLL(med_idt fid) const (*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; @@ -99,14 +114,28 @@ const MEDFileUMesh *MEDFileMeshSupports::getSupMeshWithName(const std::string& n } } std::ostringstream oss; - oss << "MEDFileMeshSupports::getSupMeshWithName : no such name \"" << name << "\". Possibilitities are :"; + 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::getNumberOfNodesPerCellOf(const std::string& name) const +mcIdType MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, INTERP_KERNEL::NormalizedCellType gt, const std::string& name) const { const MEDFileUMesh *sup(getSupMeshWithName(name)); - return sup->getNumberOfNodes(); + switch(entity) + { + case ON_NODES: + return sup->getNumberOfNodes(); + case ON_CELLS: + { + std::vector gts(sup->getAllGeoTypes()); + if(std::find(gts.begin(),gts.end(),gt) == gts.end()) + throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : specified geometric type not found !"); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt)); + return sup->getNumberOfCellsWithType(gt)*cm.getNumberOfNodes(); + } + default: + throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : not recognized entity type !"); + } }