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