]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_Mesh.hxx
Salome HOME
NRI : Merge from V1_2.
[modules/med.git] / src / MEDMEM / MEDMEM_Mesh.hxx
1 //  MED MEDMEM : MED files in memory
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : MEDMEM_Mesh.hxx
25 //  Module : MED
26
27 #ifndef MESH_HXX
28 #define MESH_HXX
29
30 #include <string>
31 #include <vector>
32
33 #include "utilities.h"
34 #include "MEDMEM_STRING.hxx"
35 #include "MEDMEM_Exception.hxx"
36 #include "MEDMEM_define.hxx"
37
38 //#include "MEDMEM_Support.hxx"
39 #include "MEDMEM_Coordinate.hxx"
40 #include "MEDMEM_Connectivity.hxx"
41
42 // Add your own driver header (step 2)
43 #include "MEDMEM_MedMeshDriver.hxx"
44 #include "MEDMEM_MedMedDriver.hxx"
45 #include "MEDMEM_GibiMeshDriver.hxx"
46
47 class CELLMODEL;
48 class FAMILY;
49 class GROUP;
50 class SUPPORT;
51
52 template <class T> class FIELD;
53
54 //class GENDRIVER ;
55 //class MED_MESH_RDONLY_DRIVER ;
56 //class MED_MESH_WRONLY_DRIVER ;
57
58 using namespace MED_EN;
59
60 /*! This class contains all the informations related with a MESH :
61   - COORDINATES
62   - CONNECTIVITIES
63   - FAMILIES OF NODES
64   - FAMILIES OF CELLS
65   - FAMILIES OF FACES
66   - FAMILIES OF EDGES
67
68   NOTE: A Family is only on one type of entity (MED_CELL, MED_FACE, MED_EDGE, MED_NODE).
69   You can't have a family on MED_CELL and MED_FACE
70
71 */
72
73 class MESH
74 {
75
76
77 public :
78
79   // ------- Drivers Management Part
80 protected:
81
82   //-----------------------//
83   class INSTANCE
84   //-----------------------//
85   {
86   public:
87     virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0 ;
88   } ;
89
90   //-------------------------------------------------------//
91   template <class T> class INSTANCE_DE : public INSTANCE
92   //-------------------------------------------------------//
93   {
94   public :
95     GENDRIVER * run(const string & fileName, MESH * ptrMesh) const
96     { return new T(fileName,ptrMesh) ; }
97   } ;
98
99   // Add a similar line for your personnal driver (step 3)
100   static INSTANCE_DE<MED_MESH_RDWR_DRIVER>  inst_med ;
101   static INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> inst_gibi ;
102   //static INSTANCE_DE<VTK_DRIVER>   inst_vtk   ;
103   static const INSTANCE * const instances[] ;
104
105   // ------ End of Drivers Management Part
106
107
108   //-----------------------//
109   //   Attributes
110   //-----------------------//
111
112 protected :
113
114   string        _name; // A POSITIONNER EN FCT DES IOS ?
115
116   COORDINATE *   _coordinate;
117   CONNECTIVITY * _connectivity;
118
119   int           _spaceDimension;
120   int           _meshDimension ;
121   int           _numberOfNodes    ;
122
123   int             _numberOfNodesFamilies;  //INUTILE ? -> _familyNode.size()
124   vector<FAMILY*> _familyNode ;  // array of size _numberOfNodesFamilies;
125   int             _numberOfCellsFamilies;
126   vector<FAMILY*> _familyCell ;  // array of size _numberOfCellsFamilies;
127   int             _numberOfFacesFamilies;
128   vector<FAMILY*> _familyFace ;  // array of size _numberOfFacesFamilies;
129   int             _numberOfEdgesFamilies;
130   vector<FAMILY*> _familyEdge ;  // array of size _numberOfEdgesFamilies;
131
132   int            _numberOfNodesGroups; //INUTILE ?
133   vector<GROUP*> _groupNode;    // array of size _numberOfNodesGroups;
134   int            _numberOfCellsGroups; //INUTILE ?
135   vector<GROUP*> _groupCell;    // array of size _numberOfCellsGroups;
136   int            _numberOfFacesGroups; //INUTILE ?
137   vector<GROUP*> _groupFace;    // array of size _numberOfFacesGroups;
138   int            _numberOfEdgesGroups; //INUTILE ?
139   vector<GROUP*> _groupEdge;    // array of size _numberOfEdgesGroups;
140   // list of all Group
141
142   vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
143
144   bool           _isAGrid;      // am I a GRID or not
145
146   //-----------------------//
147   //   Methods
148   //-----------------------//
149
150   inline void checkGridFillCoords() const;
151   inline void checkGridFillConnectivity() const;
152   // if this->_isAGrid, assure that _coordinate and _connectivity are filled
153
154 public :
155
156   // Add your personnal driver line (step 2)
157   friend class MED_MESH_RDONLY_DRIVER;
158   friend class MED_MESH_WRONLY_DRIVER;
159
160   friend class MED_MED_RDONLY_DRIVER;
161   friend class MED_MED_WRONLY_DRIVER;
162   friend class MED_MED_RDWR_DRIVER;
163
164   friend class GIBI_MESH_RDONLY_DRIVER;
165   friend class GIBI_MESH_WRONLY_DRIVER;
166   friend class GIBI_MESH_RDWR_DRIVER;
167
168   void init();
169   MESH();
170   MESH(MESH &m);
171   MESH & operator=(const MESH &m);
172   MESH( driverTypes driverType, const string & fileName="",
173         const string & meshName="");
174   ~MESH();
175   friend ostream & operator<<(ostream &os, MESH &my) ;
176
177   int  addDriver(driverTypes driverType,
178                  const string & fileName  ="Default File Name.med",
179                  const string & driverName="Default Mesh Name");
180   int  addDriver(GENDRIVER & driver);
181   void rmDriver(int index=0);
182
183   void read(int index=0);
184   inline void read(const MED_MED_DRIVER & genDriver);
185   inline void write(int index=0, const string & driverName = "");
186   inline void write(const MED_MED_DRIVER & genDriver);
187
188   //  void calculateReverseConnectivity();
189   //  void createFaces();       //Faces creation => full constituent informations
190   //  void buildConstituent() ; // calculate descendent connectivity + face-cell connectivity
191
192
193   inline void         setName(string name);
194
195   inline string       getName() const;
196   inline int          getSpaceDimension() const ;
197   inline int          getMeshDimension() const ;
198   inline bool         getIsAGrid();
199
200   inline int          getNumberOfNodes() const ;
201   inline const COORDINATE * getCoordinateptr() const ;
202   inline string       getCoordinatesSystem() const ;
203   inline const double *     getCoordinates(medModeSwitch Mode) const ;
204   inline const double       getCoordinate(int Number,int Axis) const ;
205   inline const string *     getCoordinatesNames() const ;
206   inline const string *     getCoordinatesUnits() const ;
207   //  inline int *        getNodesNumbers();
208
209   inline int          getNumberOfTypes(medEntityMesh Entity) const ;
210   inline const medGeometryElement *  getTypes(medEntityMesh Entity) const ;
211   inline const CELLMODEL *  getCellsTypes(medEntityMesh Entity) const ;
212   inline const int *        getGlobalNumberingIndex(medEntityMesh Entity) const ;
213   inline int          getNumberOfElements(medEntityMesh Entity,medGeometryElement Type) const ;
214   inline bool         existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity) const ;
215   inline medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
216   inline void         calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity) ;
217   inline const int *        getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type) const ;
218   inline const int *        getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity) const ;
219   int                 getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) const ;
220   inline const int *        getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ;
221   inline const int *        getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ;
222
223   inline int          getNumberOfFamilies(medEntityMesh Entity) const ;
224   inline const vector<FAMILY*> getFamilies(medEntityMesh Entity) const ;
225   inline const FAMILY*      getFamily(medEntityMesh Entity,int i) const ;
226   inline int          getNumberOfGroups(medEntityMesh Entity) const ;
227   inline const vector<GROUP*> getGroups(medEntityMesh Entity) const ;
228   inline const GROUP*      getGroup(medEntityMesh Entity,int i) const ;
229   inline const CONNECTIVITY* getConnectivityptr() const ;
230   SUPPORT * getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) ;
231   //SUPPORT * getBoundaryElements(medEntityMesh Entity) const throw (MEDEXCEPTION) ; // problème avec le maillage dans le support : le pointeur n'est pas const, mais sa valeur oui. A voir !!! PG
232
233   SUPPORT * getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) ;
234
235   //  Node DonneBarycentre(const Cell &m) const;
236   FIELD<double>* getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 3D elements
237   FIELD<double>* getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements
238   FIELD<double>* getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 1D elements
239   FIELD<double>* getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements
240   FIELD<double>* getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) ;
241   //  FIELD<int>* getNeighbourhood(SUPPORT * Support) const throw (MEDEXCEPTION) ; // Il faut preciser !
242 };
243
244 // ---------------------------------------
245 //              Methodes Inline
246 // ---------------------------------------
247
248 inline const CONNECTIVITY* MESH::getConnectivityptr() const
249 {
250   return _connectivity;
251 }
252
253 // inline void MESH::read(int index/*=0*/)
254 // {
255 //   const char * LOC = "MESH::read(int index=0) : ";
256 //   BEGIN_OF(LOC);
257
258 //   if (_drivers[index]) {
259 //     _drivers[index]->open();
260 //     _drivers[index]->read();
261 //     _drivers[index]->close();
262 //   }
263 //   else
264 //     throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
265 //                                      << "The index given is invalid, index must be between  0 and |"
266 //                                      << _drivers.size()
267 //                                      )
268 //                           );
269 //   END_OF(LOC);
270 // }
271
272 /*! Write all the content of the MESH using driver referenced by the handler <index>*/
273 inline void MESH::write(int index/*=0*/, const string & driverName/* = ""*/)
274 {
275   const char * LOC = "MESH::write(int index=0, const string & driverName = \"\") : ";
276   BEGIN_OF(LOC);
277
278   if ( _drivers[index] ) {
279     _drivers[index]->open();
280     if (driverName != "") _drivers[index]->setMeshName(driverName);
281     _drivers[index]->write();
282     _drivers[index]->close();
283   }
284   else
285     throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
286                                      << "The index given is invalid, index must be between  0 and |"
287                                      << _drivers.size()
288                                      )
289                           );
290   END_OF(LOC);
291 }
292
293 // This method is MED specific : don't use it
294 // must be private.
295 inline void MESH::write(const MED_MED_DRIVER & genDriver)
296 {
297   const char * LOC = "MESH::write(const MED_MED_DRIVER & genDriver): ";
298   BEGIN_OF(LOC);
299
300   for (int index=0; index < _drivers.size(); index++ )
301     if ( *_drivers[index] == genDriver ) {
302       _drivers[index]->open();
303       _drivers[index]->write();
304       _drivers[index]->close();
305       // ? FINALEMENT PAS BESOIN DE L'EXCEPTION ?
306     }
307
308   END_OF(LOC);
309
310 }
311
312 // This method is MED specific : don't use it
313 // must be private.
314 inline void MESH::read(const MED_MED_DRIVER & genDriver)
315 {
316   const char * LOC = "MESH::read(const MED_MED_DRIVER & genDriver): ";
317   BEGIN_OF(LOC);
318
319   for (int index=0; index < _drivers.size(); index++ )
320     if ( *_drivers[index] == genDriver ) {
321       _drivers[index]->open();
322       _drivers[index]->read();
323       _drivers[index]->close();
324       // ? FINALEMENT PAS BESOIN DE L'EXCEPTION ?
325     }
326
327   END_OF(LOC);
328
329 }
330
331 /*! Set the MESH name */
332 inline void MESH::setName(string name)
333 {
334   _name=name ; //NOM interne à la classe
335 }
336
337 /*! Get the MESH name */
338 inline string MESH::getName() const
339 {
340   return _name ;
341 }
342
343 /*! Get the dimension of the space */
344 inline int MESH::getSpaceDimension() const
345 {
346   return _spaceDimension;
347 }
348
349 /*! Get the dimension of the MESH */
350 inline int MESH::getMeshDimension() const
351 {
352   return _meshDimension;
353 }
354
355 /*! Get the number of nodes used in the MESH */
356 inline int MESH::getNumberOfNodes() const
357 {
358   return _numberOfNodes;
359 }
360
361 /*! Get the COORDINATES object. Use it only if you need COORDINATES informations not provided by the MESH class.*/
362 inline const COORDINATE * MESH::getCoordinateptr() const
363 {
364   checkGridFillCoords();
365   return _coordinate;
366 }
367
368 /*! Get the system in which coordinates are given (CARTESIAN,CYLINDRICAL,SPHERICAL) __??MED_CART??__. */
369 inline string MESH::getCoordinatesSystem() const
370 {
371   return _coordinate->getCoordinatesSystem();
372 }
373
374 /*! Get the whole coordinates array in a given interlacing mode. The interlacing mode are :
375   - MED_NO_INTERLACE   :  X1 X2 Y1 Y2 Z1 Z2
376   - MED_FULL_INTERLACE :  X1 Y1 Z1 X2 Y2 Z2
377  */
378 inline const double * MESH::getCoordinates(medModeSwitch Mode) const
379 {
380   checkGridFillCoords();
381   return _coordinate->getCoordinates(Mode);
382 }
383
384 /*! Get the coordinate n° number on axis n°axis*/
385 inline const double MESH::getCoordinate(int number, int axis) const
386 {
387   checkGridFillCoords();
388   return _coordinate->getCoordinate(number,axis);
389 }
390
391 /*! Get the coordinate names array ("x       ","y       ","z       ")
392   of size n*MED_TAILLE_PNOM
393 */
394 inline const string * MESH::getCoordinatesNames() const
395 {
396   return _coordinate->getCoordinatesNames();
397 }
398
399 /*! Get the coordinate unit names array ("cm       ","cm       ","cm       ")
400   of size n*MED_TAILLE_PNOM
401 */
402 inline const string * MESH::getCoordinatesUnits() const
403 {
404   return _coordinate->getCoordinatesUnits();
405 }
406 //  int * MESH::getNodesNumbers() const
407 //  {
408 //    return nodesNumbers;
409 //  }
410
411 /*! Get the number of different geometric types for a given entity type.
412
413     For exemple getNumberOfTypes(MED_CELL) would return 3 is the MESH
414     have some MED_TETRA4, MED_PYRA5 and MED_HEXA6 in it.
415
416     medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES
417
418     If entity is not defined, return 0.
419
420     If there is no connectivity, return an exception.
421 */
422 inline int MESH::getNumberOfTypes(medEntityMesh entity) const
423 {
424   MESSAGE("MESH::getNumberOfTypes(medEntityMesh entity) : "<<entity);
425   if (entity == MED_NODE)
426     return 1 ;
427   checkGridFillConnectivity();
428   if (_connectivity != NULL)
429     return _connectivity->getNumberOfTypes(entity) ;
430   throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
431 }
432
433 /*!
434   Get the list of geometric types used by a given entity.
435   medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_ALL_ENTITIES
436
437   REM : Don't use MED_NODE
438
439   If entity is not defined, return an exception.
440 */
441 inline const medGeometryElement * MESH::getTypes(medEntityMesh entity) const
442 {
443   if (entity == MED_NODE)
444     throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !"));
445   // return un tableau de taille 1 contenant MED_NONE, comme les supports pour etre coherent avec getNumberOfTypes ???? PG
446
447   checkGridFillConnectivity();
448   if (_connectivity != NULL)
449     return _connectivity->getGeometricTypes(entity) ;
450   throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : Connectivity not defined !"));
451 }
452
453 /*!
454   Get the whole list of CELLMODEL used by cells of given type (medEntityMesh).
455
456   REMARK : Don't use MED_NODE as medEntityMesh
457 */
458 inline const CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity) const
459 {
460   checkGridFillConnectivity();
461   if (_connectivity != NULL)
462     return _connectivity->getCellsTypes(Entity) ;
463   throw MEDEXCEPTION(LOCALIZED("MESH::getCellsTypes( medEntityMesh ) : Connectivity not defined !"));
464 }
465
466 /*! Return an array of size NumbreOfTypes+1 which contains, for each
467     geometric type of the given entity, the first global element number
468     of this type.
469
470     For exemple, if we have a mesh with 5 triangles and 4 quadrangle :
471     - size of GlobalNumberingIndex is 3
472     - GlobalNumberingIndex[0]=1 (the first type)
473     - GlobalNumberingIndex[1]=6 (the second type)
474     - GlobalNumberingIndex[2]=10
475 */
476 inline const int * MESH::getGlobalNumberingIndex(medEntityMesh entity) const
477 {
478   checkGridFillConnectivity();
479   if (_connectivity != NULL)
480     return _connectivity->getGlobalNumberingIndex(entity);
481   throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
482 }
483 /*!
484   Return the number of element of given geometric type of given entity. Return 0 if query is not defined.
485
486   Example :
487   - getNumberOfElements(MED_NODE,MED_NONE) : number of node
488   - getNumberOfElements(MED_NODE,MED_TRIA3) : return 0 (not defined)
489   - getNumberOfElements(MED_FACE,MED_TRIA3) : return number of triangles
490   elements defined in face entity (0 if not defined)
491   - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : return total number
492   of elements defined in cell entity
493  */
494 inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type) const
495 {
496   const char * LOC = "MESH::getNumberOfElements(medEntityMesh,medGeometryElement) : " ;
497   if (entity==MED_NODE)
498     if ((Type==MED_NONE)|(Type==MED_ALL_ELEMENTS))
499       return _numberOfNodes ;
500     else
501       return 0 ;
502   //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE"));
503   else
504     {
505       checkGridFillConnectivity();
506       if (_connectivity != (CONNECTIVITY*)NULL)
507         return _connectivity->getNumberOf(entity,Type) ;
508       else
509         return 0 ;
510       //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"connectivity not defined !"));
511     }
512 }
513 /*!
514   Return true if the wanted connectivity exist, else return false
515   (to use before a getSomething method).
516  */
517 inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity) const
518 {
519   checkGridFillConnectivity();
520   if (_connectivity==(CONNECTIVITY*)NULL)
521     throw MEDEXCEPTION("MESH::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
522   return _connectivity->existConnectivity(connectivityType,entity) ;
523 }
524 /*!
525   Return the geometric type of global element Number of entity Entity.
526
527   Throw an exception if Entity is not defined or Number are wrong (too big).
528  */
529 inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number) const
530 {
531   checkGridFillConnectivity();
532   if (_connectivity==(CONNECTIVITY*)NULL)
533     throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !");
534   return _connectivity->getElementType(Entity,Number) ;
535 }
536 /*!
537   Calculate the ask connectivity. Return an exception if this could not be
538   done. Do nothing if connectivity already exist.
539  */
540
541 inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity)
542 {
543   checkGridFillConnectivity();
544   if (Mode==MED_FULL_INTERLACE)
545     _connectivity->calculateConnectivity(ConnectivityType,entity) ;
546   else
547     throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
548 }
549 /*!
550   Return the required connectivity in the right mode for the given
551   geometric type of the given entity.
552
553   To get connectivity for all geometric type, use Mode=MED_FULL_INTERLACE
554   and Type=MED_ALL_ELEMENTS.
555   You must also get the corresponding index array.
556  */
557 inline const int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) const
558 {
559   checkGridFillConnectivity();
560   if (Mode==MED_FULL_INTERLACE)
561     return _connectivity->getConnectivity(ConnectivityType,entity,Type) ;
562   throw MEDEXCEPTION(LOCALIZED("MESH::getConnectivity : only for MED_FULL_INTERLACE mode"));
563 }
564 /*!
565   Return the required index array for a connectivity received in
566   MED_FULL_ENTERLACE mode and MED_ALL_ELEMENTS type.
567
568   This array allow to find connectivity of each elements.
569
570   Example : Connectivity of i^{th} elements (1<=i<=NumberOfElement) begin
571   at index ConnectivityIndex[i-1] and end at index ConnectivityIndex[i]-1
572   in Connectivity array (Connectivity[ConnectivityIndex[i-1]-1] is the
573   first value)
574  */
575 inline const int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity) const
576 {
577   checkGridFillConnectivity();
578   return _connectivity->getConnectivityIndex(ConnectivityType, entity) ;
579 }
580 /*!
581   Return the reverse connectivity required by ConnectivityType :
582   - If ConnectivityType=MED_NODAL : return connectivity node-cell
583   - If ConnectivityType=MED_DESCENDING : return connectivity face-cell
584
585   You must get ReverseConnectivityIndex array to use it.
586  */
587 inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
588 {
589   checkGridFillConnectivity();
590   if (NULL==_connectivity)
591     throw MEDEXCEPTION("MESH::getReverseConnectivity : no connectivity defined in MESH !");
592
593   return _connectivity->getReverseConnectivity(ConnectivityType,Entity) ;
594 }
595 /*!
596   Return the index array required by ConnectivityType.
597
598   This array allow to find reverse connectivity of each elements.
599
600   Example : Reverse connectivity of i^{th} elements (1<=i<=NumberOfElement)
601   begin at index ReverseConnectivityIndex[i-1] and end at index
602   ReverseConnectivityIndex[i]-1
603   in ReverseConnectivity array (
604   ReverseConnectivity[ReverseConnectivityIndex[i-1]-1]
605   is the first value)
606  */
607 inline const int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
608 {
609   checkGridFillConnectivity();
610   if (NULL==_connectivity)
611     throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : no connectivity defined in MESH !");
612
613   return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity) ;
614 }
615
616
617 inline int MESH::getNumberOfFamilies (medEntityMesh entity) const
618 {
619   switch (entity) {
620   case MED_NODE :
621     return _numberOfNodesFamilies ;
622   case MED_CELL :
623     return _numberOfCellsFamilies ;
624   case MED_FACE :
625     return _numberOfFacesFamilies ;
626   case MED_EDGE :
627     return _numberOfEdgesFamilies ;
628   default :
629     throw MEDEXCEPTION("MESH::getNumberOfFamilies : Unknown entity");
630   }
631 }
632 inline int MESH::getNumberOfGroups (medEntityMesh entity) const
633 {
634   switch (entity) {
635   case MED_NODE :
636     return _numberOfNodesGroups ;
637   case MED_CELL :
638     return _numberOfCellsGroups ;
639   case MED_FACE :
640     return _numberOfFacesGroups ;
641   case MED_EDGE :
642     return _numberOfEdgesGroups ;
643   default :
644     throw MEDEXCEPTION("MESH::getNumberOfGroups : Unknown entity");
645   }
646 }
647 const vector<FAMILY*> MESH::getFamilies(medEntityMesh entity) const
648 {
649   switch (entity) {
650   case MED_NODE :
651     return _familyNode ;
652   case MED_CELL :
653     return _familyCell ;
654   case MED_FACE :
655     return _familyFace ;
656   case MED_EDGE :
657     return _familyEdge ;
658   default :
659     throw MEDEXCEPTION("MESH::getFamilies : Unknown entity");
660   }
661 }
662
663 const vector<GROUP*> MESH::getGroups(medEntityMesh entity) const
664 {
665   switch (entity) {
666   case MED_NODE :
667     return _groupNode ;
668   case MED_CELL :
669     return _groupCell ;
670   case MED_FACE :
671     return _groupFace ;
672   case MED_EDGE :
673     return _groupEdge ;
674   default :
675     throw MEDEXCEPTION("MESH::getGroups : Unknown entity");
676   }
677 }
678
679 const FAMILY* MESH::getFamily(medEntityMesh entity, int i) const
680 {
681   if (i<=0)
682     throw MEDEXCEPTION("MESH::getFamily(i) : argument i must be > 0");
683   int NumberOfFamilies = 0 ;
684   vector<FAMILY*> Family ;
685   switch (entity) {
686   case MED_NODE : {
687     NumberOfFamilies = _numberOfNodesFamilies ;
688     Family = _familyNode ;
689     break ;
690   }
691   case MED_CELL : {
692     NumberOfFamilies = _numberOfCellsFamilies ;
693     Family = _familyCell ;
694     break ;
695   }
696   case MED_FACE : {
697     NumberOfFamilies = _numberOfFacesFamilies ;
698     Family = _familyFace ;
699     break ;
700   }
701   case MED_EDGE : {
702     NumberOfFamilies = _numberOfEdgesFamilies ;
703     Family = _familyEdge ;
704     break ;
705   }
706   default :
707     throw MEDEXCEPTION("MESH::getFamilies : Unknown entity");
708   }
709   if (i>NumberOfFamilies)
710     throw MEDEXCEPTION("MESH::getFamily(entity,i) : argument i must be <= _numberOfFamilies");
711   return Family[i-1];
712 }
713
714 const GROUP* MESH::getGroup(medEntityMesh entity, int i) const
715 {
716   const char * LOC = "MESH::getGroup(medEntityMesh entity, int i) : " ;
717   if (i<=0)
718     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i must be > 0"));
719   int NumberOfGroups = 0 ;
720   vector<GROUP*> Group ;
721   switch (entity) {
722   case MED_NODE : {
723     NumberOfGroups = _numberOfNodesGroups ;
724     Group = _groupNode ;
725     break ;
726   }
727   case MED_CELL : {
728     NumberOfGroups = _numberOfCellsGroups ;
729     Group = _groupCell ;
730     break ;
731   }
732   case MED_FACE : {
733     NumberOfGroups = _numberOfFacesGroups ;
734     Group = _groupFace ;
735     break ;
736   }
737   case MED_EDGE : {
738     NumberOfGroups = _numberOfEdgesGroups ;
739     Group = _groupEdge ;
740     break ;
741   }
742   default :
743     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Unknown entity"));
744   }
745   if (i>NumberOfGroups)
746     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i="<<i<<" must be <= _numberOfGroups="<<NumberOfGroups));
747   return Group[i-1];
748 }
749
750
751 //    int * get_() {
752 //      return  ;
753 //    }
754
755 //inline void MESH::write(const string & driverName)  {
756 //  write(0,driverName);
757 //}
758
759 inline bool MESH::getIsAGrid()
760 {
761   return _isAGrid;
762 }
763
764 #endif /* MESH_HXX */