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