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