1 // Copyright (C) 2007-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #include "MEDFileMeshSupport.hxx"
22 #include "MEDLoaderBase.hxx"
23 #include "MEDFileMeshLL.hxx"
24 #include "MEDFileSafeCaller.txx"
26 #include "InterpKernelAutoPtr.hxx"
28 using namespace MEDCoupling;
30 MEDFileMeshSupports *MEDFileMeshSupports::New(med_idt fid)
32 return new MEDFileMeshSupports(fid);
35 MEDFileMeshSupports *MEDFileMeshSupports::New()
37 return new MEDFileMeshSupports;
40 MEDFileMeshSupports::MEDFileMeshSupports(med_idt fid)
42 int nbSM(MEDnSupportMesh(fid));
43 _supports.resize(nbSM);
44 for(int i=0;i<nbSM;i++)
46 INTERP_KERNEL::AutoPtr<char> msn(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
47 INTERP_KERNEL::AutoPtr<char> description(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
49 int nAxis(MEDsupportMeshnAxis(fid,i+1));
50 INTERP_KERNEL::AutoPtr<char> axisName(new char[MED_SNAME_SIZE*nAxis+1]),axisUnit(new char[MED_SNAME_SIZE*nAxis+1]);
51 int spaceDim(0),meshDim(0);
52 MEDFILESAFECALLERRD0(MEDsupportMeshInfo,(fid,i+1,msn,&spaceDim,&meshDim,description,&axType,axisName,axisUnit));
53 std::string name(MEDLoaderBase::buildStringFromFortran(msn,MED_NAME_SIZE));
54 _supports[i]=MEDFileUMesh::New(fid,name);
58 MEDFileMeshSupports::MEDFileMeshSupports()
62 MEDFileMeshSupports::~MEDFileMeshSupports()
66 std::vector<const BigMemoryObject *> MEDFileMeshSupports::getDirectChildrenWithNull() const
68 std::size_t sz(_supports.size());
69 std::vector<const BigMemoryObject *> ret(sz);
70 for(std::size_t i=0;i<sz;i++)
75 std::size_t MEDFileMeshSupports::getHeapMemorySizeWithoutChildren() const
77 return _supports.capacity()*sizeof(MCAuto<MEDFileUMesh>);
80 void MEDFileMeshSupports::writeLL(med_idt fid) const
82 for(std::vector< MCAuto<MEDFileUMesh> >::const_iterator it=_supports.begin();it!=_supports.end();it++)
87 const MEDFileUMesh *MEDFileMeshSupports::getSupMeshWithName(const std::string& name) const
89 std::vector<std::string> mns;
90 for(std::vector< MCAuto<MEDFileUMesh> >::const_iterator it=_supports.begin();it!=_supports.end();it++)
94 std::string na((*it)->getName());
101 std::ostringstream oss;
102 oss << "MEDFileMeshSupports::getSupMeshWithName : no such name \"" << name << "\". Possibilitities are :";
103 std::copy(mns.begin(),mns.end(),std::ostream_iterator<std::string>(oss,","));
105 throw INTERP_KERNEL::Exception(oss.str());
108 int MEDFileMeshSupports::getNumberOfNodesPerCellOf(const std::string& name) const
110 const MEDFileUMesh *sup(getSupMeshWithName(name));
111 return sup->getNumberOfNodes();