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