Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/med.git] / src / MEDMEM / MEDMEM_Grid.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 // File      : MEDMEM_Grid.hxx
21 // Created   : Wed Dec 18 08:35:26 2002
22 // Descr     : class containing structured mesh data
23
24 // Author    : Edward AGAPOV (eap)
25 // Project   : SALOME Pro
26 // Module    : MED 
27 // $Header$
28
29 #ifndef MEDMEM_Grid_HeaderFile
30 #define MEDMEM_Grid_HeaderFile
31
32 #include <MEDMEM.hxx>
33
34 #include "MEDMEM_Mesh.hxx"
35
36 // class containing structured mesh data
37
38 namespace MEDMEM {
39 class MEDMEM_EXPORT GRID: public MESH
40 {
41  protected:
42   //-----------------------//
43   //   Fields
44   //-----------------------//
45   
46   // 1. grid type: MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED
47   MED_EN::med_grid_type     _gridType;
48   
49   // 2. node coordinates
50   // For MED_BODY_FITTED MESH::_coordinate is used
51   
52   // 2.1. i component array: X for MED_CARTESIAN, R for MED_POLAR
53   int               _iArrayLength;
54   double*           _iArray;
55   // 2.2. j component array: Y for MED_CARTESIAN, Theta for MED_POLAR
56   int               _jArrayLength;
57   double*           _jArray;
58   // 2.3. k component array: Z for both MED_CARTESIAN and MED_POLAR
59   int               _kArrayLength;
60   double*           _kArray;
61
62   // 3. flags to know that _coordinates and _connectivity of MESH are filled
63   bool              _is_coordinates_filled;
64   bool              _is_connectivity_filled;
65
66   // 4. is _gridType a true value or just a default one
67   bool              _is_default_gridType;
68
69   //-----------------------//
70   //   Protected Methods
71   //-----------------------//
72
73   CONNECTIVITY * makeConnectivity (const MED_EN::medEntityMesh Entity, const MED_EN::medGeometryElement Geometry,
74                                    const int NbEntities, int NbNodes, int nbMeshNodes,
75                                    const int * NodeNumbers) const ;
76   // creates nodal connectivity
77
78   
79   // Suppose a READ Driver to do the following except filling _[ijk]Array's
80   // 1) fill MESH fields:
81   //    * _name
82   //    * _spaceDimension
83   //    * _meshDimension
84   //    * _numberOfNodesFamilies, _numberOfCellsFamilies, ect
85   //    * _familyNode, _familyCell, etc
86   //    * _numberOfNodesGroups, _numberOfCellsGroups, etc
87   //    * _groupNode, _groupCell, etc
88   //    * _
89   // 2) create MESH::_coordinate without setting _coordinate->_coordinate and set: 
90   //    * _coordinate->_coordinateSystem
91   //    * _coordinate->_coordinateName
92   //    * _coordinate->_coordinateUnit
93   
94
95  public:
96   //-----------------------//
97   //   Methods
98   //-----------------------//
99
100   GRID();
101   GRID(const MED_EN::med_grid_type type);
102   GRID(const GRID &m);
103   GRID( driverTypes driverType, const string & fileName="",const string & meshName="");
104   GRID(const std::vector<std::vector<double> >& xyz_array,const std::vector<std::string>& coord_name,
105        const std::vector<std::string>& coord_unit, const MED_EN::med_grid_type type=MED_EN::MED_CARTESIAN);
106   GRID & operator=(const GRID &m);
107   virtual ~GRID();
108   virtual void init();
109
110   void fillCoordinates() const ;
111   void fillConnectivity() const ;
112   // fill _coordinates and _connectivity of MESH if not yet done
113
114   inline void makeUnstructured();
115   // fill both coordinates and connectivity of MESH
116
117   void fillMeshAfterRead();
118   // fill some fields (_numberOfNodes, etc.) after reading
119
120   void writeUnstructured(int index=0, const string & driverName = "");
121   // write a Grid as an Unstructured mesh
122
123   void read(int index=0);
124
125   //   API Methods returning fields of MESH that are filled while reading.
126   //   So they need not to be redefined
127
128 //   string                getName() const;
129 //   int                   getSpaceDimension();
130 //   int                   getMeshDimension();
131 //   string                getCoordinatesSystem();
132 //   int                   getNumberOfNodes();
133 //   string *              getCoordinatesNames();
134 //   string *              getCoordinatesUnits();
135 //   int                   getNumberOfFamilies(medEntityMesh Entity);
136 //   vector<FAMILY*>       getFamilies(medEntityMesh Entity);
137 //   FAMILY*               getFamily(medEntityMesh Entity,int i);
138 //   int                   getNumberOfGroups(medEntityMesh Entity);
139 //   vector<GROUP*>        getGroups(medEntityMesh Entity);
140 //   GROUP*                getGroup(medEntityMesh Entity,int i);
141
142
143 // Since a MESH itself knows if it is a GRID, it calls fillConnectivity()
144 // or fillCoordinates() whenever needed. So no redifinition of the following methods
145
146 //   const double *        getCoordinates(medModeSwitch Mode);
147 //   COORDINATE *          getCoordinateptr();
148 //   const double          getCoordinate(int Number,int Axis);
149 //   int                   getNumberOfTypes(medEntityMesh Entity);
150 //   medGeometryElement *  getTypes(medEntityMesh Entity);
151 //   CELLMODEL *           getCellsTypes(medEntityMesh Entity);
152 //   medGeometryElement    getElementType(medEntityMesh Entity,int Number) ;
153 //   int                   getNumberOfElements(medEntityMesh Entity,medGeometryElement Type);
154 //   int                   getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) ;
155 //   int *                 getGlobalNumberingIndex(medEntityMesh Entity);
156 //   int *                 getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type);
157 //   int *                 getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity);
158 //   int *                 getReverseConnectivity(medConnectivity ConnectivityType);
159 //   int *                 getReverseConnectivityIndex(medConnectivity ConnectivityType);
160 //   bool                  existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity);
161 //   void                  calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity);
162 //   FIELD<double>*        getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) ;
163 //   FIELD<double>*        getArea(const SUPPORT * Support) throw (MEDEXCEPTION) ;
164 //   FIELD<double>*        getLength(const SUPPORT * Support) throw (MEDEXCEPTION) ;
165 //   FIELD<double>*        getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) ;
166 //   FIELD<double>*        getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) ;
167
168
169   // Specific GRID methods
170
171   inline int getNodeNumber(const int i, const int j=0, const int k=0) const;
172   // return a NODE number by its position in the grid.
173   // WARNING: be carefull, there is no check that i,j,k are within a good range
174   // A good range is: 0 <= X < getArrayLength( X_Axis )
175   inline int getCellNumber(const int i, const int j=0, const int k=0) const ;
176   // return a CELL number by its position in the grid.
177   // WARNING: be carefull, there is no check that i,j,k are within a good range
178   // A good range is: 0 <= X < (getArrayLength( X_Axis )-1)
179
180   int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION) ;
181   // return an EDGE number by its position in the grid.
182   // Axis [1,2,3] means one of directions: along i, j or k.
183   // It selects an edge of ones having same (i,j,k):
184   //  * an EDGE going along given Axis.
185   // Exception for Axis out of range or when there is no edges in the grid (1D)
186   // WARNING: be carefull, there is no check that i,j,k are within a good range
187   // A good range is:
188   // 0 <= X < (getArrayLength( X_Axis )-1)
189   // 0 <= X < getArrayLength( NOT_X_Axis )
190
191   int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION) ;
192   // return a FACE number by its position in the grid.
193   // Axis [1,2,3] means one of directions: along i, j or k.
194   // It selects a face of ones having same (i,j,k):
195   //  * a FACE which is normal to given Axis
196   // Exception for Axis out of range or when there is no faces in the grid (1,2D)
197   // WARNING: be carefull, there is no check that i,j,k are within a good range
198   // A good range is:
199   // 0 <= X < (getArrayLength( NOT_X_Axis )-1)
200   // 0 <= X < getArrayLength( X_Axis )
201   
202
203   void getNodePosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION) ;
204   void getCellPosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION) ;
205   void getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION) ;
206   void getFacePosition(const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION) ;
207   // return position (i,j,k) of an entity #Number
208   // Axis: [1,2,3], see get*Number for details
209   // Exception for Number out of range
210
211
212   //  Access to fields
213
214   inline MED_EN::med_grid_type getGridType() const;
215   // return MED_CARTESIAN, MED_POLAR or MED_BODY_FITTED
216
217   int getArrayLength( const int Axis ) const throw (MEDEXCEPTION);
218   // return array length. Axis = [1,2,3] meaning [i,j,k],
219   // exception if Axis out of [1-3] range
220
221   const double getArrayValue (const int Axis, const int i) const throw (MEDEXCEPTION) ;
222   // return i-th array component. Axis = [1,2,3] meaning [i,j,k],
223   // exception if Axis out of [1 - 3] range
224   // exception if i is out of range [0 - (getArrayLength(Axis)-1)];
225
226   inline const COORDINATE * getCoordinateptr() const;
227
228   inline const double * getCoordinates(MED_EN::medModeSwitch Mode) const;
229
230   inline const double getCoordinate(int Number,int Axis) const;
231
232   inline int getNumberOfTypes(MED_EN::medEntityMesh Entity) const;
233
234   inline int getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const;
235
236   inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const;
237
238   MED_EN::medGeometryElement * getTypesWithPoly(MED_EN::medEntityMesh Entity) const;
239
240   inline const CELLMODEL * getCellsTypes(MED_EN::medEntityMesh Entity) const;
241
242   const int * getGlobalNumberingIndex(MED_EN::medEntityMesh Entity) const;
243
244   inline int getNumberOfElements(MED_EN::medEntityMesh Entity,
245                                  MED_EN::medGeometryElement Type) const;
246
247   inline int getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity,
248                                          MED_EN::medGeometryElement Type) const;
249
250   inline bool existConnectivity(MED_EN::medConnectivity ConnectivityType,
251                                 MED_EN::medEntityMesh Entity) const;
252
253   inline bool existConnectivityWithPoly(MED_EN::medConnectivity ConnectivityType,
254                                         MED_EN::medEntityMesh Entity) const;
255
256   inline MED_EN::medGeometryElement getElementType(MED_EN::medEntityMesh Entity,
257                                            int Number) const;
258
259   inline MED_EN::medGeometryElement getElementTypeWithPoly(MED_EN::medEntityMesh Entity,
260                                                            int Number) const;
261
262   inline void calculateConnectivity(MED_EN::medModeSwitch Mode,
263                                     MED_EN::medConnectivity ConnectivityType,
264                                     MED_EN::medEntityMesh Entity) const ;
265
266   inline const CONNECTIVITY* getConnectivityptr() const;
267
268   inline const int * getConnectivity(MED_EN::medModeSwitch Mode,
269                                      MED_EN::medConnectivity ConnectivityType,
270                                      MED_EN::medEntityMesh Entity, 
271                                      MED_EN::medGeometryElement Type) const;
272
273   inline const int * getConnectivityIndex(MED_EN::medConnectivity ConnectivityType,
274                                           MED_EN::medEntityMesh Entity) const;
275
276   inline const int * getReverseConnectivity(MED_EN::medConnectivity ConnectivityType,
277                                             MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const;
278
279   inline const int * getReverseConnectivityIndex(MED_EN::medConnectivity ConnectivityType,
280                                                  MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const;
281
282   //  Setting fields
283
284   inline void setGridType(MED_EN::med_grid_type gridType);
285
286   friend class IMED_MESH_RDONLY_DRIVER;
287   friend class IMED_MESH_WRONLY_DRIVER;
288   friend class MED_MESH_RDONLY_DRIVER21;
289   friend class MED_MESH_WRONLY_DRIVER21;
290   friend class MED_MESH_RDONLY_DRIVER22;
291   friend class MED_MESH_WRONLY_DRIVER22;
292 };
293
294
295   //----------------------------------//
296   //   Inline Methods Implementation
297   //----------------------------------//
298
299 inline MED_EN::med_grid_type GRID::getGridType() const
300 {
301   return _gridType;
302 }
303 //=======================================================================
304 //function : getNodeNumber
305 //purpose  : 
306 //=======================================================================
307
308 inline int GRID::getNodeNumber(const int i, const int j, const int k) const
309 {
310   return 1 + i + _iArrayLength * j + _iArrayLength * _jArrayLength * k;
311 }
312
313 //=======================================================================
314 //function : getCellNumber
315 //purpose  : 
316 //=======================================================================
317
318 inline int GRID::getCellNumber(const int i, const int j, const int k) const
319 {
320   return 1 + i + (_iArrayLength-1) * j + (_iArrayLength-1) * (_jArrayLength-1) * k;
321 }
322
323 //=======================================================================
324 //function : makeUnstructured
325 //purpose : fill coordinates and connectivity of MESH
326 //=======================================================================
327
328 inline void GRID::makeUnstructured()
329 {
330   fillCoordinates();
331   fillConnectivity();
332 }
333
334 //=======================================================================
335 //function : setGridType
336 //purpose : set the _gridType field od the class GRID
337 //=======================================================================
338
339 inline void GRID::setGridType(MED_EN::med_grid_type gridType)
340 {
341   _gridType = gridType;
342 }
343
344 /*! Get the COORDINATES object. Use it only if you need COORDINATES informations not provided by the GRID class via the MESH class.*/
345 inline const COORDINATE * GRID::getCoordinateptr() const
346 {
347   fillCoordinates();
348   return _coordinate;
349 }
350
351 /*! Get the whole coordinates array in a given interlacing mode. The interlacing mode are :
352   - MED_NO_INTERLACE   :  X1 X2 Y1 Y2 Z1 Z2
353   - MED_FULL_INTERLACE :  X1 Y1 Z1 X2 Y2 Z2
354  */
355 inline const double * GRID::getCoordinates(MED_EN::medModeSwitch Mode) const
356 {
357   fillCoordinates();
358   return _coordinate->getCoordinates(Mode);
359 }
360
361 /*! Get the coordinate n° number on axis n°axis*/
362 inline const double GRID::getCoordinate(int number, int axis) const
363 {
364   fillCoordinates();
365   return _coordinate->getCoordinate(number,axis);
366 }
367
368 /*! Get the number of different geometric types for a given entity type.
369
370     medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE,
371     MED_ALL_ENTITIES
372
373 */
374 inline int GRID::getNumberOfTypes(MED_EN::medEntityMesh entity) const
375 {
376   MESSAGE("GRID::getNumberOfTypes(medEntityMesh entity) : "<<entity);
377     return 1; // a grid has one type
378 }
379
380
381 inline int GRID::getNumberOfTypesWithPoly(MED_EN::medEntityMesh entity) const
382 {
383   MESSAGE("GRID::getNumberOfTypes(medEntityMesh entity) : "<<entity);
384     return 1; // a grid has one type
385 }
386
387 /*!
388   Get the whole list of CELLMODEL used by cells of given type (medEntityMesh).
389
390   REMARK : Don't use MED_NODE as medEntityMesh
391 */
392 inline const CELLMODEL * GRID::getCellsTypes(MED_EN::medEntityMesh Entity) const
393 {
394   fillConnectivity();
395
396   if (_connectivity != NULL)
397     return _connectivity->getCellsTypes(Entity);
398   throw MEDEXCEPTION(LOCALIZED("GRID::getCellsTypes( medEntityMesh ) : Connectivity not defined !"));
399 }
400
401 /*! Return an array of size NumbreOfTypes+1 which contains, for each
402     geometric type of the given entity, the first global element number
403     of this type.
404
405     For exemple, if we have a mesh with 5 triangles and 4 quadrangle :
406     - size of GlobalNumberingIndex is 3
407     - GlobalNumberingIndex[0]=1 (the first type)
408     - GlobalNumberingIndex[1]=6 (the second type)
409     - GlobalNumberingIndex[2]=10
410 */
411 inline const int * GRID::getGlobalNumberingIndex(MED_EN::medEntityMesh entity) const
412 {
413   fillConnectivity();
414
415   if (_connectivity != NULL)
416     return _connectivity->getGlobalNumberingIndex(entity);
417   throw MEDEXCEPTION(LOCALIZED("GRID::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
418 }
419
420 /*!
421   Return the number of element of given geometric type of given entity. Return 0 if query is not defined.
422 */
423 inline int GRID::getNumberOfElements(MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const
424 {
425   int numberOfElements=0;
426     
427     // Cas où le nombre d'éléments n'est pas nul
428     if (entity==MED_EN::MED_FACE && (Type==MED_EN::MED_QUAD4 || Type==MED_EN::MED_ALL_ELEMENTS) && _spaceDimension>2)
429       if ( _meshDimension == 2 )
430         numberOfElements=(_iArrayLength-1)*(_jArrayLength-1);
431       else
432         numberOfElements=
433           (_iArrayLength-1)*(_jArrayLength-1)*_kArrayLength +
434           (_jArrayLength-1)*(_kArrayLength-1)*_iArrayLength +
435           (_iArrayLength-1)*(_kArrayLength-1)*_jArrayLength;
436
437     else if (entity==MED_EN::MED_EDGE && (Type==MED_EN::MED_SEG2 || Type==MED_EN::MED_ALL_ELEMENTS) && _spaceDimension>1)
438       if ( _meshDimension == 1 )
439         numberOfElements=_iArrayLength-1;
440       else if ( _meshDimension == 2 )
441         numberOfElements=
442           (_iArrayLength-1)*_jArrayLength + (_jArrayLength-1)*_iArrayLength;
443       else
444         numberOfElements=
445           (_iArrayLength-1)*_jArrayLength*_kArrayLength +
446           (_jArrayLength-1)*_kArrayLength*_iArrayLength +
447           (_kArrayLength-1)*_iArrayLength*_jArrayLength;
448
449     else if (entity==MED_EN::MED_NODE && (Type==MED_EN::MED_NONE || Type==MED_EN::MED_ALL_ELEMENTS) && _spaceDimension>0)
450         numberOfElements=_numberOfNodes;
451     
452     else if (entity==MED_EN::MED_CELL && _spaceDimension==3 && (Type==MED_EN::MED_HEXA8 || Type==MED_EN::MED_ALL_ELEMENTS) )
453         numberOfElements=(_iArrayLength-1)*(_jArrayLength-1)*(_kArrayLength-1);
454     
455     else if (entity==MED_EN::MED_CELL && _spaceDimension==2 && (Type==MED_EN::MED_QUAD4 || Type==MED_EN::MED_ALL_ELEMENTS))
456         numberOfElements=(_iArrayLength-1)*(_jArrayLength-1);
457     
458     else if (entity==MED_EN::MED_CELL && _spaceDimension==1 && (Type==MED_EN::MED_SEG2 || Type==MED_EN::MED_ALL_ELEMENTS) )
459         numberOfElements=_iArrayLength-1;
460
461     MESSAGE("GRID::getNumberOfElements - entity=" << entity << " Type=" << Type);
462     MESSAGE("_spaceDimension=" << _spaceDimension << "  numberOfElements=" << numberOfElements);
463
464     return numberOfElements;
465 }
466
467 int GRID::getNumberOfElementsWithPoly(MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const
468 {
469   return getNumberOfElements(entity,Type);
470 }
471
472
473 /*!
474   Return true if the wanted connectivity exist, else return false
475   (to use before a getSomething method).
476  */
477 inline bool GRID::existConnectivity(MED_EN::medConnectivity connectivityType, MED_EN::medEntityMesh entity) const
478 {
479   fillConnectivity();
480
481   if (_connectivity==(CONNECTIVITY*)NULL)
482     throw MEDEXCEPTION("GRID::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
483   return _connectivity->existConnectivity(connectivityType,entity);
484 }
485
486 /*!
487   Same as the previous
488  */
489 inline bool GRID::existConnectivityWithPoly(MED_EN::medConnectivity ConnectivityType,
490                                             MED_EN::medEntityMesh Entity) const
491 {
492   return existConnectivity(ConnectivityType,Entity);
493 }
494
495 /*!
496   Return the geometric type of global element Number of entity Entity.
497
498   Throw an exception if Entity is not defined or Number are wrong (too big).
499  */
500 inline MED_EN::medGeometryElement GRID::getElementType(MED_EN::medEntityMesh Entity,int Number) const
501 {
502   fillConnectivity();
503
504   if (_connectivity==(CONNECTIVITY*)NULL)
505     throw MEDEXCEPTION("GRID::getElementType(medEntityMesh,int) : no connectivity defined !");
506   return _connectivity->getElementType(Entity,Number);
507 }
508
509 inline MED_EN::medGeometryElement GRID::getElementTypeWithPoly(MED_EN::medEntityMesh Entity,int Number) const
510 {
511   return getElementType(Entity,Number);
512 }
513
514 /*!
515   Calculate the ask connectivity. Return an exception if this could not be
516   done. Do nothing if connectivity already exist.
517  */
518
519 inline void GRID::calculateConnectivity(MED_EN::medModeSwitch Mode,MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh entity) const
520 {
521   fillConnectivity();
522
523   if (Mode==MED_EN::MED_FULL_INTERLACE)
524     _connectivity->calculateConnectivity(ConnectivityType,entity);
525   else
526     throw MEDEXCEPTION(LOCALIZED("GRID::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
527 }
528
529 inline const CONNECTIVITY* GRID::getConnectivityptr() const
530 {
531   fillConnectivity();
532
533   return _connectivity;
534 }
535
536 /*!
537   Return the required connectivity in the right mode for the given
538   geometric type of the given entity.
539
540   To get connectivity for all geometric type, use Mode=MED_FULL_INTERLACE
541   and Type=MED_ALL_ELEMENTS.
542   You must also get the corresponding index array.
543  */
544 inline const int * GRID::getConnectivity(MED_EN::medModeSwitch Mode,MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const
545 {
546   fillConnectivity();
547
548   if (Mode==MED_EN::MED_FULL_INTERLACE)
549     return _connectivity->getConnectivity(ConnectivityType,entity,Type);
550   throw MEDEXCEPTION(LOCALIZED("GRID::getConnectivity : only for MED_FULL_INTERLACE mode"));
551 }
552
553 /*!
554   Return the required index array for a connectivity received in
555   MED_FULL_ENTERLACE mode and MED_ALL_ELEMENTS type.
556
557   This array allow to find connectivity of each elements.
558
559   Example : Connectivity of i^{th} elements (1<=i<=NumberOfElement) begin
560   at index ConnectivityIndex[i-1] and end at index ConnectivityIndex[i]-1
561   in Connectivity array (Connectivity[ConnectivityIndex[i-1]-1] is the
562   first value)
563  */
564 inline const int * GRID::getConnectivityIndex(MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh entity) const
565 {
566   fillConnectivity();
567
568   return _connectivity->getConnectivityIndex(ConnectivityType, entity);
569 }
570
571 /*!
572   Return the reverse connectivity required by ConnectivityType :
573   - If ConnectivityType=MED_NODAL : return connectivity node-cell
574   - If ConnectivityType=MED_DESCENDING : return connectivity face-cell
575
576   You must get ReverseConnectivityIndex array to use it.
577  */
578 inline const int * GRID::getReverseConnectivity(MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh Entity/*=MED_CELL*/) const
579 {
580   fillConnectivity();
581
582   if (NULL==_connectivity)
583     throw MEDEXCEPTION("GRID::getReverseConnectivity : no connectivity defined in MESH !");
584
585   return _connectivity->getReverseConnectivity(ConnectivityType,Entity);
586 }
587
588 /*!
589   Return the index array required by ConnectivityType.
590
591   This array allow to find reverse connectivity of each elements.
592
593   Example : Reverse connectivity of i^{th} elements (1<=i<=NumberOfElement)
594   begin at index ReverseConnectivityIndex[i-1] and end at index
595   ReverseConnectivityIndex[i]-1
596   in ReverseConnectivity array (
597   ReverseConnectivity[ReverseConnectivityIndex[i-1]-1]
598   is the first value)
599  */
600 inline const int * GRID::getReverseConnectivityIndex(MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh Entity/*=MED_CELL*/) const
601 {
602   fillConnectivity();
603
604   if (NULL==_connectivity)
605     throw MEDEXCEPTION("GRID::getReverseConnectivityIndex : no connectivity defined in MESH !");
606
607   return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity);
608 }
609
610 }
611
612 #endif