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 __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 void writeLL(med_idt fid) const;
46 const MEDFileEquivalences *getFather() const { return _father; }
47 MEDFileEquivalences *getFather() { return _father; }
48 const MEDFileMesh *getMesh() const;
49 MEDFileMesh *getMesh();
50 MEDFileEquivalencePair *deepCopy(MEDFileEquivalences *father) const;
51 bool isEqual(const MEDFileEquivalencePair *other, std::string& what) const;
52 void getRepr(std::ostream& oss) const;
53 static MEDFileEquivalencePair *New(MEDFileEquivalences *father, const std::string& name);
54 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
55 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
57 MEDLOADER_EXPORT std::string getName() const { return _name; }
58 MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; }
59 MEDLOADER_EXPORT std::string getDescription() const { return _description; }
60 MEDLOADER_EXPORT void setDescription(const std::string& descr) { _description=descr; }
61 MEDLOADER_EXPORT MEDFileEquivalenceCell *initCell();
62 MEDLOADER_EXPORT MEDFileEquivalenceNode *initNode();
63 MEDLOADER_EXPORT MEDFileEquivalenceCell *getCell() { return _cell; }
64 MEDLOADER_EXPORT MEDFileEquivalenceNode *getNode() { return _node; }
65 MEDLOADER_EXPORT void setArray(int meshDimRelToMaxExt, DataArrayInt *da);
67 MEDFileEquivalencePair(MEDFileEquivalences *father, const std::string& name, const std::string& desc):_father(father),_name(name),_description(desc) { }
68 void load(med_idt fid);
70 MEDFileEquivalences *_father;
72 std::string _description;
73 MCAuto<MEDFileEquivalenceCell> _cell;
74 MCAuto<MEDFileEquivalenceNode> _node;
77 class MEDFileEquivalences : public RefCountObject, public MEDFileWritableStandAlone
80 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
81 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
82 MEDLOADER_EXPORT const MEDFileMesh *getMesh() const { return _owner; }
83 MEDLOADER_EXPORT MEDFileMesh *getMesh() { return _owner; }
84 void getDtIt(int &dt, int &it) const;
85 std::string getMeshName() const;
86 void pushEquivalence(MEDFileEquivalencePair *elt);
87 static MEDFileEquivalences *New(MEDFileMesh *owner) { return new MEDFileEquivalences(owner); }
88 MEDFileEquivalences *deepCopy(MEDFileMesh *owner) const;
89 bool isEqual(const MEDFileEquivalences *other, std::string& what) const;
90 void getRepr(std::ostream& oss) const;
92 MEDLOADER_EXPORT MEDFileEquivalencePair *getEquivalence(int i);
93 MEDLOADER_EXPORT MEDFileEquivalencePair *getEquivalenceWithName(const std::string& name);
94 MEDLOADER_EXPORT int size() const;
95 MEDLOADER_EXPORT std::vector<std::string> getEquivalenceNames() const;
96 MEDLOADER_EXPORT MEDFileEquivalencePair *appendEmptyEquivalenceWithName(const std::string& name);
97 MEDLOADER_EXPORT void killEquivalenceWithName(const std::string& name);
98 MEDLOADER_EXPORT void killEquivalenceAt(int i);
99 MEDLOADER_EXPORT void clear();
101 MEDLOADER_EXPORT void writeLL(med_idt fid) const;
102 static int PresenceOfEquivalences(med_idt fid, const std::string& meshName);
103 static MEDFileEquivalences *Load(med_idt fid, int nbOfEq, MEDFileMesh *owner);
104 static void CheckDataArray(const DataArrayInt *data);
106 MEDFileEquivalences(MEDFileMesh *owner):_owner(owner) { }
107 void deepCpyFrom(const MEDFileEquivalences& other);
110 std::vector< MCAuto<MEDFileEquivalencePair> > _equ;
113 class MEDFileEquivalenceBase : public RefCountObject, public MEDFileWritableStandAlone
116 MEDFileEquivalenceBase(MEDFileEquivalencePair *father);
117 const MEDFileEquivalencePair *getFather() const { return _father; }
118 MEDFileEquivalencePair *getFather() { return _father; }
119 const MEDFileMesh *getMesh() const { return getFather()->getMesh(); }
120 MEDFileMesh *getMesh() { return getFather()->getMesh(); }
122 ~MEDFileEquivalenceBase() { }
124 MEDFileEquivalencePair *_father;
127 class MEDFileEquivalenceData : public MEDFileEquivalenceBase
130 MEDFileEquivalenceData(MEDFileEquivalencePair *owner, DataArrayInt *data);
131 MEDLOADER_EXPORT void setArray(DataArrayInt *data);
132 MEDLOADER_EXPORT const DataArrayInt *getArray() const { return _data; }
133 MEDLOADER_EXPORT DataArrayInt *getArray() { return _data; }
134 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
135 bool isEqual(const MEDFileEquivalenceData *other, std::string& what) const;
137 void writeAdvanced(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const;
139 ~MEDFileEquivalenceData() { }
141 MCAuto<DataArrayInt> _data;
144 class MEDFileEquivalenceCellType : public MEDFileEquivalenceData
147 MEDFileEquivalenceCellType(MEDFileEquivalencePair *owner, INTERP_KERNEL::NormalizedCellType type, DataArrayInt *data):MEDFileEquivalenceData(owner,data),_type(type) { }
148 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
149 INTERP_KERNEL::NormalizedCellType getType() const { return _type; }
150 MEDFileEquivalenceCellType *deepCopy(MEDFileEquivalencePair *owner) const;
151 bool isEqual(const MEDFileEquivalenceCellType *other, std::string& what) const;
152 void getRepr(std::ostream& oss) const;
154 void writeLL(med_idt fid) const;
156 ~MEDFileEquivalenceCellType() { }
158 INTERP_KERNEL::NormalizedCellType _type;
161 class MEDFileEquivalenceCell : public MEDFileEquivalenceBase
164 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
165 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
166 static MEDFileEquivalenceCell *Load(med_idt fid, MEDFileEquivalencePair *owner);
167 void writeLL(med_idt fid) const;
168 MEDFileEquivalenceCell *deepCopy(MEDFileEquivalencePair *owner) const;
169 bool isEqual(const MEDFileEquivalenceCell *other, std::string& what) const;
170 void getRepr(std::ostream& oss) const;
172 MEDLOADER_EXPORT void clear() { _types.clear(); }
173 MEDLOADER_EXPORT std::size_t size() const { return _types.size(); }
174 MEDLOADER_EXPORT DataArrayInt *getArray(INTERP_KERNEL::NormalizedCellType type);
175 MEDLOADER_EXPORT void setArray(int meshDimRelToMax, DataArrayInt *da);
176 MEDLOADER_EXPORT void setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da);
177 MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getTypes() const;
179 MEDFileEquivalenceCell(MEDFileEquivalencePair *owner):MEDFileEquivalenceBase(owner) { }
181 ~MEDFileEquivalenceCell() { }
183 void load(med_idt fid);
184 std::string getName() const { return getFather()->getName(); }
186 std::vector< MCAuto<MEDFileEquivalenceCellType> > _types;
189 class MEDFileEquivalenceNode : public MEDFileEquivalenceData
192 MEDFileEquivalenceNode(MEDFileEquivalencePair *owner, DataArrayInt *data):MEDFileEquivalenceData(owner,data) { }
193 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
194 void writeLL(med_idt fid) const;
195 MEDFileEquivalenceNode *deepCopy(MEDFileEquivalencePair *owner) const;
196 bool isEqual(const MEDFileEquivalenceNode *other, std::string& what) const;
197 void getRepr(std::ostream& oss) const;
199 ~MEDFileEquivalenceNode() { }