Salome HOME
Lease constraints on getHeapMem.
[tools/medcoupling.git] / src / MEDLoader / MEDFileMesh.hxx
1 // Copyright (C) 2007-2013  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.
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 (CEA/DEN)
20
21 #ifndef __MEDFILEMESH_HXX__
22 #define __MEDFILEMESH_HXX__
23
24 #include "MEDLoaderDefines.hxx"
25 #include "MEDFileMeshLL.hxx"
26 #include "MEDFileUtilities.hxx"
27
28 #include <map>
29 #include <list>
30
31 namespace ParaMEDMEM
32 {
33   class MEDLOADER_EXPORT MEDFileMesh : public RefCountObject, public MEDFileWritable
34   {
35   public:
36     static MEDFileMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
37     static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
38     std::size_t getHeapMemorySize() const;
39     virtual MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception) = 0;
40     virtual MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
41     virtual bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
42     virtual void clearNonDiscrAttributes() const;
43     void setName(const char *name) { _name=name; }
44     bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
45     const char *getName() const { return _name.c_str(); }
46     const char *getUnivName() const { return _univ_name.c_str(); }
47     bool getUnivNameWrStatus() const { return _univ_wr_status; }
48     void setUnivNameWrStatus(bool newStatus) { _univ_wr_status=newStatus; }
49     void setDescription(const char *name) { _desc_name=name; }
50     const char *getDescription() const { return _desc_name.c_str(); }
51     void setOrder(int order) { _order=order; }
52     int getOrder() const { return _order; }
53     void setIteration(int it) { _iteration=it; }
54     int getIteration() const { return _iteration; }
55     void setTimeValue(double time) { _time=time; }
56     void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; }
57     double getTime(int& dt, int& it) { dt=_iteration; it=_order; return _time; }
58     double getTimeValue() const { return _time; }
59     void setTimeUnit(const char *unit) { _dt_unit=unit; }
60     const char *getTimeUnit() const { return _dt_unit.c_str(); }
61     virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0;
62     virtual std::vector<int> getNonEmptyLevels() const = 0;
63     virtual std::vector<int> getNonEmptyLevelsExt() const = 0;
64     virtual void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
65     virtual void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
66     virtual int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
67     virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception) = 0;
68     //
69     bool areFamsEqual(const MEDFileMesh *other, std::string& what) const;
70     bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const;
71     bool existsGroup(const char *groupName) const;
72     bool existsFamily(int famId) const;
73     bool existsFamily(const char *familyName) const;
74     void setFamilyId(const char *familyName, int id);
75     void setFamilyIdUnique(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
76     virtual void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
77     virtual void createGroupOnAll(int meshDimRelToMaxExt, const char *groupName) throw(INTERP_KERNEL::Exception);
78     virtual bool keepFamIdsOnlyOnLevs(const std::vector<int>& famIds, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
79     void addFamilyOnGrp(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception);
80     std::string findOrCreateAndGiveFamilyWithId(int id, bool& created) throw(INTERP_KERNEL::Exception);
81     void setFamilyInfo(const std::map<std::string,int>& info);
82     void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
83     void copyFamGrpMapsFrom(const MEDFileMesh& other);
84     const std::map<std::string,int>& getFamilyInfo() const { return _families; }
85     const std::map<std::string, std::vector<std::string> >& getGroupInfo() const { return _groups; }
86     std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
87     std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
88     std::vector<int> getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
89     void setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
90     void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
91     std::vector<std::string> getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception);
92     void setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
93     std::vector<std::string> getGroupsNames() const;
94     std::vector<std::string> getFamiliesNames() const;
95     void assignFamilyNameWithGroupName() throw(INTERP_KERNEL::Exception);
96     void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
97     void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
98     void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
99     void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
100     void changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception);
101     void changeAllGroupsContainingFamily(const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames) throw(INTERP_KERNEL::Exception);
102     int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
103     int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
104     int getMinFamilyId() const throw(INTERP_KERNEL::Exception);
105     int getTheMaxFamilyId() const throw(INTERP_KERNEL::Exception);
106     int getTheMinFamilyId() const throw(INTERP_KERNEL::Exception);
107     virtual int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception) = 0;
108     virtual int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception) = 0;
109     DataArrayInt *getAllFamiliesIdsReferenced() const throw(INTERP_KERNEL::Exception);
110     std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
111     std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
112     bool ensureDifferentFamIdsPerLevel() throw(INTERP_KERNEL::Exception);
113     void normalizeFamIdsTrio() throw(INTERP_KERNEL::Exception);
114     void normalizeFamIdsMEDFile() throw(INTERP_KERNEL::Exception);
115     virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0;
116     virtual std::string simpleRepr() const;
117     virtual std::string advancedRepr() const = 0;
118     //
119     virtual void setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayInt *>& grps, bool renum=false) throw(INTERP_KERNEL::Exception);
120     virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception) = 0;
121     virtual void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception) = 0;
122     virtual void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) throw(INTERP_KERNEL::Exception) = 0;
123     virtual const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
124     virtual const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
125     virtual const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
126     virtual const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
127     virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception) = 0;
128     virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
129     virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
130     virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
131     virtual DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
132     virtual DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
133     virtual DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
134     virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
135     // tools
136     virtual bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell) throw(INTERP_KERNEL::Exception) = 0;
137   protected:
138     MEDFileMesh();
139     //! protected because no way in MED file API to specify this name
140     void setUnivName(const char *name) { _univ_name=name; }
141     void addFamilyOnAllGroupsHaving(const char *famName, const char *otherFamName) throw(INTERP_KERNEL::Exception);
142     virtual void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception) = 0;
143     void dealWithTinyInfo(const MEDCouplingMesh *m) throw(INTERP_KERNEL::Exception);
144     virtual void synchronizeTinyInfoOnLeaves() const = 0;
145     void getFamilyRepr(std::ostream& oss) const;
146     virtual void appendFamilyEntries(const DataArrayInt *famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
147     virtual void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception) = 0;
148     static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
149     static void ChangeAllGroupsContainingFamily(std::map<std::string, std::vector<std::string> >& groups, const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames) throw(INTERP_KERNEL::Exception);
150     static std::string FindOrCreateAndGiveFamilyWithId(std::map<std::string,int>& families, int id, bool& created) throw(INTERP_KERNEL::Exception);
151     static std::string CreateNameNotIn(const std::string& nameTry, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception);
152     static int PutInThirdComponentOfCodeOffset(std::vector<int>& code, int strt) throw(INTERP_KERNEL::Exception);
153   protected:
154     int _order;
155     int _iteration;
156     double _time;
157     std::string _dt_unit;
158     std::string _name;
159     //! this attribute do not impact the state of instance -> mutable
160     mutable std::string _univ_name;
161     bool _univ_wr_status;
162     std::string _desc_name;
163   protected:
164     std::map<std::string, std::vector<std::string> > _groups;
165     std::map<std::string,int> _families;
166   public:
167     static const char DFT_FAM_NAME[];
168   };
169
170   class MEDLOADER_EXPORT MEDFileUMesh : public MEDFileMesh
171   {
172     friend class MEDFileMesh;
173   public:
174     static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
175     static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
176     static MEDFileUMesh *New();
177     std::size_t getHeapMemorySize() const;
178     MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
179     MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
180     bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
181     void clearNonDiscrAttributes() const;
182     ~MEDFileUMesh();
183     //
184     int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
185     int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
186     int getMeshDimension() const throw(INTERP_KERNEL::Exception);
187     int getSpaceDimension() const throw(INTERP_KERNEL::Exception);
188     std::string simpleRepr() const;
189     std::string advancedRepr() const;
190     int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
191     const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
192     const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
193     const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
194     const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
195     int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
196     std::vector<int> getNonEmptyLevels() const;
197     std::vector<int> getNonEmptyLevelsExt() const;
198     std::vector<int> getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception);
199     std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception);
200     std::vector<int> getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception);
201     std::vector<int> getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception);
202     std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
203     std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
204     std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
205     std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
206     std::vector<std::string> getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
207     DataArrayDouble *getCoords() const;
208     MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
209     MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
210     MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
211     MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
212     DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
213     MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const throw(INTERP_KERNEL::Exception);
214     MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
215     MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
216     MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
217     MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
218     MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
219     //
220     void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception);
221     void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
222     void eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
223     void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
224     void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception);
225     void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) throw(INTERP_KERNEL::Exception);
226     void addNodeGroup(const DataArrayInt *ids) throw(INTERP_KERNEL::Exception);
227     void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids) throw(INTERP_KERNEL::Exception);
228     void removeMeshAtLevel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
229     void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false) throw(INTERP_KERNEL::Exception);
230     void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception);
231     void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception);
232     void optimizeFamilies() throw(INTERP_KERNEL::Exception);
233     // tools
234     void duplicateNodesOnM1Group(const char *grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified, DataArrayInt *&cellsNotModified) throw(INTERP_KERNEL::Exception);
235     bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell) throw(INTERP_KERNEL::Exception);
236     DataArrayInt *zipCoords() throw(INTERP_KERNEL::Exception);
237   private:
238     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
239     MEDFileUMesh();
240     MEDFileUMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
241     void loadUMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
242     const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
243     MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
244     void checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const throw(INTERP_KERNEL::Exception);
245     DataArrayDouble *checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception);
246     void computeRevNum() const;
247     void synchronizeTinyInfoOnLeaves() const;
248     void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception);
249     std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const;
250     void addGroupUnderground(const DataArrayInt *ids, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
251   private:
252     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
253     MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
254     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
255     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
256     MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _name_coords;
257     mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_coords;
258   };
259
260   class MEDLOADER_EXPORT MEDFileStructuredMesh : public MEDFileMesh
261   {
262     friend class MEDFileMesh;
263   public:
264     std::size_t getHeapMemorySize() const;
265     int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
266     int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
267     bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
268     void clearNonDiscrAttributes() const;
269     DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
270     const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
271     void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
272     void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception);
273     void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) throw(INTERP_KERNEL::Exception);
274     const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
275     const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
276     const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
277     std::vector<int> getNonEmptyLevels() const;
278     std::vector<int> getNonEmptyLevelsExt() const;
279     MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
280     int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
281     int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
282     // tools
283     bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell) throw(INTERP_KERNEL::Exception);
284   protected:
285     void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception);
286     void deepCpyAttributes() throw(INTERP_KERNEL::Exception);
287     void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
288     void writeStructuredLL(med_idt fid, const char *maa) const throw(INTERP_KERNEL::Exception);
289     virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0;
290     static med_geometry_type GetGeoTypeFromMeshDim(int meshDim) throw(INTERP_KERNEL::Exception);
291   private:
292     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_nodes;
293     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_nodes;
294     MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names_nodes;
295     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_cells;
296     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_cells;
297     MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names_cells;
298     mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_nodes;
299     mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_cells;
300   };
301
302   class MEDLOADER_EXPORT MEDFileCMesh : public MEDFileStructuredMesh
303   {
304     friend class MEDFileMesh;
305   public:
306     static MEDFileCMesh *New();
307     static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
308     static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
309     std::size_t getHeapMemorySize() const;
310     MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
311     MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
312     bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
313     int getMeshDimension() const throw(INTERP_KERNEL::Exception);
314     std::string simpleRepr() const;
315     std::string advancedRepr() const;
316     void clearNonDiscrAttributes() const;
317     const MEDCouplingCMesh *getMesh() const;
318     void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception);
319   private:
320     const MEDCouplingStructuredMesh *getStructuredMesh() const;
321     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
322     MEDFileCMesh();
323     void synchronizeTinyInfoOnLeaves() const;
324     MEDFileCMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
325     void loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
326   private:
327     MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
328   };
329
330   class MEDLOADER_EXPORT MEDFileCurveLinearMesh : public MEDFileStructuredMesh
331   {
332     friend class MEDFileMesh;
333   public:
334     static MEDFileCurveLinearMesh *New();
335     static MEDFileCurveLinearMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
336     static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
337     std::size_t getHeapMemorySize() const;
338     MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
339     MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
340     bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
341     int getMeshDimension() const throw(INTERP_KERNEL::Exception);
342     std::string simpleRepr() const;
343     std::string advancedRepr() const;
344     void clearNonDiscrAttributes() const;
345     const MEDCouplingCurveLinearMesh *getMesh() const;
346     void setMesh(MEDCouplingCurveLinearMesh *m) throw(INTERP_KERNEL::Exception);
347   private:
348     MEDFileCurveLinearMesh();
349     MEDFileCurveLinearMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
350     const MEDCouplingStructuredMesh *getStructuredMesh() const;
351     void synchronizeTinyInfoOnLeaves() const;
352     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
353     void loadCLMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);//to imp
354   private:
355     MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> _clmesh;
356   };
357
358   class MEDLOADER_EXPORT MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable
359   {
360   public:
361     static MEDFileMeshMultiTS *New();
362     static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
363     static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
364     MEDFileMeshMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
365     std::size_t getHeapMemorySize() const;
366     const char *getName() const throw(INTERP_KERNEL::Exception);
367     void setName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
368     bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
369     MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception);
370     void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
371     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
372     void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
373   private:
374     void loadFromFile(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
375     MEDFileMeshMultiTS();
376     MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
377     MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
378   private:
379     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> > _mesh_one_ts;
380   };
381
382   class MEDFileMeshesIterator;
383
384   class MEDLOADER_EXPORT MEDFileMeshes : public RefCountObject, public MEDFileWritable
385   {
386   public:
387     static MEDFileMeshes *New();
388     static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception);
389     MEDFileMeshes *deepCpy() const throw(INTERP_KERNEL::Exception);
390     std::size_t getHeapMemorySize() const;
391     std::string simpleRepr() const;
392     void simpleReprWithoutHeader(std::ostream& oss) const;
393     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
394     void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
395     int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
396     MEDFileMeshesIterator *iterator() throw(INTERP_KERNEL::Exception);
397     MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception);
398     MEDFileMesh *getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception);
399     std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
400     bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
401     //
402     void resize(int newSize) throw(INTERP_KERNEL::Exception);
403     void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
404     void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
405     void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
406   private:
407     void checkCoherency() const throw(INTERP_KERNEL::Exception);
408     void loadFromFile(const char *fileName) throw(INTERP_KERNEL::Exception);
409     MEDFileMeshes();
410     MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception);
411   private:
412     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> > _meshes;
413   };
414
415   class MEDCOUPLING_EXPORT MEDFileMeshesIterator
416   {
417   public:
418     MEDFileMeshesIterator(MEDFileMeshes *ms);
419     ~MEDFileMeshesIterator();
420     MEDFileMesh *nextt();
421   private:
422     MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> _ms;
423      int _iter_id;
424      int _nb_iter;
425   };
426 }
427
428 #endif