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 (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.hxx"
34 class MEDFileEquivalenceCell;
35 class MEDFileEquivalenceNode;
36 class MEDFileEquivalences;
39 class MEDFileEquivalencePair : public RefCountObject
42 static MEDFileEquivalencePair *Load(MEDFileEquivalences *father, med_idt fid, const std::string& name, const std::string &desc);
43 void write(med_idt fid) const;
44 const MEDFileEquivalences *getFather() const { return _father; }
45 MEDFileEquivalences *getFather() { return _father; }
46 const MEDFileMesh *getMesh() const;
47 MEDFileMesh *getMesh();
48 MEDFileEquivalencePair *deepCopy(MEDFileEquivalences *father) const;
49 bool isEqual(const MEDFileEquivalencePair *other, std::string& what) const;
50 void getRepr(std::ostream& oss) const;
51 static MEDFileEquivalencePair *New(MEDFileEquivalences *father, const std::string& name);
52 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
53 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
55 MEDLOADER_EXPORT std::string getName() const { return _name; }
56 MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; }
57 MEDLOADER_EXPORT std::string getDescription() const { return _description; }
58 MEDLOADER_EXPORT void setDescription(const std::string& descr) { _description=descr; }
59 MEDLOADER_EXPORT MEDFileEquivalenceCell *initCell();
60 MEDLOADER_EXPORT MEDFileEquivalenceNode *initNode();
61 MEDLOADER_EXPORT MEDFileEquivalenceCell *getCell() { return _cell; }
62 MEDLOADER_EXPORT MEDFileEquivalenceNode *getNode() { return _node; }
63 MEDLOADER_EXPORT void setArray(int meshDimRelToMaxExt, DataArrayInt *da);
65 MEDFileEquivalencePair(MEDFileEquivalences *father, const std::string& name, const std::string& desc):_father(father),_name(name),_description(desc) { }
66 void load(med_idt fid);
68 MEDFileEquivalences *_father;
70 std::string _description;
71 MCAuto<MEDFileEquivalenceCell> _cell;
72 MCAuto<MEDFileEquivalenceNode> _node;
75 class MEDFileEquivalences : public RefCountObject
78 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
79 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
80 MEDLOADER_EXPORT const MEDFileMesh *getMesh() const { return _owner; }
81 MEDLOADER_EXPORT MEDFileMesh *getMesh() { return _owner; }
82 void getDtIt(int &dt, int &it) const;
83 std::string getMeshName() const;
84 void pushEquivalence(MEDFileEquivalencePair *elt);
85 static MEDFileEquivalences *New(MEDFileMesh *owner) { return new MEDFileEquivalences(owner); }
86 MEDFileEquivalences *deepCopy(MEDFileMesh *owner) const;
87 bool isEqual(const MEDFileEquivalences *other, std::string& what) const;
88 void getRepr(std::ostream& oss) const;
90 MEDLOADER_EXPORT MEDFileEquivalencePair *getEquivalence(int i);
91 MEDLOADER_EXPORT MEDFileEquivalencePair *getEquivalenceWithName(const std::string& name);
92 MEDLOADER_EXPORT int size() const;
93 MEDLOADER_EXPORT std::vector<std::string> getEquivalenceNames() const;
94 MEDLOADER_EXPORT MEDFileEquivalencePair *appendEmptyEquivalenceWithName(const std::string& name);
95 MEDLOADER_EXPORT void killEquivalenceWithName(const std::string& name);
96 MEDLOADER_EXPORT void killEquivalenceAt(int i);
97 MEDLOADER_EXPORT void clear();
99 void write(med_idt fid) const;
100 static int PresenceOfEquivalences(med_idt fid, const std::string& meshName);
101 static MEDFileEquivalences *Load(med_idt fid, int nbOfEq, MEDFileMesh *owner);
102 static void CheckDataArray(const DataArrayInt *data);
104 MEDFileEquivalences(MEDFileMesh *owner):_owner(owner) { }
105 void deepCpyFrom(const MEDFileEquivalences& other);
108 std::vector< MCAuto<MEDFileEquivalencePair> > _equ;
111 class MEDFileEquivalenceBase : public RefCountObject
114 MEDFileEquivalenceBase(MEDFileEquivalencePair *father);
115 const MEDFileEquivalencePair *getFather() const { return _father; }
116 MEDFileEquivalencePair *getFather() { return _father; }
117 const MEDFileMesh *getMesh() const { return getFather()->getMesh(); }
118 MEDFileMesh *getMesh() { return getFather()->getMesh(); }
120 ~MEDFileEquivalenceBase() { }
122 MEDFileEquivalencePair *_father;
125 class MEDFileEquivalenceData : public MEDFileEquivalenceBase
128 MEDFileEquivalenceData(MEDFileEquivalencePair *owner, DataArrayInt *data);
129 MEDLOADER_EXPORT void setArray(DataArrayInt *data);
130 MEDLOADER_EXPORT const DataArrayInt *getArray() const { return _data; }
131 MEDLOADER_EXPORT DataArrayInt *getArray() { return _data; }
132 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
133 bool isEqual(const MEDFileEquivalenceData *other, std::string& what) const;
135 void writeLL(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const;
137 ~MEDFileEquivalenceData() { }
139 MCAuto<DataArrayInt> _data;
142 class MEDFileEquivalenceCellType : public MEDFileEquivalenceData
145 MEDFileEquivalenceCellType(MEDFileEquivalencePair *owner, INTERP_KERNEL::NormalizedCellType type, DataArrayInt *data):MEDFileEquivalenceData(owner,data),_type(type) { }
146 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
147 INTERP_KERNEL::NormalizedCellType getType() const { return _type; }
148 MEDFileEquivalenceCellType *deepCopy(MEDFileEquivalencePair *owner) const;
149 bool isEqual(const MEDFileEquivalenceCellType *other, std::string& what) const;
150 void getRepr(std::ostream& oss) const;
152 void write(med_idt fid) const;
154 ~MEDFileEquivalenceCellType() { }
156 INTERP_KERNEL::NormalizedCellType _type;
159 class MEDFileEquivalenceCell : public MEDFileEquivalenceBase
162 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
163 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
164 static MEDFileEquivalenceCell *Load(med_idt fid, MEDFileEquivalencePair *owner);
165 void write(med_idt fid) const;
166 MEDFileEquivalenceCell *deepCopy(MEDFileEquivalencePair *owner) const;
167 bool isEqual(const MEDFileEquivalenceCell *other, std::string& what) const;
168 void getRepr(std::ostream& oss) const;
170 MEDLOADER_EXPORT void clear() { _types.clear(); }
171 MEDLOADER_EXPORT std::size_t size() const { return _types.size(); }
172 MEDLOADER_EXPORT DataArrayInt *getArray(INTERP_KERNEL::NormalizedCellType type);
173 MEDLOADER_EXPORT void setArray(int meshDimRelToMax, DataArrayInt *da);
174 MEDLOADER_EXPORT void setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da);
175 MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getTypes() const;
177 MEDFileEquivalenceCell(MEDFileEquivalencePair *owner):MEDFileEquivalenceBase(owner) { }
179 ~MEDFileEquivalenceCell() { }
181 void load(med_idt fid);
182 std::string getName() const { return getFather()->getName(); }
184 std::vector< MCAuto<MEDFileEquivalenceCellType> > _types;
187 class MEDFileEquivalenceNode : public MEDFileEquivalenceData
190 MEDFileEquivalenceNode(MEDFileEquivalencePair *owner, DataArrayInt *data):MEDFileEquivalenceData(owner,data) { }
191 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
192 void write(med_idt fid) const;
193 MEDFileEquivalenceNode *deepCopy(MEDFileEquivalencePair *owner) const;
194 bool isEqual(const MEDFileEquivalenceNode *other, std::string& what) const;
195 void getRepr(std::ostream& oss) const;
197 ~MEDFileEquivalenceNode() { }