1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __MEDFILEMESH_HXX__
22 #define __MEDFILEMESH_HXX__
24 #include "MEDLoaderDefines.hxx"
25 #include "MEDFileMeshLL.hxx"
26 #include "MEDFileUtilities.hxx"
27 #include "MEDCouplingPartDefinition.hxx"
28 #include "MEDFileMeshReadSelector.hxx"
29 #include "MEDFileJoint.hxx"
30 #include "MEDFileEquivalence.hxx"
37 class MEDFileFieldGlobsReal;
38 class MEDFileField1TSStructItem;
40 class MEDFileMesh : public RefCountObject, public MEDFileWritable
43 MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
44 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);
45 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
46 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
47 MEDLOADER_EXPORT virtual MEDFileMesh *createNewEmpty() const = 0;
48 MEDLOADER_EXPORT virtual MEDFileMesh *deepCpy() const = 0;
49 MEDLOADER_EXPORT virtual MEDFileMesh *shallowCpy() const = 0;
50 MEDLOADER_EXPORT virtual bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
51 MEDLOADER_EXPORT virtual void clearNonDiscrAttributes() const;
52 MEDLOADER_EXPORT virtual void setName(const std::string& name);
53 MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
54 MEDLOADER_EXPORT std::string getName() const { return _name; }
55 MEDLOADER_EXPORT std::string getUnivName() const { return _univ_name; }
56 MEDLOADER_EXPORT bool getUnivNameWrStatus() const { return _univ_wr_status; }
57 MEDLOADER_EXPORT void setUnivNameWrStatus(bool newStatus) { _univ_wr_status=newStatus; }
58 MEDLOADER_EXPORT void setDescription(const std::string& name) { _desc_name=name; }
59 MEDLOADER_EXPORT std::string getDescription() const { return _desc_name; }
60 MEDLOADER_EXPORT void setOrder(int order) { _order=order; }
61 MEDLOADER_EXPORT int getOrder() const { return _order; }
62 MEDLOADER_EXPORT void setIteration(int it) { _iteration=it; }
63 MEDLOADER_EXPORT int getIteration() const { return _iteration; }
64 MEDLOADER_EXPORT void setTimeValue(double time) { _time=time; }
65 MEDLOADER_EXPORT void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; }
66 MEDLOADER_EXPORT double getTime(int& dt, int& it) const { dt=_iteration; it=_order; return _time; }
67 MEDLOADER_EXPORT double getTimeValue() const { return _time; }
68 MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
69 MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
70 MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
71 MEDLOADER_EXPORT virtual int getNumberOfNodes() const = 0;
72 MEDLOADER_EXPORT virtual int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const = 0;
73 MEDLOADER_EXPORT virtual bool hasImplicitPart() const = 0;
74 MEDLOADER_EXPORT virtual int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const = 0;
75 MEDLOADER_EXPORT virtual void releaseImplicitPartIfAny() const = 0;
76 MEDLOADER_EXPORT virtual std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const = 0;
77 MEDLOADER_EXPORT virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const = 0;
78 MEDLOADER_EXPORT virtual std::vector<int> getNonEmptyLevels() const = 0;
79 MEDLOADER_EXPORT virtual std::vector<int> getNonEmptyLevelsExt() const = 0;
80 MEDLOADER_EXPORT virtual std::vector<int> getFamArrNonEmptyLevelsExt() const = 0;
81 MEDLOADER_EXPORT virtual std::vector<int> getNumArrNonEmptyLevelsExt() const = 0;
82 MEDLOADER_EXPORT virtual std::vector<int> getNameArrNonEmptyLevelsExt() const = 0;
83 MEDLOADER_EXPORT virtual void write(const std::string& fileName, int mode) const;
84 MEDLOADER_EXPORT virtual void write(med_idt fid) const;
85 MEDLOADER_EXPORT virtual int getSizeAtLevel(int meshDimRelToMaxExt) const = 0;
86 MEDLOADER_EXPORT virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const = 0;
87 MEDLOADER_EXPORT virtual std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const;
88 MEDLOADER_EXPORT virtual void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const = 0;
90 MEDLOADER_EXPORT bool areFamsEqual(const MEDFileMesh *other, std::string& what) const;
91 MEDLOADER_EXPORT bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const;
92 MEDLOADER_EXPORT bool existsGroup(const std::string& groupName) const;
93 MEDLOADER_EXPORT bool existsFamily(int famId) const;
94 MEDLOADER_EXPORT bool existsFamily(const std::string& familyName) const;
95 MEDLOADER_EXPORT void setFamilyId(const std::string& familyName, int id);
96 MEDLOADER_EXPORT void setFamilyIdUnique(const std::string& familyName, int id);
97 MEDLOADER_EXPORT virtual void addFamily(const std::string& familyName, int id);
98 MEDLOADER_EXPORT virtual void createGroupOnAll(int meshDimRelToMaxExt, const std::string& groupName);
99 MEDLOADER_EXPORT virtual bool keepFamIdsOnlyOnLevs(const std::vector<int>& famIds, const std::vector<int>& levs);
100 MEDLOADER_EXPORT void addFamilyOnGrp(const std::string& grpName, const std::string& famName);
101 MEDLOADER_EXPORT std::string findOrCreateAndGiveFamilyWithId(int id, bool& created);
102 MEDLOADER_EXPORT void setFamilyInfo(const std::map<std::string,int>& info);
103 MEDLOADER_EXPORT void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
104 MEDLOADER_EXPORT void copyFamGrpMapsFrom(const MEDFileMesh& other);
105 MEDLOADER_EXPORT void clearGrpMap();
106 MEDLOADER_EXPORT void clearFamMap();
107 MEDLOADER_EXPORT void clearFamGrpMaps();
108 MEDLOADER_EXPORT const std::map<std::string,int>& getFamilyInfo() const { return _families; }
109 MEDLOADER_EXPORT const std::map<std::string, std::vector<std::string> >& getGroupInfo() const { return _groups; }
110 MEDLOADER_EXPORT std::vector<std::string> getFamiliesOnGroup(const std::string& name) const;
111 MEDLOADER_EXPORT std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const;
112 MEDLOADER_EXPORT std::vector<int> getFamiliesIdsOnGroup(const std::string& name) const;
113 MEDLOADER_EXPORT void setFamiliesOnGroup(const std::string& name, const std::vector<std::string>& fams);
114 MEDLOADER_EXPORT void setFamiliesIdsOnGroup(const std::string& name, const std::vector<int>& famIds);
115 MEDLOADER_EXPORT std::vector<std::string> getGroupsOnFamily(const std::string& name) const;
116 MEDLOADER_EXPORT void setGroupsOnFamily(const std::string& famName, const std::vector<std::string>& grps);
117 MEDLOADER_EXPORT std::vector<std::string> getGroupsNames() const;
118 MEDLOADER_EXPORT std::vector<std::string> getFamiliesNames() const;
119 MEDLOADER_EXPORT void assignFamilyNameWithGroupName();
120 MEDLOADER_EXPORT std::vector<std::string> removeEmptyGroups();
121 MEDLOADER_EXPORT void removeGroup(const std::string& name);
122 MEDLOADER_EXPORT void removeFamily(const std::string& name);
123 MEDLOADER_EXPORT std::vector<std::string> removeOrphanGroups();
124 MEDLOADER_EXPORT std::vector<std::string> removeOrphanFamilies();
125 MEDLOADER_EXPORT void removeFamiliesReferedByNoGroups();
126 MEDLOADER_EXPORT void rearrangeFamilies();
127 MEDLOADER_EXPORT void checkOrphanFamilyZero() const;
128 MEDLOADER_EXPORT void changeGroupName(const std::string& oldName, const std::string& newName);
129 MEDLOADER_EXPORT void changeFamilyName(const std::string& oldName, const std::string& newName);
130 MEDLOADER_EXPORT void changeFamilyId(int oldId, int newId);
131 MEDLOADER_EXPORT void changeAllGroupsContainingFamily(const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames);
132 MEDLOADER_EXPORT int getFamilyId(const std::string& name) const;
133 MEDLOADER_EXPORT int getMaxAbsFamilyId() const;
134 MEDLOADER_EXPORT int getMaxFamilyId() const;
135 MEDLOADER_EXPORT int getMinFamilyId() const;
136 MEDLOADER_EXPORT int getTheMaxAbsFamilyId() const;
137 MEDLOADER_EXPORT int getTheMaxFamilyId() const;
138 MEDLOADER_EXPORT int getTheMinFamilyId() const;
139 MEDLOADER_EXPORT virtual int getMaxAbsFamilyIdInArrays() const = 0;
140 MEDLOADER_EXPORT virtual int getMaxFamilyIdInArrays() const = 0;
141 MEDLOADER_EXPORT virtual int getMinFamilyIdInArrays() const = 0;
142 MEDLOADER_EXPORT DataArrayInt *getAllFamiliesIdsReferenced() const;
143 MEDLOADER_EXPORT DataArrayInt *computeAllFamilyIdsInUse() const;
144 MEDLOADER_EXPORT std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const;
145 MEDLOADER_EXPORT std::string getFamilyNameGivenId(int id) const;
146 MEDLOADER_EXPORT bool ensureDifferentFamIdsPerLevel();
147 MEDLOADER_EXPORT void normalizeFamIdsTrio();
148 MEDLOADER_EXPORT void normalizeFamIdsMEDFile();
149 MEDLOADER_EXPORT virtual int getMeshDimension() const = 0;
150 MEDLOADER_EXPORT virtual std::string simpleRepr() const;
151 MEDLOADER_EXPORT virtual std::string advancedRepr() const = 0;
153 MEDLOADER_EXPORT virtual void setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayInt *>& grps, bool renum=false);
154 MEDLOADER_EXPORT virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) = 0;
155 MEDLOADER_EXPORT virtual void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) = 0;
156 MEDLOADER_EXPORT virtual void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) = 0;
157 MEDLOADER_EXPORT virtual void addNodeGroup(const DataArrayInt *ids) = 0;
158 MEDLOADER_EXPORT virtual void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids) = 0;
159 MEDLOADER_EXPORT virtual const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const = 0;
160 MEDLOADER_EXPORT virtual DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) = 0;
161 MEDLOADER_EXPORT DataArrayInt *getOrCreateAndGetFamilyFieldAtLevel(int meshDimRelToMaxExt);
162 MEDLOADER_EXPORT virtual const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const = 0;
163 MEDLOADER_EXPORT virtual const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const = 0;
164 MEDLOADER_EXPORT virtual const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const = 0;
165 MEDLOADER_EXPORT virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const = 0;
166 MEDLOADER_EXPORT virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const;
167 MEDLOADER_EXPORT virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const;
168 MEDLOADER_EXPORT virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const;
169 MEDLOADER_EXPORT virtual DataArrayInt *getNodeGroupArr(const std::string& grp, bool renum=false) const;
170 MEDLOADER_EXPORT virtual DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const;
171 MEDLOADER_EXPORT virtual DataArrayInt *getNodeFamilyArr(const std::string& fam, bool renum=false) const;
172 MEDLOADER_EXPORT virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const;
174 MEDLOADER_EXPORT virtual bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell) = 0;
175 MEDLOADER_EXPORT int getNumberOfJoints() const;
176 MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
177 MEDLOADER_EXPORT void setJoints( MEDFileJoints* joints );
178 MEDFileEquivalences *getEquivalences() { return _equiv; }
179 const MEDFileEquivalences *getEquivalences() const { return _equiv; }
180 void killEquivalences() { _equiv=(MEDFileEquivalences *)0; }
181 void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); }
184 //! protected because no way in MED file API to specify this name
185 void setUnivName(const std::string& name) { _univ_name=name; }
186 void addFamilyOnAllGroupsHaving(const std::string& famName, const std::string& otherFamName);
187 virtual void writeLL(med_idt fid) const = 0;
188 void dealWithTinyInfo(const MEDCouplingMesh *m);
189 virtual void synchronizeTinyInfoOnLeaves() const = 0;
190 void getFamilyRepr(std::ostream& oss) const;
191 virtual void appendFamilyEntries(const DataArrayInt *famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
192 virtual void changeFamilyIdArr(int oldId, int newId) = 0;
193 virtual std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const = 0;
194 virtual void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) = 0;
195 void loadLLWithAdditionalItems(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
196 void addGroupUnderground(bool isNodeGroup, const DataArrayInt *ids, DataArrayInt *famArr);
197 static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
198 static void ChangeAllGroupsContainingFamily(std::map<std::string, std::vector<std::string> >& groups, const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames);
199 static std::string FindOrCreateAndGiveFamilyWithId(std::map<std::string,int>& families, int id, bool& created);
200 static std::string CreateNameNotIn(const std::string& nameTry, const std::vector<std::string>& namesToAvoid);
201 static int PutInThirdComponentOfCodeOffset(std::vector<int>& code, int strt);
202 void writeJoints(med_idt fid) const;
203 void loadJointsFromFile(med_idt fid, MEDFileJoints *toUseInstedOfReading=0);
204 void loadEquivalences(med_idt fid);
205 void deepCpyEquivalences(const MEDFileMesh& other);
206 bool areEquivalencesEqual(const MEDFileMesh *other, std::string& what) const;
207 void getEquivalencesRepr(std::ostream& oss) const;
212 std::string _dt_unit;
214 //! this attribute do not impact the state of instance -> mutable
215 mutable std::string _univ_name;
216 bool _univ_wr_status;
217 std::string _desc_name;
218 MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> _joints;
219 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalences> _equiv;
221 std::map<std::string, std::vector<std::string> > _groups;
222 std::map<std::string,int> _families;
224 MEDLOADER_EXPORT static const char DFT_FAM_NAME[];
227 class MEDFileUMesh : public MEDFileMesh
229 friend class MEDFileMesh;
231 MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
232 MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
233 MEDLOADER_EXPORT static MEDFileUMesh *New();
234 MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
235 MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(med_idt fid, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
236 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
237 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
238 MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
239 MEDLOADER_EXPORT MEDFileMesh *deepCpy() const;
240 MEDLOADER_EXPORT MEDFileMesh *shallowCpy() const;
241 MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
242 MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
243 MEDLOADER_EXPORT void setName(const std::string& name);
245 MEDLOADER_EXPORT int getMaxAbsFamilyIdInArrays() const;
246 MEDLOADER_EXPORT int getMaxFamilyIdInArrays() const;
247 MEDLOADER_EXPORT int getMinFamilyIdInArrays() const;
248 MEDLOADER_EXPORT int getMeshDimension() const;
249 MEDLOADER_EXPORT int getSpaceDimension() const;
250 MEDLOADER_EXPORT std::string simpleRepr() const;
251 MEDLOADER_EXPORT std::string advancedRepr() const;
252 MEDLOADER_EXPORT int getSizeAtLevel(int meshDimRelToMaxExt) const;
253 MEDLOADER_EXPORT const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const;
254 MEDLOADER_EXPORT DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt);
255 MEDLOADER_EXPORT const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const;
256 MEDLOADER_EXPORT const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const;
257 MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const;
258 MEDLOADER_EXPORT const PartDefinition *getPartDefAtLevel(int meshDimRelToMaxExt, INTERP_KERNEL::NormalizedCellType gt=INTERP_KERNEL::NORM_ERROR) const;
259 MEDLOADER_EXPORT int getNumberOfNodes() const;
260 MEDLOADER_EXPORT int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const;
261 MEDLOADER_EXPORT bool hasImplicitPart() const;
262 MEDLOADER_EXPORT int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const;
263 MEDLOADER_EXPORT void releaseImplicitPartIfAny() const;
264 MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
265 MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
266 MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
267 MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
268 MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
269 MEDLOADER_EXPORT std::vector<int> getFamArrNonEmptyLevelsExt() const;
270 MEDLOADER_EXPORT std::vector<int> getNumArrNonEmptyLevelsExt() const;
271 MEDLOADER_EXPORT std::vector<int> getNameArrNonEmptyLevelsExt() const;
272 MEDLOADER_EXPORT std::vector<int> getGrpNonEmptyLevels(const std::string& grp) const;
273 MEDLOADER_EXPORT std::vector<int> getGrpNonEmptyLevelsExt(const std::string& grp) const;
274 MEDLOADER_EXPORT std::vector<int> getFamNonEmptyLevels(const std::string& fam) const;
275 MEDLOADER_EXPORT std::vector<int> getFamNonEmptyLevelsExt(const std::string& fam) const;
276 MEDLOADER_EXPORT std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const;
277 MEDLOADER_EXPORT std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const;
278 MEDLOADER_EXPORT std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const;
279 MEDLOADER_EXPORT std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const;
280 MEDLOADER_EXPORT std::vector<std::string> getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const;
281 MEDLOADER_EXPORT DataArrayDouble *getCoords() const;
282 MEDLOADER_EXPORT MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const;
283 MEDLOADER_EXPORT MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const;
284 MEDLOADER_EXPORT MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const;
285 MEDLOADER_EXPORT MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
286 MEDLOADER_EXPORT DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
287 MEDLOADER_EXPORT MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const;
288 MEDLOADER_EXPORT MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const;
289 MEDLOADER_EXPORT std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const;
290 MEDLOADER_EXPORT MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const;
291 MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const;
292 MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const;
293 MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const;
294 MEDLOADER_EXPORT void forceComputationOfParts() const;
295 MEDLOADER_EXPORT std::vector<MEDCoupling1GTUMesh *> getDirectUndergroundSingleGeoTypeMeshes(int meshDimRelToMax) const;
296 MEDLOADER_EXPORT MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const;
297 MEDLOADER_EXPORT DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
298 MEDLOADER_EXPORT DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
299 MEDLOADER_EXPORT int getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
301 MEDLOADER_EXPORT void setFamilyNameAttachedOnId(int id, const std::string& newFamName);
302 MEDLOADER_EXPORT void setCoords(DataArrayDouble *coords);
303 MEDLOADER_EXPORT void eraseGroupsAtLevel(int meshDimRelToMaxExt);
304 MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr);
305 MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr);
306 MEDLOADER_EXPORT void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr);
307 MEDLOADER_EXPORT void addNodeGroup(const DataArrayInt *ids);
308 MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids);
309 MEDLOADER_EXPORT void removeMeshAtLevel(int meshDimRelToMax);
310 MEDLOADER_EXPORT void setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m);
311 MEDLOADER_EXPORT void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false);
312 MEDLOADER_EXPORT void setMeshes(const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
313 MEDLOADER_EXPORT void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
314 MEDLOADER_EXPORT void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
315 MEDLOADER_EXPORT void optimizeFamilies();
317 MEDLOADER_EXPORT void buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified, DataArrayInt *&cellsNotModified);
318 MEDLOADER_EXPORT bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell);
319 MEDLOADER_EXPORT DataArrayInt *zipCoords();
320 MEDLOADER_EXPORT MEDFileUMesh *buildExtrudedMesh(const MEDCouplingUMesh *m1D, int policy) const;
321 MEDLOADER_EXPORT MEDFileUMesh *linearToQuadratic(int conversionType=0, double eps=1e-12) const;
322 MEDLOADER_EXPORT MEDFileUMesh *quadraticToLinear(double eps=1e-12) const;
324 MEDLOADER_EXPORT void serialize(std::vector<double>& tinyDouble, std::vector<int>& tinyInt, std::vector<std::string>& tinyStr,
325 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >& bigArraysI, MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& bigArrayD);
326 MEDLOADER_EXPORT void unserialize(std::vector<double>& tinyDouble, std::vector<int>& tinyInt, std::vector<std::string>& tinyStr,
327 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >& bigArraysI, MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& bigArrayD);
329 MEDLOADER_EXPORT ~MEDFileUMesh();
330 void writeLL(med_idt fid) const;
332 MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
333 void loadPartUMeshFromFile(med_idt fid, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
334 void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
335 void dispatchLoadedPart(med_idt fid, const MEDFileUMeshL2& loaderl2, const std::string& mName, MEDFileMeshReadSelector *mrs);
336 const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) const;
337 MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt);
338 void checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const;
339 DataArrayDouble *checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const;
340 void computeRevNum() const;
341 void synchronizeTinyInfoOnLeaves() const;
342 void changeFamilyIdArr(int oldId, int newId);
343 std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const;
344 MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1>& checkAndGiveEntryInSplitL1(int meshDimRelToMax, MEDCouplingPointSet *m);
346 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
347 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
348 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
349 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
350 MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _name_coords;
351 mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_coords;
352 MEDCouplingAutoRefCountObjectPtr<PartDefinition> _part_coords;
355 class MEDFileStructuredMesh : public MEDFileMesh
357 friend class MEDFileMesh;
359 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
360 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
361 MEDLOADER_EXPORT int getMaxAbsFamilyIdInArrays() const;
362 MEDLOADER_EXPORT int getMaxFamilyIdInArrays() const;
363 MEDLOADER_EXPORT int getMinFamilyIdInArrays() const;
364 MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
365 MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
366 MEDLOADER_EXPORT DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
367 MEDLOADER_EXPORT const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const;
368 MEDLOADER_EXPORT DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt);
369 MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr);
370 MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr);
371 MEDLOADER_EXPORT void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr);
372 MEDLOADER_EXPORT void addNodeGroup(const DataArrayInt *ids);
373 MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids);
374 MEDLOADER_EXPORT const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const;
375 MEDLOADER_EXPORT const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const;
376 MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const;
377 MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
378 MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
379 MEDLOADER_EXPORT std::vector<int> getFamArrNonEmptyLevelsExt() const;
380 MEDLOADER_EXPORT std::vector<int> getNumArrNonEmptyLevelsExt() const;
381 MEDLOADER_EXPORT std::vector<int> getNameArrNonEmptyLevelsExt() const;
382 MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const;
383 MEDLOADER_EXPORT int getSizeAtLevel(int meshDimRelToMaxExt) const;
384 MEDLOADER_EXPORT int getNumberOfNodes() const;
385 MEDLOADER_EXPORT int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const;
386 MEDLOADER_EXPORT bool hasImplicitPart() const;
387 MEDLOADER_EXPORT int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const;
388 MEDLOADER_EXPORT void releaseImplicitPartIfAny() const;
389 MEDLOADER_EXPORT MEDCoupling1SGTUMesh *getImplicitFaceMesh() const;
390 MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
391 MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
392 MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
393 MEDLOADER_EXPORT virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0;
395 MEDLOADER_EXPORT bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell);
397 ~MEDFileStructuredMesh() { }
398 void changeFamilyIdArr(int oldId, int newId);
399 std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const;
400 void deepCpyAttributes();
401 void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
402 void writeStructuredLL(med_idt fid, const std::string& maa) const;
403 void buildImplicitPart() const;
404 void buildMinusOneImplicitPartIfNeeded() const;
405 static med_geometry_type GetGeoTypeFromMeshDim(int meshDim);
407 static void LoadStrMeshDAFromFile(med_idt fid, int meshDim, int dt, int it, const std::string& mName, MEDFileMeshReadSelector *mrs,
408 MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& famCells, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& numCells, MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar>& namesCells);
410 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_nodes;
411 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_nodes;
412 MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names_nodes;
413 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_cells;
414 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_cells;
415 MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names_cells;
416 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_faces;
417 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_faces;
418 MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names_faces;
419 mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_nodes;
420 mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_cells;
421 mutable MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> _faces_if_necessary;
424 class MEDFileCMesh : public MEDFileStructuredMesh
426 friend class MEDFileMesh;
428 MEDLOADER_EXPORT static MEDFileCMesh *New();
429 MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
430 MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
431 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
432 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
433 MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
434 MEDLOADER_EXPORT MEDFileMesh *deepCpy() const;
435 MEDLOADER_EXPORT MEDFileMesh *shallowCpy() const;
436 MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
437 MEDLOADER_EXPORT int getMeshDimension() const;
438 MEDLOADER_EXPORT int getSpaceDimension() const;
439 MEDLOADER_EXPORT std::string simpleRepr() const;
440 MEDLOADER_EXPORT std::string advancedRepr() const;
441 MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
442 MEDLOADER_EXPORT const MEDCouplingCMesh *getMesh() const;
443 MEDLOADER_EXPORT void setMesh(MEDCouplingCMesh *m);
446 const MEDCouplingStructuredMesh *getStructuredMesh() const;
447 void writeLL(med_idt fid) const;
449 void synchronizeTinyInfoOnLeaves() const;
450 MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
451 void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
453 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
456 class MEDFileCurveLinearMesh : public MEDFileStructuredMesh
458 friend class MEDFileMesh;
460 MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New();
461 MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
462 MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
463 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
464 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
465 MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
466 MEDLOADER_EXPORT MEDFileMesh *deepCpy() const;
467 MEDLOADER_EXPORT MEDFileMesh *shallowCpy() const;
468 MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
469 MEDLOADER_EXPORT int getMeshDimension() const;
470 MEDLOADER_EXPORT std::string simpleRepr() const;
471 MEDLOADER_EXPORT std::string advancedRepr() const;
472 MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
473 MEDLOADER_EXPORT const MEDCouplingCurveLinearMesh *getMesh() const;
474 MEDLOADER_EXPORT void setMesh(MEDCouplingCurveLinearMesh *m);
476 ~MEDFileCurveLinearMesh() { }
477 MEDFileCurveLinearMesh();
478 MEDFileCurveLinearMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
479 const MEDCouplingStructuredMesh *getStructuredMesh() const;
480 void synchronizeTinyInfoOnLeaves() const;
481 void writeLL(med_idt fid) const;
482 void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp
484 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> _clmesh;
487 class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable
490 MEDLOADER_EXPORT static MEDFileMeshMultiTS *New();
491 MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName);
492 MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName);
493 MEDLOADER_EXPORT MEDFileMeshMultiTS *deepCpy() const;
494 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
495 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
496 MEDLOADER_EXPORT std::string getName() const;
497 MEDLOADER_EXPORT void setName(const std::string& newMeshName);
498 MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
499 MEDLOADER_EXPORT MEDFileMesh *getOneTimeStep() const;
500 MEDLOADER_EXPORT void write(med_idt fid) const;
501 MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
502 MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep);
503 MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
504 MEDLOADER_EXPORT void setJoints( MEDFileJoints* joints );
506 ~MEDFileMeshMultiTS() { }
507 void loadFromFile(const std::string& fileName, const std::string& mName);
508 MEDFileMeshMultiTS();
509 MEDFileMeshMultiTS(const std::string& fileName);
510 MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName);
512 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> > _mesh_one_ts;
515 class MEDFileMeshesIterator;
517 class MEDFileMeshes : public RefCountObject, public MEDFileWritable
520 MEDLOADER_EXPORT static MEDFileMeshes *New();
521 MEDLOADER_EXPORT static MEDFileMeshes *New(const std::string& fileName);
522 MEDLOADER_EXPORT MEDFileMeshes *deepCpy() const;
523 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
524 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
525 MEDLOADER_EXPORT std::string simpleRepr() const;
526 MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const;
527 MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
528 MEDLOADER_EXPORT void write(med_idt fid) const;
529 MEDLOADER_EXPORT int getNumberOfMeshes() const;
530 MEDLOADER_EXPORT MEDFileMeshesIterator *iterator();
531 MEDLOADER_EXPORT MEDFileMesh *getMeshAtPos(int i) const;
532 MEDLOADER_EXPORT MEDFileMesh *getMeshWithName(const std::string& mname) const;
533 MEDLOADER_EXPORT std::vector<std::string> getMeshesNames() const;
534 MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
536 MEDLOADER_EXPORT void resize(int newSize);
537 MEDLOADER_EXPORT void pushMesh(MEDFileMesh *mesh);
538 MEDLOADER_EXPORT void setMeshAtPos(int i, MEDFileMesh *mesh);
539 MEDLOADER_EXPORT void destroyMeshAtPos(int i);
542 void checkCoherency() const;
543 void loadFromFile(const std::string& fileName);
545 MEDFileMeshes(const std::string& fileName);
547 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> > _meshes;
550 class MEDFileMeshesIterator
553 MEDLOADER_EXPORT MEDFileMeshesIterator(MEDFileMeshes *ms);
554 MEDLOADER_EXPORT ~MEDFileMeshesIterator();
555 MEDLOADER_EXPORT MEDFileMesh *nextt();
557 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> _ms;