1 #include "MEDMEM_PorflowMeshDriver.hxx"
2 #include "MEDMEM_Mesh.hxx"
5 #include "LocalTraceCollector.hxx"
6 #endif /* ifdef _DEBUG_*/
9 using namespace MEDMEM;
10 using namespace MED_EN;
12 int main (int argc, char ** argv)
14 /* process the arguments */
17 cerr << "Usage : " << argv[0]
18 << " Porflowfilename" << endl << endl
19 << "-> lit le fichier Porflowfilename ,crée 2 fichiers : MED et VTK" << endl;
24 LocalTraceCollector::instance();
25 #endif /* ifdef _DEBUG_*/
27 string porflowfilename = argv[1];
29 // Construction des noms de fichier
30 const string ext=".inp";
31 string::size_type pos=porflowfilename.find(ext,0);
32 string basename (porflowfilename, 0, pos); // nom sans extension
33 string medfile=basename+".med"; // nom fichier med à creer
34 string vtkfile=basename+".vtk"; // nom fichier vtk à creer
35 string::size_type pos1=porflowfilename.rfind('/');
36 string meshName (porflowfilename,pos1+1,pos-pos1-1); //get rid of directory & extension
37 cout << meshName << endl;
39 // lecture du fichier porflow
40 MESH * myMesh= new MESH() ;
41 PORFLOW_MESH_RDONLY_DRIVER myPorflowMeshDriver(porflowfilename, myMesh) ;
42 myPorflowMeshDriver.open() ;
43 myPorflowMeshDriver.read() ;
44 myPorflowMeshDriver.close() ;
46 cout << "Impression de MESH : " << endl;
49 // creation d'un fichier med
50 cout << "creation d'un fichier med : " << endl;
51 int idMed = myMesh->addDriver(MED_DRIVER, medfile, meshName);
52 myMesh->write(idMed) ;
54 // creation d'un fichier vtk
55 cout << "creation d'un fichier vtk : " << endl;
56 int idVtk = myMesh->addDriver(VTK_DRIVER, vtkfile, meshName);
57 myMesh->write(idVtk) ;
60 int SpaceDimension = myMesh->getSpaceDimension() ;
61 int MeshDimension = myMesh->getMeshDimension() ;
62 int NumberOfNodes = myMesh->getNumberOfNodes() ;
64 cout << "Space Dimension : " << SpaceDimension << endl << endl ;
66 cout << "Mesh Dimension : " << MeshDimension << endl << endl ;
68 const double * Coordinates = myMesh->getCoordinates(MED_FULL_INTERLACE) ;
70 cout << "Show Nodes Coordinates : " << endl ;
72 cout << "Name :" << endl ;
73 const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
74 for(int i=0; i<SpaceDimension ; i++) {
75 cout << " - " << CoordinatesNames[i] << endl ;
77 cout << "Unit :" << endl ;
78 const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
79 for(int i=0; i<SpaceDimension ; i++) {
80 cout << " - " << CoordinatesUnits[i] << endl ;
82 for(int i=0; i<NumberOfNodes ; i++) {
83 cout << "Nodes " << i+1 << " : " ;
84 for (int j=0; j<SpaceDimension ; j++)
85 cout << Coordinates[i*SpaceDimension+j] << " " ;
89 cout << "The END" << endl;
92 // remontée du fichier med en mémoire
93 myMesh= new MESH(MED_DRIVER,medfile,meshName);