Salome HOME
Stucture element have been read
[tools/medcoupling.git] / src / MEDLoader / MEDFileStructureElement.hxx
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 #ifndef __MEDFILESTRUCTUREELEMENT_HXX__
22 #define __MEDFILESTRUCTUREELEMENT_HXX__
23
24 #include "MEDLoaderDefines.hxx"
25 #include "MEDFileUtilities.txx"
26 #include "MEDFileMesh.hxx"
27
28 #include "MEDCouplingRefCountObject.hxx"
29
30 namespace MEDCoupling
31 {
32   class MEDFileStructureElement;
33   
34   class MEDFileSEHolder
35   {
36   protected:
37     MEDFileSEHolder(MEDFileStructureElement *father):_father(father) { }
38     std::string getModelName() const;
39     void setName(const std::string& name);
40     std::size_t getHeapMemorySizeLoc() const;
41   private:
42     MEDFileStructureElement *_father;
43     std::string _name;
44   };
45   
46 class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileSEHolder
47   {
48   public:
49     static MEDFileSEConstAtt *New(med_idt fid, MEDFileStructureElement *father, int idCstAtt);
50   public:
51     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
52     std::size_t getHeapMemorySizeWithoutChildren() const;
53     void writeLL(med_idt fid) const;
54     void setProfile(const std::string& name);
55     std::string getProfile() const;
56   private:
57     MEDFileSEConstAtt(med_idt fid, MEDFileStructureElement *father, int idCstAtt);
58   private:
59     std::string _pfl;
60     TypeOfField _tof;
61     MCAuto<DataArray> _val;
62   };
63   
64   class MEDFileSEVarAtt : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileSEHolder
65   {
66   public:
67     static MEDFileSEVarAtt *New(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
68   public:
69     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
70     std::size_t getHeapMemorySizeWithoutChildren() const;
71     void writeLL(med_idt fid) const;
72   private:
73     MEDFileSEVarAtt(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
74   private:
75     int _nb_compo;
76     MCAuto<DataArray> _gen;
77   };
78   
79   class MEDFileStructureElement : public RefCountObject, public MEDFileWritableStandAlone
80   {
81   public:
82     MEDLOADER_EXPORT static MEDFileStructureElement *New(med_idt fid, int idSE);
83     MEDLOADER_EXPORT std::string getName() const;
84   public:
85     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
86     std::size_t getHeapMemorySizeWithoutChildren() const;
87     void writeLL(med_idt fid) const;
88   public:
89     static MCAuto<DataArray> BuildFrom(med_attribute_type mat);
90     static int EffectiveNbCompo(med_attribute_type mat, int nbCompo);
91   private:
92     MEDFileStructureElement(med_idt fid, int idSE);
93   private:
94     int _id_type;
95     std::string _name;
96     INTERP_KERNEL::NormalizedCellType _geo_type;
97     int _dim;
98     std::vector< MCAuto<MEDFileSEConstAtt> > _cst_att;
99     std::vector< MCAuto<MEDFileSEVarAtt> > _var_att;
100   };
101   
102   class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone
103   {
104   public:
105     MEDLOADER_EXPORT static MEDFileStructureElements *New(med_idt fid);
106     MEDLOADER_EXPORT static MEDFileStructureElements *New();
107   public:
108     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
109     std::size_t getHeapMemorySizeWithoutChildren() const;
110     void writeLL(med_idt fid) const;
111   private:
112     MEDFileStructureElements(med_idt fid);
113     MEDFileStructureElements();
114     ~MEDFileStructureElements();
115   private:
116     std::vector< MCAuto<MEDFileStructureElement> > _elems;
117   };
118 }
119
120 #endif