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