1 // Copyright (C) 2007-2016 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 (EDF R&D)
21 #ifndef __MEDFILEFIELDGLOBS_HXX__
22 #define __MEDFILEFIELDGLOBS_HXX__
24 #include "MEDLoaderDefines.hxx"
26 #include "NormalizedGeometricTypes"
27 #include "MEDCouplingMemArray.hxx"
34 class MEDFileFieldGlobsReal;
35 class MEDFileEntities;
36 class MEDFileWritable;
37 class MEDFileFieldLoc;
39 class MEDFileFieldGlobs : public RefCountObject
42 static MEDFileFieldGlobs *New(med_idt fid);
43 static MEDFileFieldGlobs *New();
44 std::size_t getHeapMemorySizeWithoutChildren() const;
45 std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
46 MEDFileFieldGlobs *deepCopy() const;
47 MEDFileFieldGlobs *shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const;
48 MEDFileFieldGlobs *deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const;
49 void simpleRepr(std::ostream& oss) const;
50 void appendGlobs(const MEDFileFieldGlobs& other, double eps);
51 void checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const;
52 void checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const;
53 void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
54 void loadProfileInFile(med_idt fid, int id);
55 void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real);
56 void loadAllGlobals(med_idt fid, const MEDFileEntities *entities);
57 void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
58 std::vector<std::string> getPfls() const;
59 std::vector<std::string> getLocs() const;
60 bool existsPfl(const std::string& pflName) const;
61 bool existsLoc(const std::string& locName) const;
62 std::string createNewNameOfPfl() const;
63 std::string createNewNameOfLoc() const;
64 std::vector< std::vector<int> > whichAreEqualProfiles() const;
65 std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
66 void setFileName(const std::string& fileName) { _file_name=fileName; }
67 void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
68 void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
69 int getNbOfGaussPtPerCell(int locId) const;
70 int getLocalizationId(const std::string& loc) const;
71 std::string getFileName() const { return _file_name; }
72 const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
73 const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
74 const DataArrayInt *getProfileFromId(int pflId) const;
75 const DataArrayInt *getProfile(const std::string& pflName) const;
76 MEDFileFieldLoc& getLocalizationFromId(int locId);
77 MEDFileFieldLoc& getLocalization(const std::string& locName);
78 DataArrayInt *getProfile(const std::string& pflName);
79 DataArrayInt *getProfileFromId(int pflId);
80 void killProfileIds(const std::vector<int>& pflIds);
81 void killLocalizationIds(const std::vector<int>& locIds);
82 void killStructureElementsInGlobs();
84 void appendProfile(DataArrayInt *pfl);
85 void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
87 static std::string CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid);
89 MEDFileFieldGlobs(med_idt fid);
93 std::vector< MCAuto<DataArrayInt> > _pfls;
94 std::vector< MCAuto<MEDFileFieldLoc> > _locs;
95 std::string _file_name;
100 class MEDFileFieldGlobsReal
103 MEDLOADER_EXPORT MEDFileFieldGlobsReal(med_idt fid);
104 MEDLOADER_EXPORT MEDFileFieldGlobsReal();
105 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
106 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
107 MEDLOADER_EXPORT void simpleReprGlobs(std::ostream& oss) const;
108 MEDLOADER_EXPORT void resetContent();
109 MEDLOADER_EXPORT void killStructureElementsInGlobs();
110 MEDLOADER_EXPORT void shallowCpyGlobs(const MEDFileFieldGlobsReal& other);
111 MEDLOADER_EXPORT void deepCpyGlobs(const MEDFileFieldGlobsReal& other);
112 MEDLOADER_EXPORT void shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other);
113 MEDLOADER_EXPORT void deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other);
114 MEDLOADER_EXPORT void appendGlobs(const MEDFileFieldGlobsReal& other, double eps);
115 MEDLOADER_EXPORT void checkGlobsCoherency() const;
116 MEDLOADER_EXPORT void checkGlobsPflsPartCoherency() const;
117 MEDLOADER_EXPORT void checkGlobsLocsPartCoherency() const;
118 MEDLOADER_EXPORT virtual std::vector<std::string> getPflsReallyUsed() const = 0;
119 MEDLOADER_EXPORT virtual std::vector<std::string> getLocsReallyUsed() const = 0;
120 MEDLOADER_EXPORT virtual std::vector<std::string> getPflsReallyUsedMulti() const = 0;
121 MEDLOADER_EXPORT virtual std::vector<std::string> getLocsReallyUsedMulti() const = 0;
122 MEDLOADER_EXPORT virtual void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) = 0;
123 MEDLOADER_EXPORT virtual void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) = 0;
124 MEDLOADER_EXPORT virtual ~MEDFileFieldGlobsReal();
126 MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
127 MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id);
128 MEDLOADER_EXPORT void loadGlobals(med_idt fid);
129 MEDLOADER_EXPORT void loadAllGlobals(med_idt fid, const MEDFileEntities *entities=0);
130 MEDLOADER_EXPORT void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
131 MEDLOADER_EXPORT std::vector<std::string> getPfls() const;
132 MEDLOADER_EXPORT std::vector<std::string> getLocs() const;
133 MEDLOADER_EXPORT bool existsPfl(const std::string& pflName) const;
134 MEDLOADER_EXPORT bool existsLoc(const std::string& locName) const;
135 MEDLOADER_EXPORT std::string createNewNameOfPfl() const;
136 MEDLOADER_EXPORT std::string createNewNameOfLoc() const;
137 MEDLOADER_EXPORT std::vector< std::vector<int> > whichAreEqualProfiles() const;
138 MEDLOADER_EXPORT std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
139 MEDLOADER_EXPORT void setFileName(const std::string& fileName);
140 MEDLOADER_EXPORT void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
141 MEDLOADER_EXPORT void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
142 MEDLOADER_EXPORT void changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
143 MEDLOADER_EXPORT void changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
144 MEDLOADER_EXPORT void changePflName(const std::string& oldName, const std::string& newName);
145 MEDLOADER_EXPORT void changeLocName(const std::string& oldName, const std::string& newName);
146 MEDLOADER_EXPORT std::vector< std::pair<std::vector<std::string>, std::string > > zipPflsNames();
147 MEDLOADER_EXPORT std::vector< std::pair<std::vector<std::string>, std::string > > zipLocsNames(double eps);
148 MEDLOADER_EXPORT int getNbOfGaussPtPerCell(int locId) const;
149 MEDLOADER_EXPORT int getLocalizationId(const std::string& loc) const;
150 MEDLOADER_EXPORT std::string getFileName() const;
151 MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
152 MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
153 MEDLOADER_EXPORT MEDFileFieldLoc& getLocalizationFromId(int locId);
154 MEDLOADER_EXPORT MEDFileFieldLoc& getLocalization(const std::string& locName);
155 MEDLOADER_EXPORT const DataArrayInt *getProfile(const std::string& pflName) const;
156 MEDLOADER_EXPORT const DataArrayInt *getProfileFromId(int pflId) const;
157 MEDLOADER_EXPORT DataArrayInt *getProfile(const std::string& pflName);
158 MEDLOADER_EXPORT DataArrayInt *getProfileFromId(int pflId);
159 MEDLOADER_EXPORT void killProfileIds(const std::vector<int>& pflIds);
160 MEDLOADER_EXPORT void killLocalizationIds(const std::vector<int>& locIds);
162 MEDLOADER_EXPORT void appendProfile(DataArrayInt *pfl);
163 MEDLOADER_EXPORT void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
165 MEDFileFieldGlobs *contentNotNull();
166 const MEDFileFieldGlobs *contentNotNull() const;
168 MCAuto< MEDFileFieldGlobs > _globals;
171 class MEDFileFieldNameScope
174 MEDLOADER_EXPORT MEDFileFieldNameScope();
175 MEDLOADER_EXPORT MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName);
176 MEDLOADER_EXPORT std::string getName() const;
177 MEDLOADER_EXPORT void setName(const std::string& fieldName);
178 MEDLOADER_EXPORT std::string getDtUnit() const;
179 MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
180 MEDLOADER_EXPORT void copyNameScope(const MEDFileFieldNameScope& other);
181 MEDLOADER_EXPORT std::string getMeshName() const;
182 MEDLOADER_EXPORT void setMeshName(const std::string& meshName);
185 std::string _dt_unit;
186 std::string _mesh_name;