]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_Med.hxx
Salome HOME
Final version V2_0_1 which works with Med File V2.1 and the KERNEL
[modules/med.git] / src / MEDMEM / MEDMEM_Med.hxx
1 # ifndef MED_HXX
2 # define MED_HXX
3
4 // STL
5 # include <string>
6 # include <map>
7 # include <vector>
8 # include <deque>
9
10 // LOCAL
11 # include "MEDMEM_define.hxx"
12 # include "MEDMEM_Exception.hxx"
13 # include "MEDMEM_GenDriver.hxx"
14
15 using namespace MED_EN;
16
17
18 namespace MEDMEM {
19 class MESH;
20 class FIELD_;
21 class SUPPORT ;
22
23 typedef string MESH_NAME_;
24 typedef string FIELD_NAME_;
25 typedef struct { int dt; int it; } DT_IT_;
26 struct LT_DT_IT_
27 {
28   bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const
29   {
30     if ( bool test = p1.dt == p2.dt)
31       return p1.it < p2.it ;
32     else
33       return  p1.dt < p2.dt ;
34   }
35 };
36 typedef map<DT_IT_, FIELD_*, LT_DT_IT_ > MAP_DT_IT_; 
37
38 // - IN THE FIRST CASE THE USER WANTS TO DISCOVER MESHES & FIELD_S 
39 //   CONTAINNED WITHIN A FILE <fileName> OF TYPE GIVEN BY THE  <driverType> PARAMETER
40 // - IN THE SECOND CASE THE USER BEGINS HIS WORK WITH A MESH OR A FIELD, 
41 //   ?? GET A MED POINTER THEN CAN ADD MESHes OR FIELDs ??
42 //
43
44 /*!
45
46   This class is use to group together some MESH, SUPPORT and FIELD
47   objects.
48
49 */
50
51 class MED
52 {
53   // Add your personnal driver line (step 2)
54   friend class MED_MED_RDONLY_DRIVER;
55   friend class MED_MED_WRONLY_DRIVER;
56   friend class MED_MED_RDWR_DRIVER;
57
58 private:
59
60   map<MESH_NAME_,MESH*>        _meshes;     // We can't have two MESHes with the same meshName.  
61                                             // The string key is a meshName.
62
63   map<FIELD_NAME_,MAP_DT_IT_>  _fields;     // We can't have two FIELD_s with the same fieldName. 
64  
65   map<FIELD_ *, MESH_NAME_>    _meshName;   // Get the meshName associated with a FIELD_ * 
66                                             // in order to get the MESH* from _meshes 
67
68   // POURQUOI MED_FR::med_entite_maillage ? devrait être MED_EN !
69   map < MESH_NAME_, map <MED_FR::med_entite_maillage,SUPPORT * > > _support ;
70   // For each MESH, we list support for each entity on all elements.
71
72   vector<GENDRIVER *>  _drivers;          // Storage of the MED_MED drivers currently in use
73
74 public:
75
76   MED();
77   MED (driverTypes driverType, const string & fileName); // Analyse the file <fileName> by calling readFileStruct
78   ~MED();
79   
80   // INUTILE : void addMesh  (const string & meshName  ); // Read the mesh <meshName> found in the file <_fileName>. <_fileName> must be set.
81   // INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant.
82   
83   void addField ( FIELD_  * const ptrField  ) throw (MED_EXCEPTION) ;
84   void addMesh  ( MESH    * const ptrMesh   ) throw (MED_EXCEPTION) ;
85   int  addDriver     (driverTypes driverType, const string & fileName);
86   int  addDriver     (GENDRIVER & driver);
87   void rmDriver      (int index=0) throw (MEDEXCEPTION) ;
88
89   void readFileStruct(int index=0) throw (MEDEXCEPTION) ;
90   void read          (int index=0) throw (MEDEXCEPTION) ;
91   void writeFrom     (int index=0) throw (MEDEXCEPTION) ; 
92   void write         (int index=0) throw (MEDEXCEPTION) ; 
93   
94   // ------ End Of Drivers Management Part
95
96   int        getNumberOfMeshes ( void ) const;       
97   int        getNumberOfFields ( void ) const;       
98   void       getMeshNames      ( string * meshNames ) const throw (MEDEXCEPTION) ;
99   deque<string> getMeshNames   () const;
100   MESH     * getMesh           ( const string & meshName ) const throw (MEDEXCEPTION) ;
101   MESH     * getMesh           ( const  FIELD_ * const field ) const throw (MEDEXCEPTION) ;
102   void       getFieldNames     ( string * fieldNames        ) const throw (MEDEXCEPTION) ;
103   deque<string> getFieldNames  () const;
104   // A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE
105   deque<DT_IT_> getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION) ;
106   FIELD_   * getField          ( const string & fieldName,
107                                  const int dt,  const int it) const throw (MEDEXCEPTION) ;
108
109   const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const throw (MEDEXCEPTION) ;
110
111   SUPPORT *  getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const throw (MEDEXCEPTION) ;
112
113   void       updateSupport () ;
114
115   // GERER LE CAS DE L'APPARITION DES MEMES NOMS DS DES FICHIERS <> !!!!!
116  
117   //friend ostream & operator<<(ostream &os,const MED & med);
118
119 };
120 };
121
122 #endif
123
124 //REM : AJOUTER DS LES DRIVERS des attributes INTERLACE, NO INTERLACE .........
125 //      AJOUTER L'OPERATEUR DE RECOPIE