3 #include "MEDMEM_PorflowMeshDriver.hxx"
4 #include "MEDMEM_Mesh.hxx"
5 using namespace MEDMEM;
6 int main (int argc, char ** argv)
8 /* process the arguments */
11 cerr << "Usage : " << argv[0]
12 << " Porflowfilename" << endl << endl
13 << "-> lit le fichier Porflowfilename ,crée 2 fichiers : MED et VTK" << endl;
16 string porflowfilename = argv[1];
18 // Construction des noms de fichier
19 const string ext=".inp";
20 string::size_type pos=porflowfilename.find(ext,0);
21 string basename (porflowfilename, 0, pos); // nom sans extension
22 string medfile=basename+".med"; // nom fichier med à creer
23 string vtkfile=basename+".vtk"; // nom fichier vtk à creer
24 string::size_type pos1=porflowfilename.rfind('/');
25 string meshName (porflowfilename,pos1+1,pos-pos1-1); //get rid of directory & extension
26 cout << meshName << endl;
28 // lecture du fichier porflow
29 MESH * myMesh= new MESH() ;
30 PORFLOW_MESH_RDONLY_DRIVER myPorflowMeshDriver(porflowfilename, myMesh) ;
31 myPorflowMeshDriver.open() ;
32 myPorflowMeshDriver.read() ;
33 myPorflowMeshDriver.close() ;
35 cout << "Impression de MESH : " << endl;
38 // creation d'un fichier med
39 cout << "creation d'un fichier med : " << endl;
40 int idMed = myMesh->addDriver(MED_DRIVER, medfile, meshName);
41 myMesh->write(idMed) ;
43 // creation d'un fichier vtk
44 cout << "creation d'un fichier vtk : " << endl;
45 int idVtk = myMesh->addDriver(VTK_DRIVER, vtkfile, meshName);
46 myMesh->write(idVtk) ;
49 int SpaceDimension = myMesh->getSpaceDimension() ;
50 int MeshDimension = myMesh->getMeshDimension() ;
51 int NumberOfNodes = myMesh->getNumberOfNodes() ;
53 cout << "Space Dimension : " << SpaceDimension << endl << endl ;
55 cout << "Mesh Dimension : " << MeshDimension << endl << endl ;
57 const double * Coordinates = myMesh->getCoordinates(MED_FULL_INTERLACE) ;
59 cout << "Show Nodes Coordinates : " << endl ;
61 cout << "Name :" << endl ;
62 const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
63 for(int i=0; i<SpaceDimension ; i++) {
64 cout << " - " << CoordinatesNames[i] << endl ;
66 cout << "Unit :" << endl ;
67 const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
68 for(int i=0; i<SpaceDimension ; i++) {
69 cout << " - " << CoordinatesUnits[i] << endl ;
71 for(int i=0; i<NumberOfNodes ; i++) {
72 cout << "Nodes " << i+1 << " : " ;
73 for (int j=0; j<SpaceDimension ; j++)
74 cout << Coordinates[i*SpaceDimension+j] << " " ;
78 cout << "The END" << endl;
81 // remontée du fichier med en mémoire
82 myMesh= new MESH(MED_DRIVER,medfile,meshName);