1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef MED_FIELD_DRIVER_HXX
24 #define MED_FIELD_DRIVER_HXX
26 #include "MEDMEM_GenDriver.hxx"
29 template <class T> class MED_FIELD_RDWR_DRIVER;
30 template <class T> class MED_FIELD_RDONLY_DRIVER;
31 template <class T> class MED_FIELD_WRONLY_DRIVER;
37 Generic part : implement open and close methods.
41 template <class T> class MED_FIELD_DRIVER : public GENDRIVER
44 // Developement plus propre :
45 // - Il faudrait soit utiliser le type FIELD_ et ajouter à cette classe
46 // les accesseurs de FIELD<> utilisées dans les drivers
47 // - Ou bien avoir des drivers à deux paramètres template (le top)
48 // - Remarquez l'affreux cast dans le second constructeur :
49 // _ptrField( (FIELD<T> *) ptrField )
50 // Cela cast toujours le ptrField en FullInterlace
51 // Cela ne pose cependant pas de pb de fonctionement aux drivers
53 std::string _fieldName;
55 med_2_3::med_idt _medIdt;
61 template <class INTERLACING_TAG>
62 MED_FIELD_DRIVER(const std::string & fileName,
63 FIELD<T, INTERLACING_TAG> * ptrField,
64 MED_EN::med_mode_acces accessMode);
66 MED_FIELD_DRIVER(const MED_FIELD_DRIVER & fieldDriver);
68 virtual ~MED_FIELD_DRIVER();
70 virtual void open() throw (MEDEXCEPTION);
72 virtual void write( void ) const = 0 ;
73 virtual void read ( void ) = 0 ;
75 Set the name of the FIELD asked in file.
77 It could be different than the name of the FIELD object.
79 virtual void setFieldName(const std::string & fieldName) { _fieldName = fieldName; }
81 Get the name of the FIELD asked in file.
83 virtual std::string getFieldName() const { return _fieldName; }
86 virtual GENDRIVER * copy ( void ) const = 0 ;
88 bool createFieldSupportPart1(med_2_3::med_idt id,
89 const std::string & fieldName,
93 std::string & meshName,
94 std::vector<int> & numberOfElementsOfTypeC,
95 std::vector<int> & numberOfGaussPoint,
96 std::vector<std::string>& gaussModelName,
97 std::vector<std::string>& profilName,
98 int & totalNumberOfElWg,
99 MED_EN::medEntityMesh & fieldMedFileEntity,
100 MED_EN::medEntityMesh preferEntity=MED_EN::MED_ALL_ENTITIES
101 ) const throw (MEDEXCEPTION);
103 void getMeshGeometricTypeFromFile(med_2_3::med_idt id,
104 std::string & meshName,
105 MED_EN::medEntityMesh entite,
106 std::vector<MED_EN::medGeometryElement> & geoType,
107 std::vector<int> & nbOfElOfType,
108 std::vector<int> & nbOfElOfTypeC
109 ) const throw(MEDEXCEPTION);
111 void getMeshGeometricTypeFromMESH( const GMESH * meshPtr,
112 MED_EN::medEntityMesh entity,
113 std::vector<MED_EN::medGeometryElement> & geoType,
114 std::vector<int> &nbOfElOfType,
115 std::vector<int> &nbOfElOfTypeC
116 ) const throw(MEDEXCEPTION);
118 int getMeshDimensionFromFile(med_2_3::med_idt id, const string & meshName) const;
120 MED_EN::medEntityMesh getMEDMEMEntityFromMEDType(MED_EN::medGeometryElement type,
127 Driver Med for FIELD : Read only.
129 Implement read method.
133 template <class T> class MED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER<T>
137 MED_FIELD_RDONLY_DRIVER();
139 template <class INTERLACING_TAG>
140 MED_FIELD_RDONLY_DRIVER(const string & fileName,
141 FIELD<T, INTERLACING_TAG> * ptrField);
143 MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver);
145 virtual ~MED_FIELD_RDONLY_DRIVER() {};
147 void write( void ) const throw (MEDEXCEPTION) ;
148 void read ( void ) throw (MEDEXCEPTION) ;
151 GENDRIVER * copy( void ) const ;
157 Driver Med for FIELD : Write only.
159 Implement write method.
163 template <class T> class MED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER<T>
167 MED_FIELD_WRONLY_DRIVER();
169 template <class INTERLACING_TAG>
170 MED_FIELD_WRONLY_DRIVER(const string & fileName,
171 FIELD<T, INTERLACING_TAG> * ptrField);
173 MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver);
175 virtual ~MED_FIELD_WRONLY_DRIVER();
178 Write FIELD in the specified file.
180 void write( void ) const throw (MEDEXCEPTION) ;
182 Return a MEDEXCEPTION : it is the write-only driver.
184 void read ( void ) throw (MEDEXCEPTION) ;
187 GENDRIVER * copy( void ) const ;
194 Driver Med for FIELD : Read write.
195 - Use read method from MED_FIELD_RDONLY_DRIVER
196 - Use write method from MED_FIELD_WDONLY_DRIVER
200 template <class T> class MED_FIELD_RDWR_DRIVER : public MED_FIELD_RDONLY_DRIVER<T>, public MED_FIELD_WRONLY_DRIVER<T>
204 MED_FIELD_RDWR_DRIVER();
206 template <class INTERLACING_TAG>
207 MED_FIELD_RDWR_DRIVER(const string & fileName,
208 FIELD<T, INTERLACING_TAG> * ptrField);
210 MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver);
215 ~MED_FIELD_RDWR_DRIVER();
218 Write FIELD in the specified file.
220 void write(void) const throw (MEDEXCEPTION) ;
222 Read FIELD in the specified file.
224 void read (void) throw (MEDEXCEPTION) ;
227 GENDRIVER * copy( void ) const ;
231 } //End namespace MEDMEM
234 #include "MEDMEM_MedFieldDriver.txx"
236 #endif /* MED_FIELD_DRIVER_HXX */