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