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 using namespace MEDMEM;
16 void usage(char * name)
18 cout << " " << name << " <input med file> <output vtk file> " <<endl ;
19 cout << " " << "(the two file name are mandatory)" << endl ;
23 int main (int argc, char ** argv) {
25 if (argc != 3) usage(argv[0]);
27 string filenameIN = argv[1] ;
28 string filenameOUT = argv[2] ;
31 /////////////////////////////////////////////////
32 // we read all meshes and fields in filenameIN //
33 /////////////////////////////////////////////////
34 MED myMed(MED_DRIVER,filenameIN) ;
39 cout << "Read all meshes " ;
40 int NumberOfMeshes = myMed.getNumberOfMeshes() ;
41 cout << "( "<<NumberOfMeshes << " ) :" << endl ;
42 deque<string> MeshName = myMed.getMeshNames() ;
43 for (int i=0; i<NumberOfMeshes; i++) {
44 myMed.getMesh(MeshName[i])->read() ;
45 cout << " - Mesh "<<i+1<<", named "<<MeshName[i]<<" is read !" << endl;
51 // set support : support must be calculated with mesh information !!!
52 myMed.updateSupport() ;
57 cout << "Read all fields " ;
58 int NumberOfFields = myMed.getNumberOfFields() ;
59 cout << "( "<<NumberOfFields << " ) :" << endl;
60 deque<string> FieldName = myMed.getFieldNames() ;
61 for (int i=0; i<NumberOfFields; i++) {
62 deque<DT_IT_> FieldIteration = myMed.getFieldIteration(FieldName[i]) ;
63 cout << " - Field "<<i+1<<", named "<<FieldName[i] << " :" << endl ;
64 int NumberOfIteration = FieldIteration.size() ;
65 cout << " Number of iteration pair : "<< NumberOfIteration << endl;
66 for (int j=0; j<NumberOfIteration; j++) {
67 FIELD_ * myField = myMed.getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it) ;
70 cout << " * Iteration "<<FieldIteration[j].dt<<" and order number "<<FieldIteration[j].it<<" ) is read !" << endl;
74 //////////////////////////////////////////
75 // we write all in VTK file filenameOUT //
76 /////////////////////////////////////////
77 int id = myMed.addDriver(VTK_DRIVER,filenameOUT) ;
81 catch (MEDEXCEPTION& ex){
82 cout << ex.what() << endl ;