1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 #include "MEDMEM_Exception.hxx"
21 #include "MEDMEM_define.hxx"
23 #include "MEDMEM_Field.hxx"
24 #include "MEDMEM_Mesh.hxx"
25 #include "MEDMEM_Med.hxx"
26 #include "MEDMEM_MedMedDriver.hxx"
27 #include "MEDMEM_MedMeshDriver.hxx"
29 using namespace MEDMEM ;
30 using namespace MED_EN ;
34 const char * fileName = "pointe.med";
35 const char * fileName2 = "Field&MeshGeneratedPointe.med";
36 const char * fileName3 = "MedGeneratedPointe.med";
37 const char * fieldName = "fieldcelldouble";
38 const char * meshName = "maa1";
41 // Test creation of drivers from the standard driver method of an object
43 FIELD<double> * myField = new FIELD<double>();
44 MED_FIELD_RDONLY_DRIVER<double> myRdOnlyDriver(fileName,myField);
45 myRdOnlyDriver.setFieldName(fieldName);
46 myRdOnlyDriver.open();
47 //This test failed due to inadequate Support implementation
48 // myRdOnlyDriver.read();
49 // try { myRdOnlyDriver.write(); } catch (MEDEXCEPTION& ex)
50 // { MESSAGE(ex.what()); }
51 MED_FIELD_WRONLY_DRIVER<double> myWrOnlyDriver(fileName2,myField);
52 myWrOnlyDriver.open();
53 //This test failed due to inadequate Support implementation
54 // myWrOnlyDriver.write();
55 // try myWrOnlyDriver.read(); catch (MEDEXCEPTION& ex)
56 // { MESSAGE(ex.what()); }
57 myRdOnlyDriver.close();
58 myWrOnlyDriver.close();
63 MESH * myMesh = new MESH();
64 MED_MESH_RDONLY_DRIVER myRdOnlyDriver(fileName,myMesh);
65 myRdOnlyDriver.setMeshName(meshName);
66 myRdOnlyDriver.open();
67 myRdOnlyDriver.read();
68 myRdOnlyDriver.close();
69 // try { myRdOnlyDriver.write(); } catch (MEDEXCEPTION& ex)
70 // { MESSAGE(ex.what()); }
71 MED_MESH_WRONLY_DRIVER myWrOnlyDriver(fileName2,myMesh);
72 myWrOnlyDriver.setMeshName(meshName);
73 myWrOnlyDriver.open();
74 myWrOnlyDriver.write();
75 // try myWrOnlyDriver.read(); catch (MEDEXCEPTION& ex)
76 // { MESSAGE(ex.what()); }
77 // myRdOnlyDriver.close();
78 //While we use H5close() in the MESH/FIELD drivers, the next
79 //line will fail, because all files are previously closed !
80 myWrOnlyDriver.close();
85 MED * myMed = new MED();
86 MED_MED_RDONLY_DRIVER myRdOnlyDriver(fileName,myMed);
87 myRdOnlyDriver.open();
88 myRdOnlyDriver.readFileStruct();
89 myRdOnlyDriver.close();
90 myMed->updateSupport(); // DOIT ETRE SUPPRIMEE
91 // myRdOnlyDriver.read();
92 // try { myRdOnlyDriver.write(); } catch (MEDEXCEPTION& ex)
93 // { MESSAGE(ex.what()); }
94 //MED_MED_WRONLY_DRIVER myWrOnlyDriver(fileName3,myMed);
95 //myWrOnlyDriver.open();
96 //myWrOnlyDriver.write(); // Not implemented yet.
97 //myWrOnlyDriver.close();
101 } catch (MEDEXCEPTION& ex){
102 cout << "MAIN BLOCK EXCEPTION" << endl;