11 # include "MEDMEM_define.hxx"
12 # include "MEDMEM_MedMedDriver.hxx"
13 # include "MEDMEM_Exception.hxx"
14 //using namespace MED_EN;
21 typedef string MESH_NAME_;
22 typedef string FIELD_NAME_;
23 typedef struct { int dt; int it; } DT_IT_;
26 bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const
28 if ( bool test = p1.dt == p2.dt)
29 return p1.it < p2.it ;
31 return p1.dt < p2.dt ;
34 typedef map<DT_IT_, FIELD_*, LT_DT_IT_ > MAP_DT_IT_;
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 ??
43 friend class MED_MED_DRIVER;
44 friend class MED_MED_RDONLY_DRIVER;
48 map<MESH_NAME_,MESH*> _meshes; // We can't have two MESHes with the same meshName.
49 // The string key is a meshName.
51 map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELDs with the same fieldName.
53 map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD *
54 // in order to get the MESH* from _meshes
56 map < MESH_NAME_, map <MED_FR::med_entite_maillage,SUPPORT * > > _support ;
57 // For each MESH, we list support for each entity on all elements.
59 vector<GENDRIVER *> _drivers; // Storage of the MED_MED drivers currently in use
64 MED (driverTypes driverType, const string & fileName); // Analyse the file <fileName> by calling readFileStruct
67 // INUTILE : void addMesh (const string & meshName ); // Read the mesh <meshName> found in the file <_fileName>. <_fileName> must be set.
68 // INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant.
70 void addField (const FIELD_ * const ptrField ) throw (MEDEXCEPTION) ; // Add an existing FIELD object to the FIELD list, the meshName is given by the FIELD object.
71 void addMesh (const MESH * ptrMesh ) throw (MEDEXCEPTION) ; // Add an existing MESH object to the MESH list, the meshName is given by the MESH object.
73 // ------ Drivers Management Part
78 virtual GENDRIVER * run(const string & fileName, MED * const ptrMed) const = 0 ;
81 template <class T> class INSTANCE_DE : public INSTANCE {
83 GENDRIVER * run(const string & fileName, MED * const ptrMed) const { return new T(fileName,ptrMed) ; }
86 static INSTANCE_DE<MED_MED_DRIVER> inst_med ;
87 //static INSTANCE_DE<VTK_DRIVER> inst_vtk ;
88 static const INSTANCE * const instances[] ;
92 int addDriver (driverTypes driverType, const string & fileName);
93 int addDriver (GENDRIVER & driver);
94 void rmDriver (int index=0);
95 void readFileStruct(int index=0);
96 // void read (int index=0);
97 void writeFrom (int index=0);
98 void write (int index=0);
100 // ------ End Of Drivers Management Part
102 int getNumberOfMeshes ( void ) const;
103 int getNumberOfFields ( void ) const;
104 void getMeshNames ( string * meshNames ) const;
105 deque<string> getMeshNames () const;
106 MESH * getMesh ( const string & meshName ) const;
107 MESH * getMesh ( const FIELD_ * field ) const;
108 void getFieldNames ( string * fieldNames ) const;
109 deque<string> getFieldNames () const;
110 // A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE
111 deque<DT_IT_> getFieldIteration (const string & fieldName) const ;
112 FIELD_ * getField ( const string & fieldName,
113 const int dt, const int it) const;
115 const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const;
116 SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const ;
118 void updateSupport () ;
120 // GERER LE CAS DE L'APPARITION DES MEMES NOMS DS DES FICHIERS <> !!!!!
122 //friend ostream & operator<<(ostream &os,const MED & med);
128 //REM : AJOUTER DS LES DRIVERS des attributes INTERLACE, NO INTERLACE .........
129 // AJOUTER L'OPERATEUR DE RECOPIE