1 // Copyright (C) 2007-2008 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
22 #include "MEDMEM_Exception.hxx"
23 #include "MEDMEM_define.hxx"
25 #include "MEDMEM_Field.hxx"
26 #include "MEDMEM_Mesh.hxx"
27 #include "MEDMEM_Med.hxx"
28 #include "MEDMEM_MedMedDriver.hxx"
29 #include "MEDMEM_MedMeshDriver.hxx"
31 using namespace MEDMEM ;
32 using namespace MED_EN ;
36 const char * fileName = "pointe.med";
37 const char * fileName2 = "Field&MeshGeneratedPointe.med";
38 const char * fileName3 = "MedGeneratedPointe.med";
39 const char * fieldName = "fieldcelldouble";
40 const char * meshName = "maa1";
43 // Test creation of drivers from the standard driver method of an object
45 FIELD<double> * myField = new FIELD<double>();
46 MED_FIELD_RDONLY_DRIVER<double> myRdOnlyDriver(fileName,myField);
47 myRdOnlyDriver.setFieldName(fieldName);
48 myRdOnlyDriver.open();
49 //This test failed due to inadequate Support implementation
50 // myRdOnlyDriver.read();
51 // try { myRdOnlyDriver.write(); } catch (MEDEXCEPTION& ex)
52 // { MESSAGE(ex.what()); }
53 MED_FIELD_WRONLY_DRIVER<double> myWrOnlyDriver(fileName2,myField);
54 myWrOnlyDriver.open();
55 //This test failed due to inadequate Support implementation
56 // myWrOnlyDriver.write();
57 // try myWrOnlyDriver.read(); catch (MEDEXCEPTION& ex)
58 // { MESSAGE(ex.what()); }
59 myRdOnlyDriver.close();
60 myWrOnlyDriver.close();
65 MESH * myMesh = new MESH();
66 MED_MESH_RDONLY_DRIVER myRdOnlyDriver(fileName,myMesh);
67 myRdOnlyDriver.setMeshName(meshName);
68 myRdOnlyDriver.open();
69 myRdOnlyDriver.read();
70 myRdOnlyDriver.close();
71 // try { myRdOnlyDriver.write(); } catch (MEDEXCEPTION& ex)
72 // { MESSAGE(ex.what()); }
73 MED_MESH_WRONLY_DRIVER myWrOnlyDriver(fileName2,myMesh);
74 myWrOnlyDriver.setMeshName(meshName);
75 myWrOnlyDriver.open();
76 myWrOnlyDriver.write();
77 // try myWrOnlyDriver.read(); catch (MEDEXCEPTION& ex)
78 // { MESSAGE(ex.what()); }
79 // myRdOnlyDriver.close();
80 //While we use H5close() in the MESH/FIELD drivers, the next
81 //line will fail, because all files are previously closed !
82 myWrOnlyDriver.close();
87 MED * myMed = new MED();
88 MED_MED_RDONLY_DRIVER myRdOnlyDriver(fileName,myMed);
89 myRdOnlyDriver.open();
90 myRdOnlyDriver.readFileStruct();
91 myRdOnlyDriver.close();
92 myMed->updateSupport(); // DOIT ETRE SUPPRIMEE
93 // myRdOnlyDriver.read();
94 // try { myRdOnlyDriver.write(); } catch (MEDEXCEPTION& ex)
95 // { MESSAGE(ex.what()); }
96 //MED_MED_WRONLY_DRIVER myWrOnlyDriver(fileName3,myMed);
97 //myWrOnlyDriver.open();
98 //myWrOnlyDriver.write(); // Not implemented yet.
99 //myWrOnlyDriver.close();
103 } catch (MEDEXCEPTION& ex){
104 cout << "MAIN BLOCK EXCEPTION" << endl;