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 DRIVERFACTORY_IXX
24 #define DRIVERFACTORY_IXX
26 #include "MEDMEM_VtkFieldDriver.hxx"
27 #include "MEDMEM_MedFieldDriver.hxx"
28 #include "MEDMEM_AsciiFieldDriver.hxx"
29 #include "MEDMEM_EnsightFieldDriver.hxx"
32 template<class T, class INTERLACING_TAG>
33 GENDRIVER * DRIVERFACTORY::buildDriverForField(driverTypes driverType,
34 const std::string & fileName,
35 FIELD<T,INTERLACING_TAG> *field,
36 MED_EN::med_mode_acces access)
44 case MED_EN::RDONLY : {
45 ret = new MED_FIELD_RDONLY_DRIVER<T>(fileName,field);
48 case MED_EN::WRONLY : {
49 ret= new MED_FIELD_WRONLY_DRIVER<T>(fileName,field);
53 ret = new MED_FIELD_RDWR_DRIVER<T>(fileName,field);
57 throw MED_EXCEPTION ("access type has not been properly specified to the method");
62 case ENSIGHT_DRIVER : {
65 case MED_EN::RDONLY : {
66 ret = new ENSIGHT_FIELD_RDONLY_DRIVER(fileName,field);
69 case MED_EN::WRONLY : {
70 ret=new ENSIGHT_FIELD_WRONLY_DRIVER(fileName,field);
74 throw MED_EXCEPTION ("not yet implemented");
78 throw MED_EXCEPTION ("access type has not been properly specified to the method");
86 case MED_EN::RDONLY : {
87 throw MED_EXCEPTION ("access mode other than MED_ECRI and MED_REMP has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver");
90 case MED_EN::WRONLY : {
91 ret=new VTK_FIELD_DRIVER<T>(fileName,field);
95 ret=new VTK_FIELD_DRIVER<T>(fileName,field);
99 throw MED_EXCEPTION ("access type has not been properly specified to the method");
105 throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
109 case PORFLOW_DRIVER : {
110 throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
114 case ASCII_DRIVER : {
117 case MED_EN::WRONLY : {
118 ret=new ASCII_FIELD_DRIVER<T>(fileName,field);
122 throw MED_EXCEPTION ("driver ASCII_DRIVER on FIELD only in write mod");
128 throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
132 MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
137 template<class T, class INTERLACING_TAG>
138 GENDRIVER * DRIVERFACTORY::buildFieldDriverFromFile(const string & fileName,
139 FIELD<T,INTERLACING_TAG> * ptrField,
140 MED_EN::med_mode_acces access)
142 MED_EN::medFileVersion version = MED_EN::V22;
146 version = getMedFileVersion(fileName);
148 catch (MEDEXCEPTION & )
152 MESSAGE_MED("buildFieldDriverFromFile version of the file " << version);
154 GENDRIVER * driver=0;
158 case MED_EN::RDONLY : {
159 if (version == MED_EN::V21)
160 throw MED_EXCEPTION ("med-2.1 files are no more supported");
161 else if (version == MED_EN::V22)
162 driver = new MED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField);
165 case MED_EN::WRONLY : {
166 if (version == MED_EN::V21)
167 throw MED_EXCEPTION ("med-2.1 files are no more supported");
168 else if (version == MED_EN::V22)
169 driver = new MED_FIELD_WRONLY_DRIVER<T>(fileName,ptrField);
172 case MED_EN::RDWR : {
173 if (version == MED_EN::V21)
174 throw MED_EXCEPTION ("med-2.1 files are no more supported");
175 else if (version == MED_EN::V22)
176 driver = new MED_FIELD_RDWR_DRIVER<T>(fileName,ptrField);
180 throw MED_EXCEPTION ("access type has not been properly specified to the method");
185 template<class T, class INTERLACING_TAG>
186 GENDRIVER * DRIVERFACTORY::buildConcreteMedDriverForField(const std::string & fileName,
187 FIELD<T,INTERLACING_TAG> *ptrField,
188 MED_EN::med_mode_acces access,
189 MED_EN::medFileVersion version)
192 MESSAGE_MED("buildConcreteMedDriverForField version of the file " << version);
194 if (version == MED_EN::V21)
195 throw MED_EXCEPTION ("med-2.1 files are no more supported");
197 GENDRIVER * driver=0;
201 case MED_EN::RDONLY : {
202 driver = new MED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField);
205 case MED_EN::WRONLY : {
206 driver = new MED_FIELD_WRONLY_DRIVER<T>(fileName,ptrField);
209 case MED_EN::RDWR : {
210 driver = new MED_FIELD_RDWR_DRIVER<T>(fileName,ptrField);
214 throw MED_EXCEPTION ("access type has not been properly specified to the method");