1 #include "MEDMEM_DriverFactory.hxx"
2 #include "MEDMEM_MedMedDriver.hxx"
3 #include "MEDMEM_MedMeshDriver.hxx"
4 #include "MEDMEM_Mesh.hxx"
5 #include "MEDMEM_GibiMeshDriver.hxx"
6 #include "MEDMEM_PorflowMeshDriver.hxx"
7 #include "MEDMEM_VtkMeshDriver.hxx"
8 #include "MEDMEM_VtkMedDriver.hxx"
10 #include "MEDMEM_Exception.hxx"
12 #include "MEDMEM_MedVersion.hxx"
13 #include "MEDMEM_Compatibility21_22.hxx"
14 #include "MEDMEM_MedMedDriver21.hxx"
15 #include "MEDMEM_MedMedDriver22.hxx"
16 #include "MEDMEM_MedMeshDriver21.hxx"
17 #include "MEDMEM_MedMeshDriver22.hxx"
19 using namespace MEDMEM;
20 using namespace MED_EN;
23 void fill<-1,0x3>(double *a, const double *b)
28 bool compare<-1>(const double *a, const double *b)
33 MED_EN::medFileVersion DRIVERFACTORY::globalMedFileVersionForWriting = MED_EN::V22;
35 medFileVersion DRIVERFACTORY::getMedFileVersionForWriting()
37 return DRIVERFACTORY::globalMedFileVersionForWriting;
40 void DRIVERFACTORY::setMedFileVersionForWriting(medFileVersion version)
42 DRIVERFACTORY::globalMedFileVersionForWriting = version;
45 GENDRIVER *DRIVERFACTORY::buildDriverForMesh(driverTypes driverType,
46 const std::string & fileName,
48 const string & driverName,
49 med_mode_acces access)
58 ret = new MED_MESH_RDONLY_DRIVER(fileName, mesh);
59 ret->setMeshName(driverName);
63 ret = new MED_MESH_WRONLY_DRIVER(fileName, mesh);
64 ret->setMeshName(driverName);
68 ret = new MED_MESH_RDWR_DRIVER(fileName, mesh);
69 ret->setMeshName(driverName);
73 throw MED_EXCEPTION ("access type has not been properly specified to the method");
82 ret=new GIBI_MESH_RDONLY_DRIVER(fileName,mesh);
86 throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the GIBI_DRIVER type which is not allowed because GIBI_DRIVER is only a read access driver");
89 throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the GIBI_DRIVER type which is not allowed because GIBI_DRIVER is only a read access driver");
92 throw MED_EXCEPTION ("access type has not been properly specified to the method");
97 case PORFLOW_DRIVER : {
101 ret=new PORFLOW_MESH_RDONLY_DRIVER(fileName,mesh);
105 throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the PORFLOW_DRIVER type which is not allowed because PORFLOW_DRIVER is only a read access driver");
108 throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the PORFLOW_DRIVER type which is not allowed because PORFLOW_DRIVER is only a read access driver");
111 throw MED_EXCEPTION ("access type has not been properly specified to the method");
120 throw MED_EXCEPTION ("access mode other than MED_ECRI or MED_REMPT has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver");
123 ret=new VTK_MESH_DRIVER(fileName,mesh);
127 ret=new VTK_MESH_DRIVER(fileName,mesh);
131 throw MED_EXCEPTION ("access type has not been properly specified to the method");
137 throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
140 throw MED_EXCEPTION ("other driver than MED_DRIVER GIBI_DRIVER PORFLOW_DRIVER and VT_DRIVER has been specified to the method which is not allowed");
144 GENDRIVER *DRIVERFACTORY::buildDriverForMed(driverTypes driverType,
145 const std::string & fileName,
146 MED *med, med_mode_acces access)
156 ret=new MED_MED_RDONLY_DRIVER(fileName,med);
160 ret=new MED_MED_WRONLY_DRIVER(fileName,med);
164 ret=new MED_MED_RDONLY_DRIVER(fileName,med);
168 throw MED_EXCEPTION ("access type has not been properly specified to the method");
177 throw MED_EXCEPTION ("access mode other than MED_ECRI or MED_REMPT has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver");
180 ret=new VTK_MED_DRIVER(fileName,med);
184 ret=new VTK_MED_DRIVER(fileName,med);
188 throw MED_EXCEPTION ("access type has not been properly specified to the method");
194 throw MED_EXCEPTION ("GIBI_DRIVER has been specified to the method which is not allowed because there is no GIBI driver for the MED object");
198 case PORFLOW_DRIVER : {
199 throw MED_EXCEPTION ("PORFLOW_DRIVER has been specified to the method which is not allowed because there is no PORFLOW driver for the MED object");
204 throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
208 throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
213 GENDRIVER * DRIVERFACTORY::buildMedDriverFromFile(const string & fileName,
215 MED_EN::med_mode_acces access)
217 medFileVersion version;
221 version = getMedFileVersion(fileName);
223 catch (MEDEXCEPTION & ex)
225 version = DRIVERFACTORY::globalMedFileVersionForWriting;
228 MESSAGE("buildMedDriverFromFile version of the file " << version);
236 driver = new MED_MED_RDONLY_DRIVER21(fileName,ptrMed);
237 else if (version == V22)
238 driver = new MED_MED_RDONLY_DRIVER22(fileName,ptrMed);
243 driver = new MED_MED_WRONLY_DRIVER21(fileName,ptrMed);
244 else if (version == V22)
245 driver = new MED_MED_WRONLY_DRIVER22(fileName,ptrMed);
250 driver = new MED_MED_RDWR_DRIVER21(fileName,ptrMed);
251 else if (version == V22)
252 driver = new MED_MED_RDWR_DRIVER22(fileName,ptrMed);
256 throw MED_EXCEPTION ("access type has not been properly specified to the method");
260 GENDRIVER * DRIVERFACTORY::buildMeshDriverFromFile(const string & fileName,
262 MED_EN::med_mode_acces access)
264 medFileVersion version;
268 version = getMedFileVersion(fileName);
270 catch (MEDEXCEPTION & ex)
272 version = DRIVERFACTORY::globalMedFileVersionForWriting;
275 MESSAGE("buildMeshDriverFromFile version of the file " << version);
283 driver = new MED_MESH_RDONLY_DRIVER21(fileName,ptrMesh);
284 else if (version == V22)
285 driver = new MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh);
290 driver = new MED_MESH_WRONLY_DRIVER21(fileName,ptrMesh);
291 else if (version == V22)
292 driver = new MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh);
297 driver = new MED_MESH_RDWR_DRIVER21(fileName,ptrMesh);
298 else if (version == V22)
299 driver = new MED_MESH_RDWR_DRIVER22(fileName,ptrMesh);
303 throw MED_EXCEPTION ("access type has not been properly specified to the method");
307 GENDRIVER * DRIVERFACTORY::buildConcreteMedDriverForMesh(const std::string & fileName,
308 MESH *ptrMesh,const string & driverName,
309 MED_EN::med_mode_acces access,
310 MED_EN::medFileVersion version)
314 MESSAGE("buildConcreteMedDriverForMesh version of the file " << version);
320 driver = new MED_MESH_RDONLY_DRIVER21(fileName,ptrMesh);
321 else if (version == V22)
322 driver = new MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh);
323 driver->setMeshName(driverName);
328 driver = new MED_MESH_WRONLY_DRIVER21(fileName,ptrMesh);
329 else if (version == V22)
330 driver = new MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh);
331 driver->setMeshName(driverName);
336 driver = new MED_MESH_RDWR_DRIVER21(fileName,ptrMesh);
337 else if (version == V22)
338 driver = new MED_MESH_RDWR_DRIVER22(fileName,ptrMesh);
339 driver->setMeshName(driverName);
343 throw MED_EXCEPTION ("access type has not been properly specified to the method");