1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
5 * \file MULTIPR_Family.hxx
7 * \brief Class Family, Group and Attributs used to wrap MED file structures.
9 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
14 #ifndef MULTIPR_FAMILY_HXX
15 #define MULTIPR_FAMILY_HXX
17 //*****************************************************************************
19 //*****************************************************************************
36 //*****************************************************************************
38 //*****************************************************************************
43 //*****************************************************************************
45 //*****************************************************************************
52 * Builds an empty Attributs (default constructor).
57 * Destructor. Removes everything.
62 * Assignment operator (deep copy).
63 * \param pAttr any Atttibuts to be copied.
64 * \return a reference towards the copy.
66 Attributs& operator=(const Attributs& pAttr);
69 * Resets this object in its state by default (empty). Cleans memory.
73 //---------------------------------------------------------------------
75 //---------------------------------------------------------------------
78 * Dumps any Attributs to the given output stream.
79 * \param pOs any output stream.
80 * \param pA any Attributs.
81 * \return the output stream pOs.
83 friend std::ostream& operator<<(std::ostream& pOs, Attributs& pA);
87 med_int mNum; /**< Number of attributes. */
88 med_int* mId; /**< Table of identifiers: for each attribute, its identifier. */
89 med_int* mVal; /**< Table of values; for each attribute, its value. */
90 char* mDesc; /**< Table of description; for each attribute, its description. */
94 // do not allow copy constructor
95 Attributs(const Attributs&);
97 // do not allow operator ==
98 bool operator==(const Attributs&);
103 //*****************************************************************************
105 //*****************************************************************************
112 * Builds an empty Family (default constructor).
117 * Destructor. Removes everything.
122 * Resets this object in its state by default (empty). Cleans memory.
126 //---------------------------------------------------------------------
127 // Basic accessors/mutators
128 //---------------------------------------------------------------------
131 * Returns the identifier (= number) of this Family.
132 * \return the identifier of this Family.
134 med_int getId() const { return mId; }
137 * Returns the name of this Family.
138 * \return the name of this Family.
140 const char* getName() const { return mName; }
143 * Returns true if this Family if a family of nodes, false if is a family of elements (=cells)).
144 * \return true iff this Family if a family of nodes.
146 bool isFamilyOfNodes() const { return mIsFamilyOfNodes; }
149 * Sets whether this Family is a family of nodes or family of elements (= cells).
150 * \param pIsFamilyOfNodes flag.
152 void setIsFamilyOfNodes(bool pIsFamilyOfNodes) { mIsFamilyOfNodes = pIsFamilyOfNodes; }
155 * Inserts a new element (by its index) into this Family.
156 * \param pIndexElt index of the element to be added; must be >= 1.
157 * \throw IllegalArgumentException if pIndexElt <= 0.
159 void insertElt(med_int pIndexElt);
162 * Returns the number of elements in this Family.
163 * \return the number of elements in this Family.
165 int getSize() const { return mElt.size(); }
167 //---------------------------------------------------------------------
169 //---------------------------------------------------------------------
172 * Adds all the groups of this Family into the set of groups described by (pGroups, pGroupNameToGroup).
173 * \param pGroups current list of groups.
174 * \param pGroupNameToGroup table (map) to retrieve a Group* from its name.
177 std::vector<Group*>& pGroups,
178 std::map<std::string, Group*>& pGroupNameToGroup) const;
181 * Constructor. Returns a copy of this family restricted to the given group if pGroupName != NULL.
183 * 1. If current family have 3 groups "A", "B" and "C" and pGroupName="B", then the new family will only reference the group "B"
184 * 2. If current family have 3 groups "A", "B" and "C" and pGroupName="D", then the new family will reference groups "A", "B" and "C".
185 * WARNING: elements are not copied
186 * \param pGroupName name of the group to keep.
187 * \return a copy of this family.
189 Family* extractGroup(const char* pGroupName);
191 //---------------------------------------------------------------------
193 //---------------------------------------------------------------------
196 * Reads a Family from a MED file.
197 * \param pMEDfile any valid MED file opened for reading.
198 * \param pMeshName name of the mesh.
199 * \param pIndex index of the family to be read (must be >= 1).
200 * \throw IOException if any i/o error occurs.
202 void readMED(med_idt pMEDfile, char* pMeshName, med_int pIndex);
205 * Writes this Family to a MED file.
206 * WARNING: mesh must have been created and added to the MED file before.
207 * \param pMEDfile any valid MED file opened for writing.
208 * \param pPeshName name of the mesh.
209 * \throw IOException if any i/o error occurs.
211 void writeMED(med_idt pMEDfile, char* pMeshName);
214 * Sets the flag which control the stream operator <<.
215 * \param pFlag new flag value.
217 void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
220 * Dumps any Family to the given output stream.
221 * \param pOs any output stream.
222 * \param pF any Family.
223 * \return the output stream pOs.
225 friend std::ostream& operator<<(std::ostream& pOs, Family& pF);
229 char mName[MED_TAILLE_NOM + 1]; /** Name of the Family */
230 med_int mId; /**< Id: > 0 if family of nodes; < 0 if family of elements. */
231 std::set<med_int> mElt; /**< Set of all the elements (by their index in 1..*). */
232 std::string mStrNameGroups; /**< A string with name of all groups which contain the Family. */
233 std::vector<std::string> mNameGroups; /**< List of groups (by name) which contain the Family. */
234 Attributs mAttributs; /**< All the attributed related to the Family. */
235 bool mIsFamilyOfNodes; /**< Is it a family of nodes or a family of elements? */
237 bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
241 // do not allow copy constructor
242 Family(const Family&);
245 Family& operator=(const Family&);
247 // do not allow operator ==
248 bool operator==(const Family&);
253 //*****************************************************************************
255 //*****************************************************************************
262 * Builds an empty group (default constructor).
267 * Destructor. Removes everything.
272 * Resets this object in its state by default (empty). Cleans memory.
276 //---------------------------------------------------------------------
277 // Basic accessors/mutators
278 //---------------------------------------------------------------------
281 * Returns true if it is a group of nodes, false if it is a group of elements.
282 * \return true if it is a group of nodes, false if it is a group of elements.
284 bool isGroupOfNodes() const { return mIsGroupOfNodes; }
287 * Sets whether it is a group of nodes or a group of elements.
288 * \param pIsGroupOfNodes true for a group of nodes, false for a group of elements.
290 void setIsGroupOfNodes(bool pIsGroupOfNodes) { mIsGroupOfNodes = pIsGroupOfNodes; }
293 * Returns the name of this Group.
294 * \return the name of this Group.
296 const std::string& getName() const { return mName; }
299 * Sets the name of this Group.
300 * \param pName new name of this Group (length of name must not exceed MED_TAILLE_LNOM).
302 void setName(const std::string& pName);
305 * Adds the index of a new element to this Group.
306 * \param pIndexElt must be >= 1.
308 void insertElt(med_int pIndexElt);
311 * Returns the set of all the elements referenced in this Group.
312 * \return the set of all the elements referenced in this Group.
314 const std::set<med_int>& getSetOfElt() const { return mElt; }
317 * Returns the number of elements referenced in this Group.
318 * \return the number of elements referenced in this Group.
320 int getSize() const { return mElt.size(); }
322 //---------------------------------------------------------------------
324 //---------------------------------------------------------------------
327 * Sets the flag which control the stream operator <<.
328 * \param pFlag new flag value.
330 void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
333 * Dumps any Group to the given output stream.
334 * \param pOs any output stream.
335 * \param pG any Group.
336 * \return the output stream pOs.
338 friend std::ostream& operator<<(std::ostream& pOs, Group& pG);
342 std::string mName; /**< Name of the group. */
343 std::set<med_int> mElt; /**< All elements of this group; each element is referenced by its index >= 1; each element is unique. */
344 bool mIsGroupOfNodes; /**< Is it a group of nodes or a group of elements? */
346 bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
350 // do not allow copy constructor
354 Group& operator=(const Group&);
356 // do not allow operator ==
357 bool operator==(const Group&);
362 } // namespace MULTIPR
365 #endif // MULTIPR_FAMILY_HXX