]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_Family.hxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_Family.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef FAMILY_HXX
23 #define FAMILY_HXX
24
25 #include <string>
26 #include "MEDMEM_Support.hxx"
27
28 /*!
29
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
34
35   All families on one entity represent a mesh partition for this entity.
36
37 */
38 namespace MEDMEM {
39   class FAMILY;
40   MEDMEM_EXPORT ostream & operator<<(ostream &os, FAMILY &my);
41   MEDMEM_EXPORT ostream & operator<<(ostream &os, const FAMILY &my) ;
42
43 class MEDMEM_EXPORT FAMILY : virtual public SUPPORT
44 {
45 protected :
46   /*!
47     \if developper
48     Identifier of the family in the mesh
49     Note : There is precisely one for each family.
50     \endif
51   */
52   int      _identifier ;
53   /*!
54     \if developper
55     Number of attribute of the family .\n
56     Note that attributes are numbered from 1 to N.
57     \endif
58   */
59   int      _numberOfAttribute ;
60   /*!
61     \if developper
62     Array of all attributes' identifiers.
63     There is one for each attribute.
64     \endif
65   */ 
66   PointerOf<int>    _attributeIdentifier ;
67   /*!
68     \if developper
69     Array of all attributes' values.
70     There is one for each attribute.
71     \endif
72   */
73   PointerOf<int>    _attributeValue ;
74   /*!
75     \if developper
76     Array of all attributes' descriptions.
77     There is one for each attribute.
78     \endif
79   */
80   //PointerOf<string>  _attributeDescription ;
81   vector<string>  _attributeDescription ;
82   /*!
83     \if developper
84     Number of the group the family belongs to.
85     \endif
86   */
87   int      _numberOfGroup ;
88   /*!
89     \if developper
90     Name of the group the family belongs to.
91     \endif
92   */
93   //PointerOf<string> _groupName ;
94   vector<string> _groupName ;
95
96 public:
97                         /*! Constructor. */
98   FAMILY();
99   /*!
100     \if developper
101     Constructor to use with med driver.
102     \endif
103   */
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
112           ) ;
113
114                         /*! Copy Constructor. */
115   FAMILY(const FAMILY & m);
116
117                         /*! Constructor with SUPPORT entry. */
118   FAMILY(const SUPPORT & s);
119
120                         /*! Destructor. */
121   virtual ~FAMILY();
122   FAMILY & operator=(const FAMILY &fam);
123   friend ostream & operator<<(ostream &os, FAMILY &my) ;
124
125   friend ostream & operator<<(ostream &os, const FAMILY &my) ;
126
127   bool build(MED_EN::medEntityMesh Entity,int **FamilyNumber);
128
129   // Il faudrait mettre en cohérence les méthodes set
130   // avec l'opérateur d'affection ! Rmq from EF !!!
131
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);
139
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;
147
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;
153 };
154
155 // inline methods :
156 /*! Sets the attribute _identifier to Identifier. */
157 //----------------------------------------------
158 inline void FAMILY::setIdentifier(int Identifier)         
159 //----------------------------------------------
160
161     _identifier = Identifier; 
162 }
163
164 /*! Sets the attribute _numberOfAttribute to NumberOfAttribute. */
165 //--------------------------------------------------------------
166 inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute) 
167 //--------------------------------------------------------------
168
169     _numberOfAttribute = NumberOfAttribute; 
170 }
171
172 /*! Sets the attribute _attributeIdentifier to AttributeIdentifier. */
173 //---------------------------------------------------------------------
174 inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier) 
175 //---------------------------------------------------------------------
176
177     //_attributeIdentifier = AttributeIdentifier ; 
178     _attributeIdentifier.setShallowAndOwnership(AttributeIdentifier) ;
179 }
180
181 /*! Sets the attribute _attributeValue to AttributeValue. */
182 //-----------------------------------------------------------
183 inline void FAMILY::setAttributesValues(int * AttributeValue) 
184 //-----------------------------------------------------------
185
186     //_attributeValue = AttributeValue ; 
187     _attributeValue.setShallowAndOwnership(AttributeValue) ;
188 }
189
190 /*! Sets the attribute _attributeDescription to  AttributeDescription. */
191 //--------------------------------------------------------------------------
192 inline void FAMILY::setAttributesDescriptions(string * AttributeDescription) 
193 //--------------------------------------------------------------------------
194
195   //_attributeDescription = AttributeDescription ; 
196   //_attributeDescription.setShallowAndOwnership(AttributeDescription) ;
197   int nbAttr = getNumberOfAttributes();
198 //   if(nbAttr<1) {
199 //     std::string diagnosis;
200 //     diagnosis="Can not set attributes descriptions - number of attributes is not set";
201 //     throw MEDMEM::MEDEXCEPTION(diagnosis.c_str());
202 //   }
203   _attributeDescription.resize(nbAttr);
204   for(int i=0; i<nbAttr; i++) {
205     _attributeDescription[i] = AttributeDescription[i];
206   }
207 }
208
209 /*! Sets the attribute _numberOfGroup to NumberOfGroups. */
210 //-------------------------------------------------------
211 inline void FAMILY::setNumberOfGroups(int NumberOfGroups) 
212 //-------------------------------------------------------
213
214     _numberOfGroup = NumberOfGroups ; 
215 }
216
217 /*! Sets the attribute _groupName to GroupName. */
218 //----------------------------------------------------
219   inline void FAMILY::setGroupsNames(string * GroupName, bool giveOwnership) 
220 //----------------------------------------------------
221
222   // SKL, CPP TESTS: _groupName is no more PointerOf(string) but vector<string>
223 //   if (giveOwnership)
224 //     _groupName.setShallowAndOwnership(GroupName);
225 //   else  
226 //     //_groupName = GroupName ; 
227 //     _groupName.set(_numberOfGroup, GroupName) ;
228
229   int nbGr = getNumberOfGroups();
230 //   if(nbGr<1) {
231 //     std::string diagnosis;
232 //     diagnosis="Can not set groups names - number of groups is not set";
233 //     throw MEDMEM::MEDEXCEPTION(diagnosis.c_str());
234 //   }
235   if (giveOwnership) {
236     //_groupName.setShallowAndOwnership(GroupName);
237     _groupName.resize(nbGr);
238     for(int i=0; i<nbGr; i++) {
239       _groupName[i] = GroupName[i];
240     }
241     delete [] GroupName;
242   }
243   else {
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];
249     }
250   }
251 }
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 //--------------------------------------
257
258     return _identifier ; 
259 }
260
261 /*! Returns the number of attributes of the family. */
262 //----------------------------------------------
263 inline int FAMILY::getNumberOfAttributes() const
264 //----------------------------------------------
265
266     return _numberOfAttribute ; 
267 }
268 /*! Returns a pointer to attributes identifiers .
269     (There are _numberOfAttribute attributes) */
270 //---------------------------------------------------
271 inline const int * FAMILY::getAttributesIdentifiers() const
272 //---------------------------------------------------
273
274     return _attributeIdentifier ; 
275 }
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 //----------------------------------------------------
281
282     return _attributeIdentifier[i-1] ; 
283 }
284 /*! Returns a pointer to attributes values.
285     (There are _numberOfAttribute attributes)*/
286 //----------------------------------------------
287 inline const int * FAMILY::getAttributesValues() const
288 //----------------------------------------------
289
290     return _attributeValue ; 
291 }
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 //-----------------------------------------------
297
298     return _attributeValue[i-1] ; 
299 }
300 //-------------------------------------------------------
301 inline const string * FAMILY::getAttributesDescriptions() const
302 //-------------------------------------------------------
303
304     return &(_attributeDescription[0]);
305 }
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 //--------------------------------------------------------
311
312     return _attributeDescription[i-1] ; 
313 }
314 /*! Returns the number of groups the family belongs to.*/
315 //------------------------------------------
316 inline int FAMILY::getNumberOfGroups() const                   
317 //------------------------------------------
318
319     return _numberOfGroup; 
320 }
321 /*! Returns a pointer to the names of the groups the family belongs to */
322 //--------------------------------------------
323 inline const string * FAMILY::getGroupsNames() const
324 //--------------------------------------------
325
326   return &(_groupName[0]);
327 }
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 //---------------------------------------------
333
334     return _groupName[i-1] ; 
335 }
336
337 }//End namespace MEDMEM
338 #endif /* FAMILY_HXX */