Salome HOME
support mesh are now read as classical meshes !
[tools/medcoupling.git] / src / MEDLoader / MEDFileMeshSupport.cxx
1 // Copyright (C) 2007-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 #include "MEDFileMeshSupport.hxx"
22 #include "MEDLoaderBase.hxx"
23 #include "MEDFileMeshLL.hxx"
24 #include "MEDFileSafeCaller.txx"
25
26 #include "InterpKernelAutoPtr.hxx"
27
28 using namespace MEDCoupling;
29
30 MEDFileMeshSupports *MEDFileMeshSupports::New(med_idt fid)
31 {
32   return new MEDFileMeshSupports(fid);
33 }
34
35 MEDFileMeshSupports *MEDFileMeshSupports::New()
36 {
37   return new MEDFileMeshSupports;
38 }
39
40 MEDFileMeshSupports::MEDFileMeshSupports(med_idt fid)
41 {
42   int nbSM(MEDnSupportMesh(fid));
43   _supports.resize(nbSM);
44   for(int i=0;i<nbSM;i++)
45     {
46       INTERP_KERNEL::AutoPtr<char> msn(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
47       INTERP_KERNEL::AutoPtr<char> description(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
48       med_axis_type axType;
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);
55     }
56 }
57
58 MEDFileMeshSupports::MEDFileMeshSupports()
59 {
60 }
61
62 MEDFileMeshSupports::~MEDFileMeshSupports()
63 {
64 }
65
66 std::vector<const BigMemoryObject *> MEDFileMeshSupports::getDirectChildrenWithNull() const
67 {
68   std::size_t sz(_supports.size());
69   std::vector<const BigMemoryObject *> ret(sz);
70   for(std::size_t i=0;i<sz;i++)
71     ret[i]=_supports[i];
72   return ret;
73 }
74
75 std::size_t MEDFileMeshSupports::getHeapMemorySizeWithoutChildren() const
76 {
77   return _supports.capacity()*sizeof(MCAuto<MEDFileUMesh>);
78 }
79
80 void MEDFileMeshSupports::writeLL(med_idt fid) const
81 {
82   for(std::vector< MCAuto<MEDFileUMesh> >::const_iterator it=_supports.begin();it!=_supports.end();it++)
83     if((*it).isNotNull())
84       (*it)->writeLL(fid);
85 }