1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
5 * \file MULTIPR_Elements.hxx
7 * \brief Class Elements = table of elements in a mesh.
8 * All elements share the same type (e.g. MED_MAILLE) and the same geometric description (e.g. TETRA10).
9 * Each element has a family and a table of connectivity.
10 * Optional: each element has a name and an id.
12 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
17 #ifndef MULTIPR_ELEMENTS_HXX
18 #define MULTIPR_ELEMENTS_HXX
20 //*****************************************************************************
22 //*****************************************************************************
35 //*****************************************************************************
37 //*****************************************************************************
42 //*****************************************************************************
44 //*****************************************************************************
51 * Builds an empty set of elements (default constructor).
56 * Destructor. Removes everything.
61 * Resets this object in its state by default (empty). Cleans memory.
65 //---------------------------------------------------------------------
66 // Basic accessors/mutators
67 //---------------------------------------------------------------------
70 * Returns true iff this object contains no elements (table of elements is empty).
71 * \return true iff this object contains no elements.
73 bool isEmpty() const { return (mNum == 0); }
76 * Returns true iff elements have a name.
77 * \return true iff elements have a name.
79 bool isNames() const { return (mNames != NULL); }
82 * Returns true iff elements have an identifier (= a number).
83 * \return true iff elements have an identifier (= a number).
85 bool isIdentifiers() const { return (mId != NULL); }
88 * Returns the number of elements.
89 * \return the number of elements.
91 int getNumberOfElements() const { return mNum; }
94 * Returns the type of primitives (e.g. MED_TETRA10).
95 * \return the type of primitives
97 med_geometrie_element getTypeOfPrimitives() const { return mGeom; }
100 * Returns the number of nodes that composed an element.
101 * \return the number of nodes that composed an element.
103 int getNumberOfNodesByElement() const { return mNumNodesByElt; }
106 * Returns the family associated with an element.
107 * \param pIndex index of any element in [0..NUMBER_OF_ELEMENTS-1].
108 * \return the family associated with an element.
109 * \throw IndexOutOfBoundsException if pIndex is invalid.
111 med_int getFamilyIdentifier(med_int pIndex) const;
114 * Returns the connectivity of one element.
115 * \param pIndex must be in [0..NUMBER_OF_ELEMENTS-1].
116 * \return a pointer towards the table of connectivity of the element.
117 * \throw IndexOutOfBoundsException if pIndex is invalid.
119 const med_int* getConnectivity(int pIndex) const;
122 * Returns the coordinates of all the nodes of one element.
123 * \param pIndexElt must be in [0..NUMBER_OF_ELEMENTS-1].
124 * \param pNodes table of nodes, used to retrieve coordinates.
125 * \param pCoo (out) table of coordinates of nodes (e.g. 30 = 3 * 10 med_float for a TETRA10).
126 * \param pFirst only get the pFirst coordinates.
127 * \throw IndexOutOfBoundsException if pIndex is invalid.
129 void getCoordinates(med_int pIndexElt, const Nodes* pNodes, med_float* pCoo, int pFirst = 100) const;
131 //---------------------------------------------------------------------
133 //---------------------------------------------------------------------
136 * Constructor. Creates a subset of this set of elements from a set of indices.
137 * \param pSetIndices set of indices (start at 1).
138 * \return a restriction of this set of elements.
140 Elements* extractSubSet(const std::set<med_int>& pSetIndices) const;
143 * Returns the set of indices (starting at 1) of all nodes used by this set of elements.
144 * \return the set of indices of all nodes used by this set of elements.
146 const std::set<med_int>& getSetOfNodes();
149 * Returns the set of families referenced by this set of elements.
150 * Each family is described by its identifier.
151 * \return Returns the set of families referenced by this set of elements.
153 std::set<med_int> getSetOfFamilies() const;
156 * Remaps this set of elements such that indices of nodes are continous 1 2 3 4 5 ... *
157 * This method is intended to be used after extractSubSet().
161 //---------------------------------------------------------------------
163 //---------------------------------------------------------------------
166 * Reads a set of elements from a MED file.
167 * You must give: name of mesh, dimension of the mesh, type of entity and type of elements.
168 * \param pMEDfile any valid MED file opened for reading.
169 * \param pMeshName name of the mesh.
170 * \param pMeshDim dimension of the mesh.
171 * \param pEntity entity to be read (e.g. MED_MAILLE).
172 * \param pGeom type of primitves to be read (e.g. MED_TETRA10).
173 * \throw IOException if any i/o error occurs.
179 med_entite_maillage pEntity,
180 med_geometrie_element pGeom);
183 * Writes this set of elements to a MED file.
184 * WARNING: mesh must have been created and added to the MED file before.
185 * \param pMEDfile any valid MED file opened for writing.
186 * \param pMeshName name of the mesh.
187 * \param pMeshDim dimension of the mesh.
188 * \throw IOException if any i/o error occurs.
190 void writeMED(med_idt pMEDfile, char* pMeshName, med_int pMeshDim);
193 * Sets the flag which control the stream operator <<.
194 * \param pFlag new flag value.
196 void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
199 * Dumps any Elements to the given output stream.
200 * \param pOs any output stream.
201 * \param pE any Elements.
202 * \return the output stream pOs.
204 friend std::ostream& operator<<(std::ostream& pOs, Elements& pE);
209 * Builds the set of nodes used by this set of elements.
210 * If the set already exist, then it is cleared and a new set is computed.
212 void buildSetOfNodes();
216 med_int mNum; /**< Number of elements. */
217 med_entite_maillage mEntity; /**< Type of entity, e.g. MED_MAILLE. */
218 med_geometrie_element mGeom; /**< Type of primitive, e.g. MED_TETRA10. */
219 int mDim; /**< Dimension of elements = mGeom / 100. */
220 int mNumNodesByElt; /**< Number of nodes by element = mGeom % 100. */
221 med_int* mId; /**< Optional; for each element, its identifier; NULL if undefined. */
222 med_int* mFamIdent; /**< For each element, its family (identifier). */
223 char* mNames; /**< Optional; for each element, its name; NULL if undefined. */
224 med_int* mCon; /**< For each element, list of nodes (index in 1..*) = table of connectivity. */
225 std::set<med_int> mSetOfNodes; /**< Set of all nodes used by this set of elements. */
227 bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
231 // do not allow copy constructor
232 Elements(const Elements&);
235 Elements& operator=(const Elements&);
237 // do not allow operator ==
238 bool operator==(const Elements&);
243 } // namespace MULTIPR
246 #endif // MULTIPR_NODES_HXX