1 // Copyright (C) 2007-2008 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
26 #include "MEDMEM_Support.hxx"
30 This class describe a family of elements on an entity.\n
31 It inherits from support. \n
32 It contains a list of elements (by SUPPORT class inheritance)
33 and a description of some attributs.\n
35 All families on one entity represent a mesh partition for this entity.
40 MEDMEM_EXPORT ostream & operator<<(ostream &os, FAMILY &my);
41 MEDMEM_EXPORT ostream & operator<<(ostream &os, const FAMILY &my) ;
43 class MEDMEM_EXPORT FAMILY : virtual public SUPPORT
48 Identifier of the family in the mesh
49 Note : There is precisely one for each family.
55 Number of attribute of the family .\n
56 Note that attributes are numbered from 1 to N.
59 int _numberOfAttribute ;
62 Array of all attributes' identifiers.
63 There is one for each attribute.
66 PointerOf<int> _attributeIdentifier ;
69 Array of all attributes' values.
70 There is one for each attribute.
73 PointerOf<int> _attributeValue ;
76 Array of all attributes' descriptions.
77 There is one for each attribute.
80 //PointerOf<string> _attributeDescription ;
81 vector<string> _attributeDescription ;
84 Number of the group the family belongs to.
90 Name of the group the family belongs to.
93 //PointerOf<string> _groupName ;
94 vector<string> _groupName ;
101 Constructor to use with med driver.
104 FAMILY( MESH* Mesh, int Identifier, string Name,
105 int NumberOfAttribute, int *AttributeIdentifier,
106 int *AttributeValue, string AttributeDescription,
107 int NumberOfGroup, string GroupName,
108 int * MEDArrayNodeFamily,
109 int ** MEDArrayCellFamily,
110 int ** MEDArrayFaceFamily,
111 int ** MEDArrayEdgeFamily
114 /*! Copy Constructor. */
115 FAMILY(const FAMILY & m);
117 /*! Constructor with SUPPORT entry. */
118 FAMILY(const SUPPORT & s);
122 FAMILY & operator=(const FAMILY &fam);
123 friend ostream & operator<<(ostream &os, FAMILY &my) ;
125 friend ostream & operator<<(ostream &os, const FAMILY &my) ;
127 bool build(MED_EN::medEntityMesh Entity,int **FamilyNumber);
129 // Il faudrait mettre en cohérence les méthodes set
130 // avec l'opérateur d'affection ! Rmq from EF !!!
132 inline void setIdentifier (int Identifier);
133 inline void setNumberOfAttributes (int NumberOfAttribute);
134 inline void setAttributesIdentifiers (int * AttributeIdentifier);
135 inline void setAttributesValues (int * AttributeValue);
136 inline void setAttributesDescriptions (string * AttributeDescription);
137 inline void setNumberOfGroups (int NumberOfGroups);
138 inline void setGroupsNames (string * GroupName, bool giveOwnership=false);
140 inline int getIdentifier() const;
141 inline int getNumberOfAttributes() const;
142 inline const int * getAttributesIdentifiers() const;
143 inline const int * getAttributesValues() const;
144 inline const string* getAttributesDescriptions() const;
145 inline int getNumberOfGroups() const;
146 inline const string* getGroupsNames() const;
148 // A FAIRE : VERIFIER LA VALIDITE DES PARAMETRES !
149 inline int getAttributeIdentifier(int i) const;
150 inline int getAttributeValue(int i) const;
151 inline string getAttributeDescription(int i) const;
152 inline string getGroupName(int i) const;
156 /*! Sets the attribute _identifier to Identifier. */
157 //----------------------------------------------
158 inline void FAMILY::setIdentifier(int Identifier)
159 //----------------------------------------------
161 _identifier = Identifier;
164 /*! Sets the attribute _numberOfAttribute to NumberOfAttribute. */
165 //--------------------------------------------------------------
166 inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute)
167 //--------------------------------------------------------------
169 _numberOfAttribute = NumberOfAttribute;
172 /*! Sets the attribute _attributeIdentifier to AttributeIdentifier. */
173 //---------------------------------------------------------------------
174 inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier)
175 //---------------------------------------------------------------------
177 //_attributeIdentifier = AttributeIdentifier ;
178 _attributeIdentifier.setShallowAndOwnership(AttributeIdentifier) ;
181 /*! Sets the attribute _attributeValue to AttributeValue. */
182 //-----------------------------------------------------------
183 inline void FAMILY::setAttributesValues(int * AttributeValue)
184 //-----------------------------------------------------------
186 //_attributeValue = AttributeValue ;
187 _attributeValue.setShallowAndOwnership(AttributeValue) ;
190 /*! Sets the attribute _attributeDescription to AttributeDescription. */
191 //--------------------------------------------------------------------------
192 inline void FAMILY::setAttributesDescriptions(string * AttributeDescription)
193 //--------------------------------------------------------------------------
195 //_attributeDescription = AttributeDescription ;
196 //_attributeDescription.setShallowAndOwnership(AttributeDescription) ;
197 int nbAttr = getNumberOfAttributes();
199 // std::string diagnosis;
200 // diagnosis="Can not set attributes descriptions - number of attributes is not set";
201 // throw MEDMEM::MEDEXCEPTION(diagnosis.c_str());
203 _attributeDescription.resize(nbAttr);
204 for(int i=0; i<nbAttr; i++) {
205 _attributeDescription[i] = AttributeDescription[i];
209 /*! Sets the attribute _numberOfGroup to NumberOfGroups. */
210 //-------------------------------------------------------
211 inline void FAMILY::setNumberOfGroups(int NumberOfGroups)
212 //-------------------------------------------------------
214 _numberOfGroup = NumberOfGroups ;
217 /*! Sets the attribute _groupName to GroupName. */
218 //----------------------------------------------------
219 inline void FAMILY::setGroupsNames(string * GroupName, bool giveOwnership)
220 //----------------------------------------------------
222 // SKL, CPP TESTS: _groupName is no more PointerOf(string) but vector<string>
223 // if (giveOwnership)
224 // _groupName.setShallowAndOwnership(GroupName);
226 // //_groupName = GroupName ;
227 // _groupName.set(_numberOfGroup, GroupName) ;
229 int nbGr = getNumberOfGroups();
231 // std::string diagnosis;
232 // diagnosis="Can not set groups names - number of groups is not set";
233 // throw MEDMEM::MEDEXCEPTION(diagnosis.c_str());
236 //_groupName.setShallowAndOwnership(GroupName);
237 _groupName.resize(nbGr);
238 for(int i=0; i<nbGr; i++) {
239 _groupName[i] = GroupName[i];
244 //_groupName = GroupName ;
245 //_groupName.set(_numberOfGroup, GroupName) ;
246 _groupName.resize(nbGr);
247 for(int i=0; i<nbGr; i++) {
248 _groupName[i] = GroupName[i];
252 /*! Returns the attribute _identifier.\n
253 Note that there is one identifier precisely for each family. */
254 //--------------------------------------
255 inline int FAMILY::getIdentifier() const
256 //--------------------------------------
261 /*! Returns the number of attributes of the family. */
262 //----------------------------------------------
263 inline int FAMILY::getNumberOfAttributes() const
264 //----------------------------------------------
266 return _numberOfAttribute ;
268 /*! Returns a pointer to attributes identifiers .
269 (There are _numberOfAttribute attributes) */
270 //---------------------------------------------------
271 inline const int * FAMILY::getAttributesIdentifiers() const
272 //---------------------------------------------------
274 return _attributeIdentifier ;
276 /*! Returns identifer of the Ith attribute of the family.\n
277 Note that they are numbered from 1 to N */
278 //----------------------------------------------------
279 inline int FAMILY::getAttributeIdentifier(int i) const
280 //----------------------------------------------------
282 return _attributeIdentifier[i-1] ;
284 /*! Returns a pointer to attributes values.
285 (There are _numberOfAttribute attributes)*/
286 //----------------------------------------------
287 inline const int * FAMILY::getAttributesValues() const
288 //----------------------------------------------
290 return _attributeValue ;
292 /*! Returns value of the Ith attribute of the family.\n
293 Note that they are numbered from 1 to N */
294 //-----------------------------------------------
295 inline int FAMILY::getAttributeValue(int i) const
296 //-----------------------------------------------
298 return _attributeValue[i-1] ;
300 //-------------------------------------------------------
301 inline const string * FAMILY::getAttributesDescriptions() const
302 //-------------------------------------------------------
304 return &(_attributeDescription[0]);
306 /*! Returns description of the Ith attribute of the family\n
307 Note that they are numbered from 1 to N */
308 //--------------------------------------------------------
309 inline string FAMILY::getAttributeDescription(int i) const
310 //--------------------------------------------------------
312 return _attributeDescription[i-1] ;
314 /*! Returns the number of groups the family belongs to.*/
315 //------------------------------------------
316 inline int FAMILY::getNumberOfGroups() const
317 //------------------------------------------
319 return _numberOfGroup;
321 /*! Returns a pointer to the names of the groups the family belongs to */
322 //--------------------------------------------
323 inline const string * FAMILY::getGroupsNames() const
324 //--------------------------------------------
326 return &(_groupName[0]);
328 /*! Returns the name of the Ith group the family belongs to.\n
329 Note that they are numbered from 1 to N*/
330 //---------------------------------------------
331 inline string FAMILY::getGroupName(int i) const
332 //---------------------------------------------
334 return _groupName[i-1] ;
337 }//End namespace MEDMEM
338 #endif /* FAMILY_HXX */