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