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