1 // MED MEDMEM : MED files in memory
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : MEDMEM_Med.hxx
37 # include "MEDMEM_define.hxx"
39 // Add your own driver header (step 2)
40 # include "MEDMEM_MedMedDriver.hxx"
41 # include "MEDMEM_VtkMedDriver.hxx"
43 # include "MEDMEM_Exception.hxx"
44 //using namespace MED_EN;
51 typedef string MESH_NAME_;
52 typedef string FIELD_NAME_;
53 typedef struct { int dt; int it; } DT_IT_;
56 bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const
58 if ( bool test = p1.dt == p2.dt)
59 return p1.it < p2.it ;
61 return p1.dt < p2.dt ;
64 typedef map<DT_IT_, FIELD_*, LT_DT_IT_ > MAP_DT_IT_;
66 // - IN THE FIRST CASE THE USER WANTS TO DISCOVER MESHES & FIELD_S
67 // CONTAINNED WITHIN A FILE <fileName> OF TYPE GIVEN BY THE <driverType> PARAMETER
68 // - IN THE SECOND CASE THE USER BEGINS HIS WORK WITH A MESH OR A FIELD,
69 // ?? GET A MED POINTER THEN CAN ADD MESHes OR FIELDs ??
74 This class is use to group together some MESH, SUPPORT and FIELD
81 // Add your personnal driver line (step 2)
82 friend class MED_MED_RDONLY_DRIVER;
83 friend class MED_MED_WRONLY_DRIVER;
84 friend class MED_MED_RDWR_DRIVER;
88 map<MESH_NAME_,MESH*> _meshes; // We can't have two MESHes with the same meshName.
89 // The string key is a meshName.
91 map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELD_s with the same fieldName.
93 map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD_ *
94 // in order to get the MESH* from _meshes
96 // POURQUOI MED_FR::med_entite_maillage ? devrait être MED_EN !
97 map < MESH_NAME_, map <MED_FR::med_entite_maillage,SUPPORT * > > _support ;
98 // For each MESH, we list support for each entity on all elements.
100 vector<GENDRIVER *> _drivers; // Storage of the MED_MED drivers currently in use
105 MED (driverTypes driverType, const string & fileName); // Analyse the file <fileName> by calling readFileStruct
108 // INUTILE : void addMesh (const string & meshName ); // Read the mesh <meshName> found in the file <_fileName>. <_fileName> must be set.
109 // INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant.
111 void addField ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ;
112 void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ;
114 // ------ Drivers Management Part
119 virtual GENDRIVER * run(const string & fileName, MED * const ptrMed) const = 0 ;
122 template <class T> class INSTANCE_DE : public INSTANCE {
124 GENDRIVER * run(const string & fileName, MED * const ptrMed) const
126 MESSAGE("GENDRIVER * run") ;
127 return new T(fileName,ptrMed) ;
131 // Add your new driver instance here (step 3)
132 static INSTANCE_DE<MED_MED_RDWR_DRIVER> inst_med ;
133 static INSTANCE_DE<VTK_MED_DRIVER> inst_vtk ;
134 static const INSTANCE * const instances[] ;
138 int addDriver (driverTypes driverType, const string & fileName);
139 int addDriver (GENDRIVER & driver);
140 void rmDriver (int index=0) throw (MEDEXCEPTION) ;
142 void readFileStruct(int index=0) throw (MEDEXCEPTION) ;
143 void read (int index=0) throw (MEDEXCEPTION) ;
144 void writeFrom (int index=0) throw (MEDEXCEPTION) ;
145 void write (int index=0) throw (MEDEXCEPTION) ;
147 // ------ End Of Drivers Management Part
149 int getNumberOfMeshes ( void ) const;
150 int getNumberOfFields ( void ) const;
151 void getMeshNames ( string * meshNames ) const throw (MEDEXCEPTION) ;
152 deque<string> getMeshNames () const;
153 MESH * getMesh ( const string & meshName ) const throw (MEDEXCEPTION) ;
154 MESH * getMesh ( const FIELD_ * const field ) const throw (MEDEXCEPTION) ;
155 void getFieldNames ( string * fieldNames ) const throw (MEDEXCEPTION) ;
156 deque<string> getFieldNames () const;
157 // A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE
158 deque<DT_IT_> getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION) ;
159 FIELD_ * getField ( const string & fieldName,
160 const int dt, const int it) const throw (MEDEXCEPTION) ;
162 const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const throw (MEDEXCEPTION) ;
164 SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const throw (MEDEXCEPTION) ;
166 void updateSupport () ;
168 // GERER LE CAS DE L'APPARITION DES MEMES NOMS DS DES FICHIERS <> !!!!!
170 //friend ostream & operator<<(ostream &os,const MED & med);
176 //REM : AJOUTER DS LES DRIVERS des attributes INTERLACE, NO INTERLACE .........
177 // AJOUTER L'OPERATEUR DE RECOPIE