4 #include "MEDMEM_MedMedDriver.hxx"
5 #include "MEDMEM_Med.hxx"
6 #include "MEDMEM_MedMeshDriver.hxx"
7 #include "MEDMEM_Mesh.hxx"
8 #include "MEDMEM_Field.hxx"
9 #include "MEDMEM_DriverFactory.hxx"
12 using namespace MEDMEM;
13 using namespace MED_EN;
15 int main(int argc, char *argv[])
19 cerr << "Usage : " << argv[0]
20 << " fileName.med where fileName.med should be a med file" << endl;
21 cerr << " It will then generate two med files fileNameAnal_V21.med (med V2.1 format)" << endl;
22 cerr << "and fileNameAnal_V21.med (med V2.2 format)" << endl << endl;
27 // This test program is more or less designed to work with file TimeStamps.med
28 // If you want to use it for other Med files, you have to alter the mounting in memory of the fields f1 and f2
29 //string fileIn="/export/home/geay32/SALOME225/KERNEL_SRC/examples/TimeStamps.med";
31 string fileIn = argv[1] ;
32 const string ext=".med";
33 string::size_type pos=fileIn.find(ext,0);
34 string baseName (fileIn, 0, pos); // nom sans extension
35 string fileOut21=baseName + "Anal_V21.med";
36 string fileOut22=baseName + "Anal_V22.med";
39 MED_MED_RDONLY_DRIVER *driverIn=new MED_MED_RDONLY_DRIVER(fileIn,myMed);
41 driverIn->readFileStruct();
43 int nbOfMeshes=myMed->getNumberOfMeshes();
44 int nbOfFields=myMed->getNumberOfFields();
45 cout << nbOfMeshes << " --- " << nbOfFields << endl;
46 deque<string> names=myMed->getMeshNames();
47 for(i=0;i<nbOfMeshes;i++)
48 cout << names[i] << endl;
49 cout << "************* " << endl;
50 deque<string> names2=myMed->getFieldNames();
51 for(i=0;i<nbOfFields;i++)
52 cout << names2[i] << endl;
53 MESH *mesh=myMed->getMesh(names[0]);
55 myMed->updateSupport();
56 deque<DT_IT_> iterations=myMed->getFieldIteration(names2[2]);
57 cout << iterations.size() << endl;
58 FIELD_ *f1=myMed->getField(names2[2],iterations[0].dt,iterations[0].it);
59 FIELD_ *f2=myMed->getField(names2[2],iterations[1].dt,iterations[1].it);
60 FIELD<double> *f1s=(FIELD<double> *)f1;
62 FIELD<double> *f2s=(FIELD<double> *)f2;
64 DRIVERFACTORY::setMedFileVersionForWriting(V21);
65 int id=mesh->addDriver(MED_DRIVER,fileOut21,mesh->getName());
67 id=f1s->addDriver(MED_DRIVER, fileOut21, f1s->getName());
69 id=f2s->addDriver(MED_DRIVER, fileOut21, f2s->getName());
72 DRIVERFACTORY::setMedFileVersionForWriting(V22);
73 id=mesh->addDriver(MED_DRIVER,fileOut22,mesh->getName());
75 id=f1s->addDriver(MED_DRIVER, fileOut22, f1s->getName());
77 id=f2s->addDriver(MED_DRIVER, fileOut22, f2s->getName());