11 # include "MEDMEM_define.hxx"
13 // Add your own driver header (step 2)
14 # include "MEDMEM_MedMedDriver.hxx"
15 # include "MEDMEM_VtkMedDriver.hxx"
17 # include "MEDMEM_Exception.hxx"
18 //using namespace MED_EN;
25 typedef string MESH_NAME_;
26 typedef string FIELD_NAME_;
27 typedef struct { int dt; int it; } DT_IT_;
30 bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const
32 if ( bool test = p1.dt == p2.dt)
33 return p1.it < p2.it ;
35 return p1.dt < p2.dt ;
38 typedef map<DT_IT_, FIELD_*, LT_DT_IT_ > MAP_DT_IT_;
40 // - IN THE FIRST CASE THE USER WANTS TO DISCOVER MESHES & FIELD_S
41 // CONTAINNED WITHIN A FILE <fileName> OF TYPE GIVEN BY THE <driverType> PARAMETER
42 // - IN THE SECOND CASE THE USER BEGINS HIS WORK WITH A MESH OR A FIELD,
43 // ?? GET A MED POINTER THEN CAN ADD MESHes OR FIELDs ??
48 This class is use to group together some MESH, SUPPORT and FIELD
55 // Add your personnal driver line (step 2)
56 friend class MED_MED_RDONLY_DRIVER;
57 friend class MED_MED_WRONLY_DRIVER;
58 friend class MED_MED_RDWR_DRIVER;
62 map<MESH_NAME_,MESH*> _meshes; // We can't have two MESHes with the same meshName.
63 // The string key is a meshName.
65 map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELD_s with the same fieldName.
67 map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD_ *
68 // in order to get the MESH* from _meshes
70 // POURQUOI MED_FR::med_entite_maillage ? devrait être MED_EN !
71 map < MESH_NAME_, map <MED_FR::med_entite_maillage,SUPPORT * > > _support ;
72 // For each MESH, we list support for each entity on all elements.
74 vector<GENDRIVER *> _drivers; // Storage of the MED_MED drivers currently in use
79 MED (driverTypes driverType, const string & fileName); // Analyse the file <fileName> by calling readFileStruct
82 // INUTILE : void addMesh (const string & meshName ); // Read the mesh <meshName> found in the file <_fileName>. <_fileName> must be set.
83 // INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant.
85 void addField ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ;
86 void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ;
88 // ------ Drivers Management Part
93 virtual GENDRIVER * run(const string & fileName, MED * const ptrMed) const = 0 ;
96 template <class T> class INSTANCE_DE : public INSTANCE {
98 GENDRIVER * run(const string & fileName, MED * const ptrMed) const
100 MESSAGE("GENDRIVER * run") ;
101 return new T(fileName,ptrMed) ;
105 // Add your new driver instance here (step 3)
106 static INSTANCE_DE<MED_MED_RDWR_DRIVER> inst_med ;
107 static INSTANCE_DE<VTK_MED_DRIVER> inst_vtk ;
108 static const INSTANCE * const instances[] ;
112 int addDriver (driverTypes driverType, const string & fileName);
113 int addDriver (GENDRIVER & driver);
114 void rmDriver (int index=0) throw (MEDEXCEPTION) ;
116 void readFileStruct(int index=0) throw (MEDEXCEPTION) ;
117 void read (int index=0) throw (MEDEXCEPTION) ;
118 void writeFrom (int index=0) throw (MEDEXCEPTION) ;
119 void write (int index=0) throw (MEDEXCEPTION) ;
121 // ------ End Of Drivers Management Part
123 int getNumberOfMeshes ( void ) const;
124 int getNumberOfFields ( void ) const;
125 void getMeshNames ( string * meshNames ) const throw (MEDEXCEPTION) ;
126 deque<string> getMeshNames () const;
127 MESH * getMesh ( const string & meshName ) const throw (MEDEXCEPTION) ;
128 MESH * getMesh ( const FIELD_ * const field ) const throw (MEDEXCEPTION) ;
129 void getFieldNames ( string * fieldNames ) const throw (MEDEXCEPTION) ;
130 deque<string> getFieldNames () const;
131 // A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE
132 deque<DT_IT_> getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION) ;
133 FIELD_ * getField ( const string & fieldName,
134 const int dt, const int it) const throw (MEDEXCEPTION) ;
136 const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const throw (MEDEXCEPTION) ;
138 SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const throw (MEDEXCEPTION) ;
140 void updateSupport () ;
142 // GERER LE CAS DE L'APPARITION DES MEMES NOMS DS DES FICHIERS <> !!!!!
144 //friend ostream & operator<<(ostream &os,const MED & med);
150 //REM : AJOUTER DS LES DRIVERS des attributes INTERLACE, NO INTERLACE .........
151 // AJOUTER L'OPERATEUR DE RECOPIE