Salome HOME
Copyright update 2021
[tools/medcoupling.git] / src / MEDLoader / MEDFileMesh.hxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __MEDFILEMESH_HXX__
22 #define __MEDFILEMESH_HXX__
23
24 #include "MEDLoaderDefines.hxx"
25 #include "MEDFileMeshLL.hxx"
26 #include "MEDFileUtilities.txx"
27 #include "MEDCouplingPartDefinition.hxx"
28 #include "MEDFileMeshReadSelector.hxx"
29 #include "MEDFileJoint.hxx"
30 #include "MEDFileEquivalence.hxx"
31
32 #include <map>
33 #include <list>
34
35 namespace MEDCoupling
36 {
37   class MEDFileFieldGlobsReal;
38   class MEDFileField1TSStructItem;
39
40   class MEDFileMesh : public RefCountObject, public MEDFileWritableStandAlone
41   {
42   public:
43     MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
44     MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0);
45     MEDLOADER_EXPORT static MEDFileMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileMesh>(db); }
46     MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0, MEDFileJoints* joints=0);
47     MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0, MEDFileJoints* joints=0);
48     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
49     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
50     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
51     MEDLOADER_EXPORT virtual MEDFileMesh *createNewEmpty() const = 0;
52     MEDLOADER_EXPORT virtual MEDFileMesh *deepCopy() const = 0;
53     MEDLOADER_EXPORT virtual MEDFileMesh *shallowCpy() const = 0;
54     MEDLOADER_EXPORT virtual bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
55     MEDLOADER_EXPORT virtual void clearNonDiscrAttributes() const;
56     MEDLOADER_EXPORT virtual void setName(const std::string& name);
57     MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
58     MEDLOADER_EXPORT std::string getName() const { return _name; }
59     MEDLOADER_EXPORT std::string getUnivName() const { return _univ_name; }
60     MEDLOADER_EXPORT bool getUnivNameWrStatus() const { return _univ_wr_status; }
61     MEDLOADER_EXPORT void setUnivNameWrStatus(bool newStatus) { _univ_wr_status=newStatus; }
62     MEDLOADER_EXPORT void setDescription(const std::string& name) { _desc_name=name; }
63     MEDLOADER_EXPORT std::string getDescription() const { return _desc_name; }
64     MEDLOADER_EXPORT void setOrder(int order) { _order=order; }
65     MEDLOADER_EXPORT int getOrder() const { return _order; }
66     MEDLOADER_EXPORT void setIteration(int it) { _iteration=it; }
67     MEDLOADER_EXPORT int getIteration() const { return _iteration; }
68     MEDLOADER_EXPORT void setTimeValue(double time) { _time=time; }
69     MEDLOADER_EXPORT void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; }
70     MEDLOADER_EXPORT double getTime(int& dt, int& it) const { dt=_iteration; it=_order; return _time; }
71     MEDLOADER_EXPORT double getTimeValue() const { return _time; }
72     MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
73     MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
74     MEDLOADER_EXPORT void setAxisType(MEDCouplingAxisType at) { _axis_type=at; }
75     MEDLOADER_EXPORT MEDCouplingAxisType getAxisType() const { return _axis_type; }
76     MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
77     MEDLOADER_EXPORT virtual mcIdType getNumberOfNodes() const = 0;
78     MEDLOADER_EXPORT virtual mcIdType getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const = 0;
79     MEDLOADER_EXPORT virtual bool hasImplicitPart() const = 0;
80     MEDLOADER_EXPORT virtual mcIdType buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const = 0;
81     MEDLOADER_EXPORT virtual void releaseImplicitPartIfAny() const = 0;
82     MEDLOADER_EXPORT virtual std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const = 0;
83     MEDLOADER_EXPORT virtual mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const = 0;
84     MEDLOADER_EXPORT virtual std::vector<int> getNonEmptyLevels() const = 0;
85     MEDLOADER_EXPORT virtual std::vector<int> getNonEmptyLevelsExt() const = 0;
86     MEDLOADER_EXPORT virtual std::vector<int> getFamArrNonEmptyLevelsExt() const = 0;
87     MEDLOADER_EXPORT virtual std::vector<int> getNumArrNonEmptyLevelsExt() const = 0;
88     MEDLOADER_EXPORT virtual std::vector<int> getNameArrNonEmptyLevelsExt() const = 0;
89     MEDLOADER_EXPORT virtual mcIdType getSizeAtLevel(int meshDimRelToMaxExt) const = 0;
90     MEDLOADER_EXPORT virtual MEDCouplingMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const = 0;
91     MEDLOADER_EXPORT virtual std::vector<mcIdType> getDistributionOfTypes(int meshDimRelToMax) const;
92     MEDLOADER_EXPORT virtual void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const = 0;
93     MEDLOADER_EXPORT virtual MEDFileMesh *cartesianize() const = 0;
94     MEDLOADER_EXPORT virtual bool presenceOfStructureElements() const = 0;
95     MEDLOADER_EXPORT virtual void killStructureElements() { }
96     //
97     MEDLOADER_EXPORT bool areFamsEqual(const MEDFileMesh *other, std::string& what) const;
98     MEDLOADER_EXPORT bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const;
99     MEDLOADER_EXPORT bool existsGroup(const std::string& groupName) const;
100     MEDLOADER_EXPORT bool existsFamily(mcIdType famId) const;
101     MEDLOADER_EXPORT bool existsFamily(const std::string& familyName) const;
102     MEDLOADER_EXPORT void setFamilyId(const std::string& familyName, mcIdType id);
103     MEDLOADER_EXPORT void setFamilyIdUnique(const std::string& familyName, mcIdType id);
104     MEDLOADER_EXPORT virtual void addFamily(const std::string& familyName, mcIdType id);
105     MEDLOADER_EXPORT virtual void createGroupOnAll(int meshDimRelToMaxExt, const std::string& groupName);
106     MEDLOADER_EXPORT virtual bool keepFamIdsOnlyOnLevs(const std::vector<mcIdType>& famIds, const std::vector<int>& levs);
107     MEDLOADER_EXPORT void addFamilyOnGrp(const std::string& grpName, const std::string& famName);
108     MEDLOADER_EXPORT std::string findOrCreateAndGiveFamilyWithId(mcIdType id, bool& created);
109     MEDLOADER_EXPORT void setFamilyInfo(const std::map<std::string,mcIdType>& info);
110     MEDLOADER_EXPORT void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
111     MEDLOADER_EXPORT void copyFamGrpMapsFrom(const MEDFileMesh& other);
112     MEDLOADER_EXPORT void clearGrpMap();
113     MEDLOADER_EXPORT void clearFamMap();
114     MEDLOADER_EXPORT void clearFamGrpMaps();
115     MEDLOADER_EXPORT const std::map<std::string,mcIdType>& getFamilyInfo() const { return _families; }
116     MEDLOADER_EXPORT const std::map<std::string, std::vector<std::string> >& getGroupInfo() const { return _groups; }
117     MEDLOADER_EXPORT std::vector<std::string> getFamiliesOnGroup(const std::string& name) const;
118     MEDLOADER_EXPORT std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const;
119     MEDLOADER_EXPORT std::vector<mcIdType> getFamiliesIdsOnGroup(const std::string& name) const;
120     MEDLOADER_EXPORT void setFamiliesOnGroup(const std::string& name, const std::vector<std::string>& fams);
121     MEDLOADER_EXPORT void setFamiliesIdsOnGroup(const std::string& name, const std::vector<mcIdType>& famIds);
122     MEDLOADER_EXPORT std::vector<std::string> getGroupsOnFamily(const std::string& name) const;
123     MEDLOADER_EXPORT void setGroupsOnFamily(const std::string& famName, const std::vector<std::string>& grps);
124     MEDLOADER_EXPORT std::vector<std::string> getGroupsNames() const;
125     MEDLOADER_EXPORT std::vector<std::string> getFamiliesNames() const;
126     MEDLOADER_EXPORT std::vector<std::string> getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const;
127     MEDLOADER_EXPORT std::vector<mcIdType> getGrpNonEmptyLevelsExt(const std::string& grp) const;
128     MEDLOADER_EXPORT std::vector<mcIdType> getGrpNonEmptyLevels(const std::string& grp) const;
129     MEDLOADER_EXPORT std::vector<mcIdType> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const;
130     MEDLOADER_EXPORT std::vector<mcIdType> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const;
131     MEDLOADER_EXPORT virtual std::vector<mcIdType> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const = 0;
132     MEDLOADER_EXPORT virtual std::vector<mcIdType> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const = 0;
133     MEDLOADER_EXPORT std::vector<mcIdType> getFamNonEmptyLevels(const std::string& fam) const;
134     MEDLOADER_EXPORT std::vector<mcIdType> getFamNonEmptyLevelsExt(const std::string& fam) const;
135     MEDLOADER_EXPORT std::vector<std::string> getFamiliesNamesWithFilePointOfView() const;
136     MEDLOADER_EXPORT static std::string GetMagicFamilyStr();
137     MEDLOADER_EXPORT void assignFamilyNameWithGroupName();
138     MEDLOADER_EXPORT std::vector<std::string> removeEmptyGroups();
139     MEDLOADER_EXPORT void removeGroupAtLevel(int meshDimRelToMaxExt, const std::string& name);
140     MEDLOADER_EXPORT void removeGroup(const std::string& name);
141     MEDLOADER_EXPORT void removeFamily(const std::string& name);
142     MEDLOADER_EXPORT std::vector<std::string> removeOrphanGroups();
143     MEDLOADER_EXPORT std::vector<std::string> removeOrphanFamilies();
144     MEDLOADER_EXPORT void removeFamiliesReferedByNoGroups();
145     MEDLOADER_EXPORT void rearrangeFamilies();
146     MEDLOADER_EXPORT void zipFamilies();
147     MEDLOADER_EXPORT void checkOrphanFamilyZero() const;
148     MEDLOADER_EXPORT void changeGroupName(const std::string& oldName, const std::string& newName);
149     MEDLOADER_EXPORT void changeFamilyName(const std::string& oldName, const std::string& newName);
150     MEDLOADER_EXPORT void changeFamilyId(mcIdType oldId, mcIdType newId);
151     MEDLOADER_EXPORT void changeAllGroupsContainingFamily(const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames);
152     MEDLOADER_EXPORT mcIdType getFamilyId(const std::string& name) const;
153     MEDLOADER_EXPORT mcIdType getMaxAbsFamilyId() const;
154     MEDLOADER_EXPORT mcIdType getMaxFamilyId() const;
155     MEDLOADER_EXPORT mcIdType getMinFamilyId() const;
156     MEDLOADER_EXPORT mcIdType getTheMaxAbsFamilyId() const;
157     MEDLOADER_EXPORT mcIdType getTheMaxFamilyId() const;
158     MEDLOADER_EXPORT mcIdType getTheMinFamilyId() const;
159     MEDLOADER_EXPORT virtual mcIdType getMaxAbsFamilyIdInArrays() const = 0;
160     MEDLOADER_EXPORT virtual mcIdType getMaxFamilyIdInArrays() const = 0;
161     MEDLOADER_EXPORT virtual mcIdType getMinFamilyIdInArrays() const = 0;
162     MEDLOADER_EXPORT DataArrayIdType *getAllFamiliesIdsReferenced() const;
163     MEDLOADER_EXPORT DataArrayIdType *computeAllFamilyIdsInUse() const;
164     MEDLOADER_EXPORT std::vector<mcIdType> getFamiliesIds(const std::vector<std::string>& famNames) const;
165     MEDLOADER_EXPORT std::string getFamilyNameGivenId(mcIdType id) const;
166     MEDLOADER_EXPORT bool ensureDifferentFamIdsPerLevel();
167     MEDLOADER_EXPORT void normalizeFamIdsTrio();
168     MEDLOADER_EXPORT void normalizeFamIdsMEDFile();
169     MEDLOADER_EXPORT virtual int getMeshDimension() const = 0;
170     MEDLOADER_EXPORT virtual int getSpaceDimension() const = 0;
171     MEDLOADER_EXPORT virtual std::string simpleRepr() const;
172     MEDLOADER_EXPORT virtual std::string advancedRepr() const = 0;
173     //
174     MEDLOADER_EXPORT virtual void setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayIdType *>& grps, bool renum=false);
175     MEDLOADER_EXPORT virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayIdType *famArr) = 0;
176     MEDLOADER_EXPORT virtual void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayIdType *renumArr) = 0;
177     MEDLOADER_EXPORT virtual void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) = 0;
178     MEDLOADER_EXPORT virtual void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayIdType *globalNumArr) = 0;
179     MEDLOADER_EXPORT virtual void addNodeGroup(const DataArrayIdType *ids) = 0;
180     MEDLOADER_EXPORT virtual void addGroup(int meshDimRelToMaxExt, const DataArrayIdType *ids) = 0;
181     MEDLOADER_EXPORT virtual const DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const = 0;
182     MEDLOADER_EXPORT virtual DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) = 0;
183     MEDLOADER_EXPORT DataArrayIdType *getOrCreateAndGetFamilyFieldAtLevel(int meshDimRelToMaxExt);
184     MEDLOADER_EXPORT virtual const DataArrayIdType *getNumberFieldAtLevel(int meshDimRelToMaxExt) const = 0;
185     MEDLOADER_EXPORT virtual const DataArrayIdType *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const = 0;
186     MEDLOADER_EXPORT virtual const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const = 0;
187     MEDLOADER_EXPORT virtual MCAuto<DataArrayIdType> getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const = 0;
188     MEDLOADER_EXPORT virtual DataArrayIdType *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const = 0;
189     MEDLOADER_EXPORT virtual DataArrayIdType *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const;
190     MEDLOADER_EXPORT virtual DataArrayIdType *getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const;
191     MEDLOADER_EXPORT virtual DataArrayIdType *getFamilyArr(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const;
192     MEDLOADER_EXPORT virtual DataArrayIdType *getNodeGroupArr(const std::string& grp, bool renum=false) const;
193     MEDLOADER_EXPORT virtual DataArrayIdType *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const;
194     MEDLOADER_EXPORT virtual DataArrayIdType *getNodeFamilyArr(const std::string& fam, bool renum=false) const;
195     MEDLOADER_EXPORT virtual DataArrayIdType *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const;
196     // tools
197     MEDLOADER_EXPORT virtual bool unPolyze(std::vector<mcIdType>& oldCode, std::vector<mcIdType>& newCode, DataArrayIdType *& o2nRenumCell) = 0;
198     MEDLOADER_EXPORT int getNumberOfJoints() const;
199     MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
200     MEDLOADER_EXPORT void setJoints( MEDFileJoints* joints );
201     MEDFileEquivalences *getEquivalences() { return _equiv; }
202     const MEDFileEquivalences *getEquivalences() const { return _equiv; }
203     void killEquivalences() { _equiv=(MEDFileEquivalences *)0; }
204     void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); }
205     MEDLOADER_EXPORT static INTERP_KERNEL::NormalizedCellType ConvertFromMEDFileGeoType(med_geometry_type geoType);
206     static TypeOfField ConvertFromMEDFileEntity(med_entity_type etype);
207   protected:
208     MEDFileMesh();
209     //! protected because no way in MED file API to specify this name
210     void setUnivName(const std::string& name) { _univ_name=name; }
211     void addFamilyOnAllGroupsHaving(const std::string& famName, const std::string& otherFamName);
212     void dealWithTinyInfo(const MEDCouplingMesh *m);
213     virtual void synchronizeTinyInfoOnLeaves() const = 0;
214     void getFamilyRepr(std::ostream& oss) const;
215     virtual void appendFamilyEntries(const DataArrayIdType *famIds, const std::vector< std::vector<mcIdType> >& fidsOfGrps, const std::vector<std::string>& grpNames);
216     virtual void changeFamilyIdArr(mcIdType oldId, mcIdType newId) = 0;
217     virtual std::list< MCAuto<DataArrayIdType> > getAllNonNullFamilyIds() const = 0;
218     virtual void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) = 0;
219     void loadLLWithAdditionalItems(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
220     void addGroupUnderground(bool isNodeGroup, const DataArrayIdType *ids, DataArrayIdType *famArr);
221     static void TranslateFamilyIds(mcIdType offset, DataArrayIdType *famArr, std::vector< std::vector<mcIdType> >& famIdsPerGrp);
222     static void ChangeAllGroupsContainingFamily(std::map<std::string, std::vector<std::string> >& groups, const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames);
223     static std::string FindOrCreateAndGiveFamilyWithId(std::map<std::string,mcIdType>& families, mcIdType id, bool& created);
224     static std::string CreateNameNotIn(const std::string& nameTry, const std::vector<std::string>& namesToAvoid);
225     static mcIdType PutInThirdComponentOfCodeOffset(std::vector<mcIdType>& code, mcIdType strt);
226     void writeJoints(med_idt fid) const;
227     void loadJointsFromFile(med_idt fid, MEDFileJoints *toUseInstedOfReading=0);
228     void loadEquivalences(med_idt fid);
229     void deepCpyEquivalences(const MEDFileMesh& other);
230     bool areEquivalencesEqual(const MEDFileMesh *other, std::string& what) const;
231     void getEquivalencesRepr(std::ostream& oss) const;
232     void checkCartesian() const;
233     void checkNoGroupClash(const DataArrayIdType *famArr, const std::string& grpName) const;
234   private:
235     virtual void writeMeshLL(med_idt fid) const = 0;
236   protected:
237     int _order;
238     int _iteration;
239     double _time;
240     std::string _dt_unit;
241     std::string _name;
242     //! this attribute do not impact the state of instance -> mutable
243     mutable std::string _univ_name;
244     bool _univ_wr_status;
245     std::string _desc_name;
246     MEDCouplingAxisType _axis_type;
247     MCAuto<MEDFileJoints> _joints;
248     MCAuto<MEDFileEquivalences> _equiv;
249   protected:
250     std::map<std::string, std::vector<std::string> > _groups;
251     std::map<std::string,mcIdType> _families;
252   public:
253     MEDLOADER_EXPORT static const char DFT_FAM_NAME[];
254   };
255
256   class MEDCouplingMappedExtrudedMesh;
257   
258   class MEDFileUMesh : public MEDFileMesh
259   {
260     friend class MEDFileMesh;
261   public:
262     MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
263     MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
264     MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
265     MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0);
266     MEDLOADER_EXPORT static MEDFileUMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileUMesh>(db); }
267     MEDLOADER_EXPORT static MEDFileUMesh *New(const MEDCouplingMappedExtrudedMesh *mem);
268     MEDLOADER_EXPORT static MEDFileUMesh *New();
269     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileUMesh"); }
270     MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<mcIdType>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
271     MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(med_idt fid, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<mcIdType>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
272     MEDLOADER_EXPORT static void LoadPartCoords(const std::string& fileName, const std::string& mName, int dt, int it, const std::vector<std::string>& infosOnComp, mcIdType startNodeId, mcIdType stopNodeId,
273 MCAuto<DataArrayDouble>& coords, MCAuto<PartDefinition>& partCoords, MCAuto<DataArrayIdType>& famCoords, MCAuto<DataArrayIdType>& numCoords, MCAuto<DataArrayAsciiChar>& nameCoords);
274     MEDLOADER_EXPORT static const char *GetSpeStr4ExtMesh() { return SPE_FAM_STR_EXTRUDED_MESH; }
275     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
276     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
277     MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
278     MEDLOADER_EXPORT MEDFileUMesh *deepCopy() const;
279     MEDLOADER_EXPORT MEDFileUMesh *shallowCpy() const;
280     MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
281     MEDLOADER_EXPORT void checkConsistency() const;
282     MEDLOADER_EXPORT void checkSMESHConsistency() const;
283     MEDLOADER_EXPORT void clearNodeAndCellNumbers();
284     MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
285     MEDLOADER_EXPORT void setName(const std::string& name);
286     MEDLOADER_EXPORT const std::vector< MCAuto<MEDFileEltStruct4Mesh> >& getAccessOfUndergroundEltStrs() const { return _elt_str; }
287     //
288     MEDLOADER_EXPORT mcIdType getMaxAbsFamilyIdInArrays() const;
289     MEDLOADER_EXPORT mcIdType getMaxFamilyIdInArrays() const;
290     MEDLOADER_EXPORT mcIdType getMinFamilyIdInArrays() const;
291     MEDLOADER_EXPORT int getMeshDimension() const;
292     MEDLOADER_EXPORT int getSpaceDimension() const;
293     MEDLOADER_EXPORT std::string simpleRepr() const;
294     MEDLOADER_EXPORT std::string advancedRepr() const;
295     MEDLOADER_EXPORT mcIdType getSizeAtLevel(int meshDimRelToMaxExt) const;
296     MEDLOADER_EXPORT const DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const;
297     MEDLOADER_EXPORT DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt);
298     MEDLOADER_EXPORT const DataArrayIdType *getNumberFieldAtLevel(int meshDimRelToMaxExt) const;
299     MEDLOADER_EXPORT const DataArrayIdType *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const;
300     MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const;
301     MEDLOADER_EXPORT MCAuto<DataArrayIdType> getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const;
302     MEDLOADER_EXPORT const PartDefinition *getPartDefAtLevel(int meshDimRelToMaxExt, INTERP_KERNEL::NormalizedCellType gt=INTERP_KERNEL::NORM_ERROR) const;
303     MEDLOADER_EXPORT mcIdType getNumberOfNodes() const;
304     MEDLOADER_EXPORT mcIdType getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const;
305     MEDLOADER_EXPORT bool hasImplicitPart() const;
306     MEDLOADER_EXPORT mcIdType buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const;
307     MEDLOADER_EXPORT void releaseImplicitPartIfAny() const;
308     MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
309     MEDLOADER_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
310     MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
311     MEDLOADER_EXPORT MEDFileMesh *cartesianize() const;
312     MEDLOADER_EXPORT bool presenceOfStructureElements() const;
313     MEDLOADER_EXPORT void killStructureElements();
314     MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
315     MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
316     MEDLOADER_EXPORT std::vector<int> getFamArrNonEmptyLevelsExt() const;
317     MEDLOADER_EXPORT std::vector<int> getNumArrNonEmptyLevelsExt() const;
318     MEDLOADER_EXPORT std::vector<int> getNameArrNonEmptyLevelsExt() const;
319     MEDLOADER_EXPORT std::vector<mcIdType> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const;
320     MEDLOADER_EXPORT std::vector<mcIdType> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const;
321     MEDLOADER_EXPORT DataArrayDouble *getCoords() const;
322     MEDLOADER_EXPORT MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const;
323     MEDLOADER_EXPORT MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const;
324     MEDLOADER_EXPORT MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const;
325     MEDLOADER_EXPORT MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
326     MEDLOADER_EXPORT DataArrayIdType *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
327     MEDLOADER_EXPORT MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const;
328     MEDLOADER_EXPORT std::vector<mcIdType> getDistributionOfTypes(int meshDimRelToMax) const;
329     MEDLOADER_EXPORT std::vector< std::pair<int,mcIdType> > getAllDistributionOfTypes() const;
330     MEDLOADER_EXPORT MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const;
331     MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const;
332     MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const;
333     MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const;
334     MEDLOADER_EXPORT void forceComputationOfParts() const;
335     MEDLOADER_EXPORT void computeRevNum() const;
336     MEDLOADER_EXPORT std::vector<MEDCoupling1GTUMesh *> getDirectUndergroundSingleGeoTypeMeshes(int meshDimRelToMax) const;
337     MEDLOADER_EXPORT MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const;
338     MEDLOADER_EXPORT DataArrayIdType *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
339     MEDLOADER_EXPORT DataArrayIdType *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
340     MEDLOADER_EXPORT int getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
341     //
342     MEDLOADER_EXPORT void setFamilyNameAttachedOnId(mcIdType id, const std::string& newFamName);
343     MEDLOADER_EXPORT void setCoords(DataArrayDouble *coords);
344     MEDLOADER_EXPORT void setCoordsForced(DataArrayDouble *coords);
345     MEDLOADER_EXPORT void eraseGroupsAtLevel(int meshDimRelToMaxExt);
346     MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayIdType *famArr);
347     MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayIdType *renumArr);
348     MEDLOADER_EXPORT void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr);
349     MEDLOADER_EXPORT void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayIdType *globalNumArr);
350     MEDLOADER_EXPORT void addNodeGroup(const DataArrayIdType *ids);
351     MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayIdType *ids);
352     MEDLOADER_EXPORT void removeMeshAtLevel(int meshDimRelToMax);
353     MEDLOADER_EXPORT void setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m);
354     MEDLOADER_EXPORT void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false);
355     MEDLOADER_EXPORT void setMeshes(const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
356     MEDLOADER_EXPORT void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
357     MEDLOADER_EXPORT void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
358     MEDLOADER_EXPORT void optimizeFamilies();
359     // tools
360     MEDLOADER_EXPORT void buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, DataArrayIdType *&nodesDuplicated, DataArrayIdType *&cellsModified, DataArrayIdType *&cellsNotModified);
361     MEDLOADER_EXPORT bool unPolyze(std::vector<mcIdType>& oldCode, std::vector<mcIdType>& newCode, DataArrayIdType *& o2nRenumCell);
362     MEDLOADER_EXPORT DataArrayIdType *zipCoords();
363     MEDLOADER_EXPORT DataArrayIdType *computeFetchedNodeIds() const;
364     MEDLOADER_EXPORT DataArrayIdType *deduceNodeSubPartFromCellSubPart(const std::map<int, MCAuto<DataArrayIdType> >& extractDef) const;
365     MEDLOADER_EXPORT MEDFileUMesh *extractPart(const std::map<int, MCAuto<DataArrayIdType> >& extractDef) const;
366     MEDLOADER_EXPORT MEDFileUMesh *buildExtrudedMesh(const MEDCouplingUMesh *m1D, int policy) const;
367     MEDLOADER_EXPORT MEDFileUMesh *linearToQuadratic(int conversionType=0, double eps=1e-12) const;
368     MEDLOADER_EXPORT MEDFileUMesh *quadraticToLinear(double eps=1e-12) const;
369     MEDLOADER_EXPORT MCAuto<MEDFileUMesh> symmetry3DPlane(const double point[3], const double normalVector[3]) const;
370     MEDLOADER_EXPORT static MCAuto<MEDFileUMesh> Aggregate(const std::vector<const MEDFileUMesh *>& meshes);
371     MEDLOADER_EXPORT MEDCouplingMappedExtrudedMesh *convertToExtrudedMesh() const;
372     // serialization
373     MEDLOADER_EXPORT void serialize(std::vector<double>& tinyDouble, std::vector<mcIdType>& tinyInt, std::vector<std::string>& tinyStr,
374                                     std::vector< MCAuto<DataArrayIdType> >& bigArraysI, MCAuto<DataArrayDouble>& bigArrayD);
375     MEDLOADER_EXPORT void unserialize(std::vector<double>& tinyDouble, std::vector<mcIdType>& tinyInt, std::vector<std::string>& tinyStr,
376                                       std::vector< MCAuto<DataArrayIdType> >& bigArraysI, MCAuto<DataArrayDouble>& bigArrayD);
377   private:
378     MEDLOADER_EXPORT ~MEDFileUMesh();
379     void writeMeshLL(med_idt fid) const;
380     MEDFileUMesh();
381     MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
382     void loadPartUMeshFromFile(med_idt fid, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<mcIdType>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
383     void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
384     void dispatchLoadedPart(med_idt fid, const MEDFileUMeshL2& loaderl2, const std::string& mName, MEDFileMeshReadSelector *mrs);
385     const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) const;
386     MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt);
387     void checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const;
388     DataArrayDouble *checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const;
389     void synchronizeTinyInfoOnLeaves() const;
390     void changeFamilyIdArr(mcIdType oldId, mcIdType newId);
391     std::list< MCAuto<DataArrayIdType> > getAllNonNullFamilyIds() const;
392     MCAuto<MEDFileUMeshSplitL1>& checkAndGiveEntryInSplitL1(int meshDimRelToMax, MEDCouplingPointSet *m);
393   private:
394     static const char SPE_FAM_STR_EXTRUDED_MESH[];
395   private:
396     std::vector< MCAuto<MEDFileUMeshSplitL1> > _ms;   ///< The array of single-dimension constituting meshes, stored in decreasing order (dimRelativeToMax=0,-1,-2, ...)
397     MCAuto<DataArrayDouble> _coords;
398     MCAuto<DataArrayIdType> _fam_coords;              ///< Node family indices
399     MCAuto<DataArrayIdType> _num_coords;
400     MCAuto<DataArrayIdType> _global_num_coords;
401     MCAuto<DataArrayAsciiChar> _name_coords;
402     mutable MCAuto<DataArrayIdType> _rev_num_coords;
403     MCAuto<PartDefinition> _part_coords;
404     std::vector< MCAuto<MEDFileEltStruct4Mesh> > _elt_str;
405   };
406
407   class MEDFileStructuredMesh : public MEDFileMesh
408   {
409     friend class MEDFileMesh;
410   public:
411     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
412     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
413     MEDLOADER_EXPORT mcIdType getMaxAbsFamilyIdInArrays() const;
414     MEDLOADER_EXPORT mcIdType getMaxFamilyIdInArrays() const;
415     MEDLOADER_EXPORT mcIdType getMinFamilyIdInArrays() const;
416     MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
417     MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
418     MEDLOADER_EXPORT DataArrayIdType *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
419     MEDLOADER_EXPORT const DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const;
420     MEDLOADER_EXPORT DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt);
421     MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayIdType *famArr);
422     MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayIdType *renumArr);
423     MEDLOADER_EXPORT void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr);
424     MEDLOADER_EXPORT void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayIdType *globalNumArr);
425     MEDLOADER_EXPORT void addNodeGroup(const DataArrayIdType *ids);
426     MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayIdType *ids);
427     MEDLOADER_EXPORT const DataArrayIdType *getNumberFieldAtLevel(int meshDimRelToMaxExt) const;
428     MEDLOADER_EXPORT const DataArrayIdType *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const;
429     MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const;
430     MEDLOADER_EXPORT MCAuto<DataArrayIdType> getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const;
431     MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
432     MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
433     MEDLOADER_EXPORT std::vector<int> getFamArrNonEmptyLevelsExt() const;
434     MEDLOADER_EXPORT std::vector<int> getNumArrNonEmptyLevelsExt() const;
435     MEDLOADER_EXPORT std::vector<int> getNameArrNonEmptyLevelsExt() const;
436     MEDLOADER_EXPORT MEDCouplingMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const;
437     MEDLOADER_EXPORT std::vector<mcIdType> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const;
438     MEDLOADER_EXPORT std::vector<mcIdType> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const;
439     MEDLOADER_EXPORT mcIdType getSizeAtLevel(int meshDimRelToMaxExt) const;
440     MEDLOADER_EXPORT mcIdType getNumberOfNodes() const;
441     MEDLOADER_EXPORT mcIdType getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const;
442     MEDLOADER_EXPORT bool hasImplicitPart() const;
443     MEDLOADER_EXPORT mcIdType buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const;
444     MEDLOADER_EXPORT void releaseImplicitPartIfAny() const;
445     MEDLOADER_EXPORT MEDCoupling1SGTUMesh *getImplicitFaceMesh() const;
446     MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
447     MEDLOADER_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
448     MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
449     MEDLOADER_EXPORT bool presenceOfStructureElements() const { return false; }
450     MEDLOADER_EXPORT virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0;
451     // tools
452     MEDLOADER_EXPORT bool unPolyze(std::vector<mcIdType>& oldCode, std::vector<mcIdType>& newCode, DataArrayIdType *& o2nRenumCell);
453   protected:
454     ~MEDFileStructuredMesh() { }
455     void changeFamilyIdArr(mcIdType oldId, mcIdType newId);
456     std::list< MCAuto<DataArrayIdType> > getAllNonNullFamilyIds() const;
457     void deepCpyAttributes();
458     void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
459     void writeStructuredLL(med_idt fid, const std::string& maa) const;
460     void buildImplicitPart() const;
461     void buildMinusOneImplicitPartIfNeeded() const;
462     static med_geometry_type GetGeoTypeFromMeshDim(int meshDim);
463   private:
464     static void LoadStrMeshDAFromFile(med_idt fid, int meshDim, int dt, int it, const std::string& mName, MEDFileMeshReadSelector *mrs,
465                                       MCAuto<DataArrayIdType>& famCells, MCAuto<DataArrayIdType>& numCells, MCAuto<DataArrayAsciiChar>& namesCells);
466   private:
467     MCAuto<DataArrayIdType> _fam_nodes;
468     MCAuto<DataArrayIdType> _num_nodes;
469     MCAuto<DataArrayAsciiChar> _names_nodes;
470     MCAuto<DataArrayIdType> _fam_cells;
471     MCAuto<DataArrayIdType> _num_cells;
472     MCAuto<DataArrayAsciiChar> _names_cells;
473     MCAuto<DataArrayIdType> _fam_faces;
474     MCAuto<DataArrayIdType> _num_faces;
475     MCAuto<DataArrayAsciiChar> _names_faces;
476     mutable MCAuto<DataArrayIdType> _rev_num_nodes;
477     mutable MCAuto<DataArrayIdType> _rev_num_cells;
478     mutable MCAuto<MEDCoupling1SGTUMesh> _faces_if_necessary;
479   };
480
481   class MEDFileCMesh : public MEDFileStructuredMesh
482   {
483     friend class MEDFileMesh;
484   public:
485     MEDLOADER_EXPORT static MEDFileCMesh *New();
486     MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
487     MEDLOADER_EXPORT static MEDFileCMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0);
488     MEDLOADER_EXPORT static MEDFileCMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileCMesh>(db); }
489     MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
490     MEDLOADER_EXPORT static MEDFileCMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
491     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileCMesh"); }
492     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
493     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
494     MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
495     MEDLOADER_EXPORT MEDFileCMesh *deepCopy() const;
496     MEDLOADER_EXPORT MEDFileCMesh *shallowCpy() const;
497     MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
498     MEDLOADER_EXPORT int getMeshDimension() const;
499     MEDLOADER_EXPORT int getSpaceDimension() const;
500     MEDLOADER_EXPORT std::string simpleRepr() const;
501     MEDLOADER_EXPORT std::string advancedRepr() const;
502     MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
503     MEDLOADER_EXPORT const MEDCouplingCMesh *getMesh() const;
504     MEDLOADER_EXPORT void setMesh(MEDCouplingCMesh *m);
505     MEDLOADER_EXPORT MEDFileMesh *cartesianize() const;
506   private:
507     ~MEDFileCMesh() { }
508     const MEDCouplingStructuredMesh *getStructuredMesh() const;
509     void writeMeshLL(med_idt fid) const;
510     MEDFileCMesh();
511     void synchronizeTinyInfoOnLeaves() const;
512     MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
513     void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
514   private:
515     MCAuto<MEDCouplingCMesh> _cmesh;
516   };
517
518   class MEDFileCurveLinearMesh : public MEDFileStructuredMesh
519   {
520     friend class MEDFileMesh;
521   public:
522     MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New();
523     MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
524     MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0);
525     MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileCurveLinearMesh>(db); }
526     MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
527     MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
528     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileCurveLinearMesh"); }
529     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
530     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
531     MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
532     MEDLOADER_EXPORT MEDFileCurveLinearMesh *deepCopy() const;
533     MEDLOADER_EXPORT MEDFileCurveLinearMesh *shallowCpy() const;
534     MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
535     MEDLOADER_EXPORT int getMeshDimension() const;
536     MEDLOADER_EXPORT int getSpaceDimension() const;
537     MEDLOADER_EXPORT std::string simpleRepr() const;
538     MEDLOADER_EXPORT std::string advancedRepr() const;
539     MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
540     MEDLOADER_EXPORT const MEDCouplingCurveLinearMesh *getMesh() const;
541     MEDLOADER_EXPORT void setMesh(MEDCouplingCurveLinearMesh *m);
542     MEDLOADER_EXPORT MEDFileMesh *cartesianize() const;
543   private:
544     ~MEDFileCurveLinearMesh() { }
545     MEDFileCurveLinearMesh();
546     MEDFileCurveLinearMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
547     const MEDCouplingStructuredMesh *getStructuredMesh() const;
548     void synchronizeTinyInfoOnLeaves() const;
549     void writeMeshLL(med_idt fid) const;
550     void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp
551   private:
552     MCAuto<MEDCouplingCurveLinearMesh> _clmesh;
553   };
554
555   class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritableStandAlone
556   {
557   public:
558     MEDLOADER_EXPORT static MEDFileMeshMultiTS *New();
559     MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(med_idt fid);
560     MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName);
561     MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(med_idt fid, const std::string& mName);
562     MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName);
563     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileMeshMultiTS"); }
564     MEDLOADER_EXPORT MEDFileMeshMultiTS *deepCopy() const;
565     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
566     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
567     MEDLOADER_EXPORT std::string getName() const;
568     MEDLOADER_EXPORT void setName(const std::string& newMeshName);
569     MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
570     MEDLOADER_EXPORT void cartesianizeMe();
571     MEDLOADER_EXPORT MEDFileMesh *getOneTimeStep() const;
572     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
573     MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep);
574     MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
575     MEDLOADER_EXPORT void setJoints(MEDFileJoints* joints);
576     MEDLOADER_EXPORT bool presenceOfStructureElements() const;
577     MEDLOADER_EXPORT void killStructureElements();
578   private:
579     ~MEDFileMeshMultiTS() { }
580     void loadFromFile(med_idt fid, const std::string& mName);
581     MEDFileMeshMultiTS();
582     MEDFileMeshMultiTS(med_idt fid);
583     MEDFileMeshMultiTS(med_idt fid, const std::string& mName);
584   private:
585     std::vector< MCAuto<MEDFileMesh> > _mesh_one_ts;
586   };
587
588   class MEDFileMeshesIterator;
589
590   class MEDFileMeshes : public RefCountObject, public MEDFileWritableStandAlone
591   {
592   public:
593     MEDLOADER_EXPORT static MEDFileMeshes *New();
594     MEDLOADER_EXPORT static MEDFileMeshes *New(med_idt fid);
595     MEDLOADER_EXPORT static MEDFileMeshes *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileMeshes>(db); }
596     MEDLOADER_EXPORT static MEDFileMeshes *New(const std::string& fileName);
597     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileMeshes"); }
598     MEDLOADER_EXPORT MEDFileMeshes *deepCopy() const;
599     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
600     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
601     MEDLOADER_EXPORT std::string simpleRepr() const;
602     MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const;
603     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
604     MEDLOADER_EXPORT int getNumberOfMeshes() const;
605     MEDLOADER_EXPORT MEDFileMeshesIterator *iterator();
606     MEDLOADER_EXPORT MEDFileMesh *getMeshAtPos(int i) const;
607     MEDLOADER_EXPORT MEDFileMesh *getMeshWithName(const std::string& mname) const;
608     MEDLOADER_EXPORT std::vector<std::string> getMeshesNames() const;
609     MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
610     MEDLOADER_EXPORT void cartesianizeMe();
611     //
612     MEDLOADER_EXPORT void resize(int newSize);
613     MEDLOADER_EXPORT void pushMesh(MEDFileMesh *mesh);
614     MEDLOADER_EXPORT void setMeshAtPos(int i, MEDFileMesh *mesh);
615     MEDLOADER_EXPORT void destroyMeshAtPos(int i);
616     MEDLOADER_EXPORT bool presenceOfStructureElements() const;
617     MEDLOADER_EXPORT void killStructureElements();
618   private:
619     ~MEDFileMeshes() { }
620     void checkConsistencyLight() const;
621     void loadFromFile(med_idt fid);
622     MEDFileMeshes();
623     MEDFileMeshes(med_idt fid);
624   private:
625     std::vector< MCAuto<MEDFileMeshMultiTS> > _meshes;
626   };
627
628   class MEDFileMeshesIterator
629   {
630   public:
631     MEDLOADER_EXPORT MEDFileMeshesIterator(MEDFileMeshes *ms);
632     MEDLOADER_EXPORT ~MEDFileMeshesIterator();
633     MEDLOADER_EXPORT MEDFileMesh *nextt();
634   private:
635     MCAuto<MEDFileMeshes> _ms;
636     int _iter_id;
637     int _nb_iter;
638   };
639 }
640
641 #endif