1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
27 #include "MEDMEM_Support.hxx"
31 This class describe a family of elements on an entity.\n
32 It inherits from support. \n
33 It contains a list of elements (by SUPPORT class inheritance)
34 and a description of some attributs.\n
36 All families on one entity represent a mesh partition for this entity.
41 MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, FAMILY &my);
42 MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, const FAMILY &my) ;
44 class MEDMEM_EXPORT FAMILY : virtual public SUPPORT
49 Identifier of the family in the mesh
50 Note : There is precisely one for each family.
56 Number of attribute of the family .\n
57 Note that attributes are numbered from 1 to N.
60 int _numberOfAttribute ;
63 Array of all attributes' identifiers.
64 There is one for each attribute.
67 PointerOf<int> _attributeIdentifier ;
70 Array of all attributes' values.
71 There is one for each attribute.
74 PointerOf<int> _attributeValue ;
77 Array of all attributes' descriptions.
78 There is one for each attribute.
81 //PointerOf<string> _attributeDescription ;
82 std::vector<std::string> _attributeDescription ;
85 Number of the group the family belongs to.
91 Name of the group the family belongs to.
94 //PointerOf<string> _groupName ;
95 std::vector<std::string> _groupName ;
104 Constructor to use with med driver.
107 FAMILY( GMESH* Mesh, int Identifier, string Name,
108 int NumberOfAttribute, int *AttributeIdentifier,
109 int *AttributeValue, string AttributeDescription,
110 int NumberOfGroup, string GroupName,
111 int * MEDArrayNodeFamily,
112 int ** MEDArrayCellFamily,
113 int ** MEDArrayFaceFamily,
114 int ** MEDArrayEdgeFamily
117 /*! Copy Constructor. */
118 FAMILY(const FAMILY & m);
120 /*! Constructor with SUPPORT entry. */
121 FAMILY(const SUPPORT & s);
124 FAMILY & operator=(const FAMILY &fam);
125 friend std::ostream & operator<<(std::ostream &os, FAMILY &my) ;
127 friend std::ostream & operator<<(std::ostream &os, const FAMILY &my) ;
129 bool build(MED_EN::medEntityMesh Entity,int **FamilyNumber);
131 // Il faudrait mettre en cohérence les méthodes set
132 // avec l'opérateur d'affection ! Rmq from EF !!!
134 inline void setIdentifier (int Identifier);
135 inline void setNumberOfAttributes (int NumberOfAttribute);
136 inline void setAttributesIdentifiers (int * AttributeIdentifier);
137 inline void setAttributesValues (int * AttributeValue);
138 inline void setAttributesDescriptions (std::string * AttributeDescription);
139 inline void setNumberOfGroups (int NumberOfGroups);
140 inline void setGroupsNames (std::string * GroupName, bool giveOwnership=false);
142 inline int getIdentifier() const;
143 inline int getNumberOfAttributes() const;
144 inline const int * getAttributesIdentifiers() const;
145 inline const int * getAttributesValues() const;
146 inline const std::string* getAttributesDescriptions() const;
147 inline int getNumberOfGroups() const;
148 inline const std::string* getGroupsNames() const;
150 // A FAIRE : VERIFIER LA VALIDITE DES PARAMETRES !
151 inline int getAttributeIdentifier(int i) const;
152 inline int getAttributeValue(int i) const;
153 inline std::string getAttributeDescription(int i) const;
154 inline std::string getGroupName(int i) const;
158 /*! Sets the attribute _identifier to Identifier. */
159 //----------------------------------------------
160 inline void FAMILY::setIdentifier(int Identifier)
161 //----------------------------------------------
163 _identifier = Identifier;
166 /*! Sets the attribute _numberOfAttribute to NumberOfAttribute. */
167 //--------------------------------------------------------------
168 inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute)
169 //--------------------------------------------------------------
171 _numberOfAttribute = NumberOfAttribute;
174 /*! Sets the attribute _attributeIdentifier to AttributeIdentifier. */
175 //---------------------------------------------------------------------
176 inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier)
177 //---------------------------------------------------------------------
179 //_attributeIdentifier = AttributeIdentifier ;
180 _attributeIdentifier.setShallowAndOwnership(AttributeIdentifier) ;
183 /*! Sets the attribute _attributeValue to AttributeValue. */
184 //-----------------------------------------------------------
185 inline void FAMILY::setAttributesValues(int * AttributeValue)
186 //-----------------------------------------------------------
188 //_attributeValue = AttributeValue ;
189 _attributeValue.setShallowAndOwnership(AttributeValue) ;
192 /*! Sets the attribute _attributeDescription to AttributeDescription. */
193 //--------------------------------------------------------------------------
194 inline void FAMILY::setAttributesDescriptions(std::string * AttributeDescription)
195 //--------------------------------------------------------------------------
197 //_attributeDescription = AttributeDescription ;
198 //_attributeDescription.setShallowAndOwnership(AttributeDescription) ;
199 int nbAttr = getNumberOfAttributes();
201 // std::string diagnosis;
202 // diagnosis="Can not set attributes descriptions - number of attributes is not set";
203 // throw MEDMEM::MEDEXCEPTION(diagnosis.c_str());
205 _attributeDescription.resize(nbAttr);
206 for(int i=0; i<nbAttr; i++) {
207 _attributeDescription[i] = AttributeDescription[i];
211 /*! Sets the attribute _numberOfGroup to NumberOfGroups. */
212 //-------------------------------------------------------
213 inline void FAMILY::setNumberOfGroups(int NumberOfGroups)
214 //-------------------------------------------------------
216 _numberOfGroup = NumberOfGroups ;
219 /*! Sets the attribute _groupName to GroupName. */
220 //----------------------------------------------------
221 inline void FAMILY::setGroupsNames(std::string * GroupName, bool giveOwnership)
222 //----------------------------------------------------
224 // SKL, CPP TESTS: _groupName is no more PointerOf(string) but vector<string>
225 // if (giveOwnership)
226 // _groupName.setShallowAndOwnership(GroupName);
228 // //_groupName = GroupName ;
229 // _groupName.set(_numberOfGroup, GroupName) ;
231 int nbGr = getNumberOfGroups();
233 // std::string diagnosis;
234 // diagnosis="Can not set groups names - number of groups is not set";
235 // throw MEDMEM::MEDEXCEPTION(diagnosis.c_str());
238 //_groupName.setShallowAndOwnership(GroupName);
239 _groupName.resize(nbGr);
240 for(int i=0; i<nbGr; i++) {
241 _groupName[i] = GroupName[i];
246 //_groupName = GroupName ;
247 //_groupName.set(_numberOfGroup, GroupName) ;
248 _groupName.resize(nbGr);
249 for(int i=0; i<nbGr; i++) {
250 _groupName[i] = GroupName[i];
254 /*! Returns the attribute _identifier.\n
255 Note that there is one identifier precisely for each family. */
256 //--------------------------------------
257 inline int FAMILY::getIdentifier() const
258 //--------------------------------------
263 /*! Returns the number of attributes of the family. */
264 //----------------------------------------------
265 inline int FAMILY::getNumberOfAttributes() const
266 //----------------------------------------------
268 return _numberOfAttribute ;
270 /*! Returns a pointer to attributes identifiers .
271 (There are _numberOfAttribute attributes) */
272 //---------------------------------------------------
273 inline const int * FAMILY::getAttributesIdentifiers() const
274 //---------------------------------------------------
276 return _attributeIdentifier ;
278 /*! Returns identifer of the Ith attribute of the family.\n
279 Note that they are numbered from 1 to N */
280 //----------------------------------------------------
281 inline int FAMILY::getAttributeIdentifier(int i) const
282 //----------------------------------------------------
284 return _attributeIdentifier[i-1] ;
286 /*! Returns a pointer to attributes values.
287 (There are _numberOfAttribute attributes)*/
288 //----------------------------------------------
289 inline const int * FAMILY::getAttributesValues() const
290 //----------------------------------------------
292 return _attributeValue ;
294 /*! Returns value of the Ith attribute of the family.\n
295 Note that they are numbered from 1 to N */
296 //-----------------------------------------------
297 inline int FAMILY::getAttributeValue(int i) const
298 //-----------------------------------------------
300 return _attributeValue[i-1] ;
302 //-------------------------------------------------------
303 inline const std::string * FAMILY::getAttributesDescriptions() const
304 //-------------------------------------------------------
306 return &(_attributeDescription[0]);
308 /*! Returns description of the Ith attribute of the family\n
309 Note that they are numbered from 1 to N */
310 //--------------------------------------------------------
311 inline std::string FAMILY::getAttributeDescription(int i) const
312 //--------------------------------------------------------
314 return _attributeDescription[i-1] ;
316 /*! Returns the number of groups the family belongs to.*/
317 //------------------------------------------
318 inline int FAMILY::getNumberOfGroups() const
319 //------------------------------------------
321 return _numberOfGroup;
323 /*! Returns a pointer to the names of the groups the family belongs to */
324 //--------------------------------------------
325 inline const std::string * FAMILY::getGroupsNames() const
326 //--------------------------------------------
328 return &(_groupName[0]);
330 /*! Returns the name of the Ith group the family belongs to.\n
331 Note that they are numbered from 1 to N*/
332 //---------------------------------------------
333 inline std::string FAMILY::getGroupName(int i) const
334 //---------------------------------------------
336 return _groupName[i-1] ;
339 }//End namespace MEDMEM
340 #endif /* FAMILY_HXX */