Salome HOME
766c1129f8a3c22ac8fabd95095b43b372fe43a5
[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   class MEDFileMeshSupports;
34   class MEDFileUMesh;
35   
36   class MEDFileSEHolder
37   {
38   protected:
39     MEDFileSEHolder(MEDFileStructureElement *father):_father(father) { }
40     std::string getModelName() const;
41     void setName(const std::string& name);
42     std::size_t getHeapMemorySizeLoc() const;
43   private:
44     MEDFileStructureElement *_father;
45     std::string _name;
46   };
47   
48 class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileSEHolder
49   {
50   public:
51     static MEDFileSEConstAtt *New(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh);
52   public:
53     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
54     std::size_t getHeapMemorySizeWithoutChildren() const;
55     void writeLL(med_idt fid) const;
56     void setProfile(const std::string& name);
57     std::string getProfile() const;
58   private:
59     MEDFileSEConstAtt(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh);
60   private:
61     std::string _pfl;
62     TypeOfField _tof;
63     MCAuto<DataArray> _val;
64   };
65   
66   class MEDFileSEVarAtt : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileSEHolder
67   {
68   public:
69     static MEDFileSEVarAtt *New(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
70   public:
71     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
72     std::size_t getHeapMemorySizeWithoutChildren() const;
73     void writeLL(med_idt fid) const;
74   private:
75     MEDFileSEVarAtt(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
76   private:
77     int _nb_compo;
78     MCAuto<DataArray> _gen;
79   };
80   
81   class MEDFileStructureElement : public RefCountObject, public MEDFileWritableStandAlone
82   {
83   public:
84     MEDLOADER_EXPORT static MEDFileStructureElement *New(med_idt fid, int idSE, const MEDFileMeshSupports *ms);
85     MEDLOADER_EXPORT std::string getName() const;
86   public:
87     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
88     std::size_t getHeapMemorySizeWithoutChildren() const;
89     void writeLL(med_idt fid) const;
90   public:
91     static MCAuto<DataArray> BuildFrom(med_attribute_type mat);
92     static int EffectiveNbCompo(med_attribute_type mat, int nbCompo);
93   private:
94     MEDFileStructureElement(med_idt fid, int idSE, const MEDFileMeshSupports *ms);
95   private:
96     int _id_type;
97     std::string _name;
98     std::string _sup_mesh_name;
99     INTERP_KERNEL::NormalizedCellType _geo_type;
100     int _dim;
101     std::vector< MCAuto<MEDFileSEConstAtt> > _cst_att;
102     std::vector< MCAuto<MEDFileSEVarAtt> > _var_att;
103   };
104   
105   class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone
106   {
107   public:
108     MEDLOADER_EXPORT static MEDFileStructureElements *New(med_idt fid, const MEDFileMeshSupports *ms);
109     MEDLOADER_EXPORT static MEDFileStructureElements *New();
110   public:
111     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
112     std::size_t getHeapMemorySizeWithoutChildren() const;
113     void writeLL(med_idt fid) const;
114   private:
115     MEDFileStructureElements(med_idt fid, const MEDFileMeshSupports *ms);
116     MEDFileStructureElements();
117     ~MEDFileStructureElements();
118   private:
119     std::vector< MCAuto<MEDFileStructureElement> > _elems;
120   };
121 }
122
123 #endif