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;
26 typedef string MESH_NAME_;
27 typedef string FIELD_NAME_;
28 typedef struct { int dt; int it; } DT_IT_;
31 bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const
33 if ( bool test = p1.dt == p2.dt)
34 return p1.it < p2.it ;
36 return p1.dt < p2.dt ;
39 typedef map<DT_IT_, FIELD_*, LT_DT_IT_ > MAP_DT_IT_;
41 // - IN THE FIRST CASE THE USER WANTS TO DISCOVER MESHES & FIELD_S
42 // CONTAINNED WITHIN A FILE <fileName> OF TYPE GIVEN BY THE <driverType> PARAMETER
43 // - IN THE SECOND CASE THE USER BEGINS HIS WORK WITH A MESH OR A FIELD,
44 // ?? GET A MED POINTER THEN CAN ADD MESHes OR FIELDs ??
49 This class is use to group together some MESH, SUPPORT and FIELD
56 // Add your personnal driver line (step 2)
57 friend class MED_MED_RDONLY_DRIVER;
58 friend class MED_MED_WRONLY_DRIVER;
59 friend class MED_MED_RDWR_DRIVER;
63 map<MESH_NAME_,MESH*> _meshes; // We can't have two MESHes with the same meshName.
64 // The string key is a meshName.
66 map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELD_s with the same fieldName.
68 map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD_ *
69 // in order to get the MESH* from _meshes
71 // POURQUOI MED_FR::med_entite_maillage ? devrait être MED_EN !
72 map < MESH_NAME_, map <MED_FR::med_entite_maillage,SUPPORT * > > _support ;
73 // For each MESH, we list support for each entity on all elements.
75 vector<GENDRIVER *> _drivers; // Storage of the MED_MED drivers currently in use
80 MED (driverTypes driverType, const string & fileName); // Analyse the file <fileName> by calling readFileStruct
83 // INUTILE : void addMesh (const string & meshName ); // Read the mesh <meshName> found in the file <_fileName>. <_fileName> must be set.
84 // INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant.
86 void addField ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ;
87 void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ;
89 // ------ Drivers Management Part
94 virtual GENDRIVER * run(const string & fileName, MED * const ptrMed) const = 0 ;
97 template <class T> class INSTANCE_DE : public INSTANCE {
99 GENDRIVER * run(const string & fileName, MED * const ptrMed) const
101 MESSAGE("GENDRIVER * run") ;
102 return new T(fileName,ptrMed) ;
106 // Add your new driver instance here (step 3)
107 static INSTANCE_DE<MED_MED_RDWR_DRIVER> inst_med ;
108 static INSTANCE_DE<VTK_MED_DRIVER> inst_vtk ;
109 static const INSTANCE * const instances[] ;
113 int addDriver (driverTypes driverType, const string & fileName);
114 int addDriver (GENDRIVER & driver);
115 void rmDriver (int index=0) throw (MEDEXCEPTION) ;
117 void readFileStruct(int index=0) throw (MEDEXCEPTION) ;
118 void read (int index=0) throw (MEDEXCEPTION) ;
119 void writeFrom (int index=0) throw (MEDEXCEPTION) ;
120 void write (int index=0) throw (MEDEXCEPTION) ;
122 // ------ End Of Drivers Management Part
124 int getNumberOfMeshes ( void ) const;
125 int getNumberOfFields ( void ) const;
126 void getMeshNames ( string * meshNames ) const throw (MEDEXCEPTION) ;
127 deque<string> getMeshNames () const;
128 MESH * getMesh ( const string & meshName ) const throw (MEDEXCEPTION) ;
129 MESH * getMesh ( const FIELD_ * const field ) const throw (MEDEXCEPTION) ;
130 void getFieldNames ( string * fieldNames ) const throw (MEDEXCEPTION) ;
131 deque<string> getFieldNames () const;
132 // A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE
133 deque<DT_IT_> getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION) ;
134 FIELD_ * getField ( const string & fieldName,
135 const int dt, const int it) const throw (MEDEXCEPTION) ;
137 const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const throw (MEDEXCEPTION) ;
139 SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const throw (MEDEXCEPTION) ;
141 void updateSupport () ;
143 // GERER LE CAS DE L'APPARITION DES MEMES NOMS DS DES FICHIERS <> !!!!!
145 //friend ostream & operator<<(ostream &os,const MED & med);
152 //REM : AJOUTER DS LES DRIVERS des attributes INTERLACE, NO INTERLACE .........
153 // AJOUTER L'OPERATEUR DE RECOPIE