4 #include "MEDMEM_Exception.hxx"
5 #include "MEDMEM_define.hxx"
7 #include "MEDMEM_Med.hxx"
8 #include "MEDMEM_Mesh.hxx"
9 #include "MEDMEM_Family.hxx"
10 #include "MEDMEM_Support.hxx"
11 #include "MEDMEM_Field.hxx"
12 #include "MEDMEM_VtkMedDriver.hxx"
15 #include "LocalTraceCollector.hxx"
16 #endif /* ifdef _DEBUG_*/
19 using namespace MEDMEM;
20 void usage(char * name)
22 cout << " " << name << " <input med file> <output vtk file> " <<endl ;
23 cout << " " << "(the two file name are mandatory)" << endl ;
27 int main (int argc, char ** argv) {
29 LocalTraceCollector::instance();
30 #endif /* ifdef _DEBUG_*/
32 if (argc != 3) usage(argv[0]);
34 string filenameIN = argv[1] ;
35 string filenameOUT = argv[2] ;
38 /////////////////////////////////////////////////
39 // we read all meshes and fields in filenameIN //
40 /////////////////////////////////////////////////
41 MED myMed(MED_DRIVER,filenameIN) ;
46 cout << "Read all meshes " ;
47 int NumberOfMeshes = myMed.getNumberOfMeshes() ;
48 cout << "( "<<NumberOfMeshes << " ) :" << endl ;
49 deque<string> MeshName = myMed.getMeshNames() ;
50 for (int i=0; i<NumberOfMeshes; i++) {
51 myMed.getMesh(MeshName[i])->read() ;
52 cout << " - Mesh "<<i+1<<", named "<<MeshName[i]<<" is read !" << endl;
58 // set support : support must be calculated with mesh information !!!
59 myMed.updateSupport() ;
64 cout << "Read all fields " ;
65 int NumberOfFields = myMed.getNumberOfFields() ;
66 cout << "( "<<NumberOfFields << " ) :" << endl;
67 deque<string> FieldName = myMed.getFieldNames() ;
68 for (int i=0; i<NumberOfFields; i++) {
69 deque<DT_IT_> FieldIteration = myMed.getFieldIteration(FieldName[i]) ;
70 cout << " - Field "<<i+1<<", named "<<FieldName[i] << " :" << endl ;
71 int NumberOfIteration = FieldIteration.size() ;
72 cout << " Number of iteration pair : "<< NumberOfIteration << endl;
73 for (int j=0; j<NumberOfIteration; j++) {
74 FIELD_ * myField = myMed.getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it) ;
77 cout << " * Iteration "<<FieldIteration[j].dt<<" and order number "<<FieldIteration[j].it<<" ) is read !" << endl;
81 //////////////////////////////////////////
82 // we write all in VTK file filenameOUT //
83 /////////////////////////////////////////
84 int id = myMed.addDriver(VTK_DRIVER,filenameOUT) ;
88 catch (MEDEXCEPTION& ex){
89 cout << ex.what() << endl ;