1 // Copyright (C) 2007-2020 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 __MEDFILEEQUIVALENCE_HXX__
22 #define __MEDFILEEQUIVALENCE_HXX__
24 #include "MEDLoaderDefines.hxx"
25 #include "MEDCouplingRefCountObject.hxx"
26 #include "MEDCouplingMemArray.hxx"
27 #include "MEDFileUtilities.txx"
30 #include "NormalizedGeometricTypes"
36 class MEDFileEquivalenceCell;
37 class MEDFileEquivalenceNode;
38 class MEDFileEquivalences;
41 class MEDFileEquivalencePair : public RefCountObject, public MEDFileWritableStandAlone
44 static MEDFileEquivalencePair *Load(MEDFileEquivalences *father, med_idt fid, const std::string& name, const std::string &desc);
45 std::string getClassName() const override { return std::string("MEDFileEquivalencePair"); }
46 void writeLL(med_idt fid) const;
47 const MEDFileEquivalences *getFather() const { return _father; }
48 MEDFileEquivalences *getFather() { return _father; }
49 const MEDFileMesh *getMesh() const;
50 MEDFileMesh *getMesh();
51 MEDFileEquivalencePair *deepCopy(MEDFileEquivalences *father) const;
52 bool isEqual(const MEDFileEquivalencePair *other, std::string& what) const;
53 void getRepr(std::ostream& oss) const;
54 static MEDFileEquivalencePair *New(MEDFileEquivalences *father, const std::string& name);
55 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
56 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
58 MEDLOADER_EXPORT std::string getName() const { return _name; }
59 MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; }
60 MEDLOADER_EXPORT std::string getDescription() const { return _description; }
61 MEDLOADER_EXPORT void setDescription(const std::string& descr) { _description=descr; }
62 MEDLOADER_EXPORT MEDFileEquivalenceCell *initCell();
63 MEDLOADER_EXPORT MEDFileEquivalenceNode *initNode();
64 MEDLOADER_EXPORT MEDFileEquivalenceCell *getCell() { return _cell; }
65 MEDLOADER_EXPORT MEDFileEquivalenceNode *getNode() { return _node; }
66 MEDLOADER_EXPORT void setArray(int meshDimRelToMaxExt, DataArrayInt *da);
68 MEDFileEquivalencePair(MEDFileEquivalences *father, const std::string& name, const std::string& desc):_father(father),_name(name),_description(desc) { }
69 void load(med_idt fid);
71 MEDFileEquivalences *_father;
73 std::string _description;
74 MCAuto<MEDFileEquivalenceCell> _cell;
75 MCAuto<MEDFileEquivalenceNode> _node;
78 class MEDFileEquivalences : public RefCountObject, public MEDFileWritableStandAlone
81 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
82 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
83 MEDLOADER_EXPORT const MEDFileMesh *getMesh() const { return _owner; }
84 MEDLOADER_EXPORT MEDFileMesh *getMesh() { return _owner; }
85 void getDtIt(int &dt, int &it) const;
86 std::string getMeshName() const;
87 void pushEquivalence(MEDFileEquivalencePair *elt);
88 static MEDFileEquivalences *New(MEDFileMesh *owner) { return new MEDFileEquivalences(owner); }
89 MEDFileEquivalences *deepCopy(MEDFileMesh *owner) const;
90 bool isEqual(const MEDFileEquivalences *other, std::string& what) const;
91 void getRepr(std::ostream& oss) const;
93 MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileEquivalences"); }
94 MEDLOADER_EXPORT MEDFileEquivalencePair *getEquivalence(int i);
95 MEDLOADER_EXPORT MEDFileEquivalencePair *getEquivalenceWithName(const std::string& name);
96 MEDLOADER_EXPORT int size() const;
97 MEDLOADER_EXPORT std::vector<std::string> getEquivalenceNames() const;
98 MEDLOADER_EXPORT MEDFileEquivalencePair *appendEmptyEquivalenceWithName(const std::string& name);
99 MEDLOADER_EXPORT void killEquivalenceWithName(const std::string& name);
100 MEDLOADER_EXPORT void killEquivalenceAt(int i);
101 MEDLOADER_EXPORT void clear();
103 MEDLOADER_EXPORT void writeLL(med_idt fid) const;
104 static int PresenceOfEquivalences(med_idt fid, const std::string& meshName);
105 static MEDFileEquivalences *Load(med_idt fid, int nbOfEq, MEDFileMesh *owner);
106 static void CheckDataArray(const DataArrayInt *data);
108 MEDFileEquivalences(MEDFileMesh *owner):_owner(owner) { }
109 void deepCpyFrom(const MEDFileEquivalences& other);
112 std::vector< MCAuto<MEDFileEquivalencePair> > _equ;
115 class MEDFileEquivalenceBase : public RefCountObject, public MEDFileWritableStandAlone
118 MEDFileEquivalenceBase(MEDFileEquivalencePair *father);
119 const MEDFileEquivalencePair *getFather() const { return _father; }
120 MEDFileEquivalencePair *getFather() { return _father; }
121 const MEDFileMesh *getMesh() const { return getFather()->getMesh(); }
122 MEDFileMesh *getMesh() { return getFather()->getMesh(); }
124 ~MEDFileEquivalenceBase() { }
126 MEDFileEquivalencePair *_father;
129 class MEDFileEquivalenceData : public MEDFileEquivalenceBase
132 MEDFileEquivalenceData(MEDFileEquivalencePair *owner, DataArrayInt *data);
133 MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileEquivalenceData"); }
134 MEDLOADER_EXPORT void setArray(DataArrayInt *data);
135 MEDLOADER_EXPORT const DataArrayInt *getArray() const { return _data; }
136 MEDLOADER_EXPORT DataArrayInt *getArray() { return _data; }
137 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
138 bool isEqual(const MEDFileEquivalenceData *other, std::string& what) const;
140 void writeAdvanced(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const;
142 ~MEDFileEquivalenceData() { }
144 MCAuto<DataArrayInt> _data;
147 class MEDFileEquivalenceCellType : public MEDFileEquivalenceData
150 MEDFileEquivalenceCellType(MEDFileEquivalencePair *owner, INTERP_KERNEL::NormalizedCellType type, DataArrayInt *data):MEDFileEquivalenceData(owner,data),_type(type) { }
151 MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileEquivalenceCellType"); }
152 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
153 INTERP_KERNEL::NormalizedCellType getType() const { return _type; }
154 MEDFileEquivalenceCellType *deepCopy(MEDFileEquivalencePair *owner) const;
155 bool isEqual(const MEDFileEquivalenceCellType *other, std::string& what) const;
156 void getRepr(std::ostream& oss) const;
158 void writeLL(med_idt fid) const;
160 ~MEDFileEquivalenceCellType() { }
162 INTERP_KERNEL::NormalizedCellType _type;
165 class MEDFileEquivalenceCell : public MEDFileEquivalenceBase
168 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
169 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
170 MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileEquivalenceCell"); }
171 static MEDFileEquivalenceCell *Load(med_idt fid, MEDFileEquivalencePair *owner);
172 void writeLL(med_idt fid) const;
173 MEDFileEquivalenceCell *deepCopy(MEDFileEquivalencePair *owner) const;
174 bool isEqual(const MEDFileEquivalenceCell *other, std::string& what) const;
175 void getRepr(std::ostream& oss) const;
177 MEDLOADER_EXPORT void clear() { _types.clear(); }
178 MEDLOADER_EXPORT std::size_t size() const { return _types.size(); }
179 MEDLOADER_EXPORT DataArrayInt *getArray(INTERP_KERNEL::NormalizedCellType type);
180 MEDLOADER_EXPORT void setArray(int meshDimRelToMax, DataArrayInt *da);
181 MEDLOADER_EXPORT void setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da);
182 MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getTypes() const;
184 MEDFileEquivalenceCell(MEDFileEquivalencePair *owner):MEDFileEquivalenceBase(owner) { }
186 ~MEDFileEquivalenceCell() { }
188 void load(med_idt fid);
189 std::string getName() const { return getFather()->getName(); }
191 std::vector< MCAuto<MEDFileEquivalenceCellType> > _types;
194 class MEDFileEquivalenceNode : public MEDFileEquivalenceData
197 MEDFileEquivalenceNode(MEDFileEquivalencePair *owner, DataArrayInt *data):MEDFileEquivalenceData(owner,data) { }
198 MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileEquivalenceNode"); }
199 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
200 void writeLL(med_idt fid) const;
201 MEDFileEquivalenceNode *deepCopy(MEDFileEquivalencePair *owner) const;
202 bool isEqual(const MEDFileEquivalenceNode *other, std::string& what) const;
203 void getRepr(std::ostream& oss) const;
205 ~MEDFileEquivalenceNode() { }