Salome HOME
c0d88a2af6caa4716471b45d4b0a1628efa75e26
[tools/medcoupling.git] / src / MEDLoader / MEDFileStructureElement.hxx
1 // Copyright (C) 2007-2020  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   public:
39     std::string getModelName() const;
40     std::string getName() const;
41   protected:
42     MEDFileSEHolder(MEDFileStructureElement *father):_father(father) { }
43     void setName(const std::string& name);
44     std::size_t getHeapMemorySizeLoc() const;
45   private:
46     MEDFileStructureElement *_father;
47     std::string _name;
48   };
49   
50 class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileSEHolder
51   {
52   public:
53     static MEDFileSEConstAtt *New(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh);
54   public:
55     std::string getClassName() const override { return std::string("MEDFileSEConstAtt"); }
56     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
57     std::size_t getHeapMemorySizeWithoutChildren() const;
58     void writeLL(med_idt fid) const;
59     void setProfile(const std::string& name);
60     std::string getProfile() const;
61   private:
62     MEDFileSEConstAtt(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh);
63   private:
64     std::string _pfl;
65     TypeOfField _tof;
66     MCAuto<DataArray> _val;
67   };
68   
69   class MEDFileSEVarAtt : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileSEHolder
70   {
71   public:
72     static MEDFileSEVarAtt *New(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
73   public:
74     std::string getClassName() const override { return std::string("MEDFileSEVarAtt"); }
75     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
76     std::size_t getHeapMemorySizeWithoutChildren() const;
77     void writeLL(med_idt fid) const;
78     int getNbOfComponents() const { return _nb_compo; }
79     MCAuto<DataArray> getGenerator() const { return _gen; }
80   private:
81     MEDFileSEVarAtt(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
82   private:
83     int _nb_compo;
84     MCAuto<DataArray> _gen;
85   };
86   
87   class MEDFileStructureElement : public RefCountObject, public MEDFileWritableStandAlone
88   {
89   public:
90     MEDLOADER_EXPORT static MEDFileStructureElement *New(med_idt fid, int idSE, const MEDFileMeshSupports *ms);
91     MEDLOADER_EXPORT std::string getName() const;
92     MEDLOADER_EXPORT int getDynGT() const;
93     MEDLOADER_EXPORT TypeOfField getEntity() const;
94     MEDLOADER_EXPORT std::string getMeshName() const;
95     MEDLOADER_EXPORT std::vector<std::string> getVarAtts() const;
96     MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAtt(const std::string& varName) const;
97     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileStructureElement"); }
98   public:
99     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
100     std::size_t getHeapMemorySizeWithoutChildren() const;
101     void writeLL(med_idt fid) const;
102   public:
103     static MCAuto<DataArray> BuildFrom(med_attribute_type mat);
104     static int EffectiveNbCompo(med_attribute_type mat, int nbCompo);
105   private:
106     MEDFileStructureElement(med_idt fid, int idSE, const MEDFileMeshSupports *ms);
107   private:
108     int _id_type;
109     std::string _name;
110     std::string _sup_mesh_name;
111     INTERP_KERNEL::NormalizedCellType _geo_type;
112     TypeOfField _tof;
113     int _dim;
114     std::vector< MCAuto<MEDFileSEConstAtt> > _cst_att;
115     std::vector< MCAuto<MEDFileSEVarAtt> > _var_att;
116   };
117   
118   class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone
119   {
120   public:
121     MEDLOADER_EXPORT static MEDFileStructureElements *New(const std::string& fileName, const MEDFileMeshSupports *ms);
122     MEDLOADER_EXPORT static MEDFileStructureElements *New(med_idt fid, const MEDFileMeshSupports *ms);
123     MEDLOADER_EXPORT static MEDFileStructureElements *New();
124     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileStructureElements"); }
125     MEDLOADER_EXPORT int getNumberOf() const;
126     MEDLOADER_EXPORT std::vector<int> getDynGTAvail() const;
127     MEDLOADER_EXPORT const MEDFileStructureElement *getWithGT(int idGT) const;
128     MEDLOADER_EXPORT mcIdType getNumberOfNodesPerSE(const std::string& seName) const;
129     MEDLOADER_EXPORT const MEDFileStructureElement *getSEWithName(const std::string& seName) const;
130     MEDLOADER_EXPORT std::vector<std::string> getVarAttsOf(const std::string& seName) const;
131     MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAttOf(const std::string &seName, const std::string& varName) const;
132     MEDLOADER_EXPORT const MEDFileUMesh *getSupMeshWithName(const std::string& name) const;
133   public:
134     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
135     std::size_t getHeapMemorySizeWithoutChildren() const;
136     void writeLL(med_idt fid) const;
137   private:
138     MEDFileStructureElements(med_idt fid, const MEDFileMeshSupports *ms);
139     MEDFileStructureElements();
140     ~MEDFileStructureElements();
141   private:
142     std::vector< MCAuto<MEDFileStructureElement> > _elems;
143     MCConstAuto<MEDFileMeshSupports> _sup;
144   };
145 }
146
147 #endif