5 #include "MEDMEM_Exception.hxx"
6 #include "MEDMEM_define.hxx"
8 #include "MEDMEM_Med.hxx"
9 #include "MEDMEM_Mesh.hxx"
10 #include "MEDMEM_Family.hxx"
11 #include "MEDMEM_Support.hxx"
12 #include "MEDMEM_Field.hxx"
13 #include "MEDMEM_VtkMedDriver.hxx"
15 void usage(char * name)
17 cout << " " << name << " <input med file> <output vtk file> " <<endl ;
18 cout << " " << "(the two file name are mandatory)" << endl ;
22 int main (int argc, char ** argv) {
24 if (argc != 3) usage(argv[0]);
26 string filenameIN = argv[1] ;
27 string filenameOUT = argv[2] ;
30 /////////////////////////////////////////////////
31 // we read all meshes and fields in filenameIN //
32 /////////////////////////////////////////////////
33 MED myMed(MED_DRIVER,filenameIN) ;
38 cout << "Read all meshes " ;
39 int NumberOfMeshes = myMed.getNumberOfMeshes() ;
40 cout << "( "<<NumberOfMeshes << " ) :" << endl ;
41 deque<string> MeshName = myMed.getMeshNames() ;
42 for (int i=0; i<NumberOfMeshes; i++) {
43 myMed.getMesh(MeshName[i])->read() ;
44 cout << " - Mesh "<<i+1<<", named "<<MeshName[i]<<" is read !" << endl;
50 // set support : support must be calculated with mesh information !!!
51 myMed.updateSupport() ;
56 cout << "Read all fields " ;
57 int NumberOfFields = myMed.getNumberOfFields() ;
58 cout << "( "<<NumberOfFields << " ) :" << endl;
59 deque<string> FieldName = myMed.getFieldNames() ;
60 for (int i=0; i<NumberOfFields; i++) {
61 deque<DT_IT_> FieldIteration = myMed.getFieldIteration(FieldName[i]) ;
62 cout << " - Field "<<i+1<<", named "<<FieldName[i] << " :" << endl ;
63 int NumberOfIteration = FieldIteration.size() ;
64 cout << " Number of iteration pair : "<< NumberOfIteration << endl;
65 for (int j=0; j<NumberOfIteration; j++) {
66 FIELD_ * myField = myMed.getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it) ;
69 cout << " * Iteration "<<FieldIteration[j].dt<<" and order number "<<FieldIteration[j].it<<" ) is read !" << endl;
73 //////////////////////////////////////////
74 // we write all in VTK file filenameOUT //
75 /////////////////////////////////////////
76 int id = myMed.addDriver(VTK_DRIVER,filenameOUT) ;
80 catch (MEDEXCEPTION& ex){
81 cout << ex.what() << endl ;