Back to index

salome-med  6.5.0
test_gibi_driver.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 #include "MEDMEM_GibiMeshDriver.hxx"
00023 #include "MEDMEM_Mesh.hxx"
00024 #include "MEDMEM_DriverFactory.hxx"
00025 
00026 using namespace std;
00027 using namespace MEDMEM;
00028 using namespace MED_EN;
00029 using namespace DRIVERFACTORY;
00030 
00031 int main (int argc, char ** argv)
00032 {
00033     /* process the arguments */
00034     if (argc != 2) 
00035     {
00036         cerr << "Usage : " << argv[0] 
00037         << " Gibifilename" << endl << endl
00038         << "-> lit le fichier gibi filename ,crée 2 fichiers : MED et VTK" << endl;
00039         exit(-1);
00040     }
00041 
00042     string gibifilename  = argv[1];
00043 
00044     // Construction des noms de fichier
00045     const string ext=".sauve";
00046     string::size_type pos=gibifilename.find(ext,0);
00047     string basename (gibifilename, 0, pos); // nom sans extension
00048     string medfile21=basename+"_V21.med"; // nom fichier med 2.1 à creer
00049     string medfile22=basename+"_V22.med"; // nom fichier med 2.2 à creer
00050     string vtkfile=basename+".vtk"; // nom fichier vtk à creer
00051     string::size_type pos1=gibifilename.rfind('/');
00052     string meshName (gibifilename,pos1+1,pos-pos1-1); // get rid of directory & extension
00053     cout << meshName << endl;
00054 
00055     // lecture du fichier gibi
00056     // MESH * myMesh= new MESH(GIBI_DRIVER,gibifilename);
00057     MESH * myMesh= new MESH; 
00058     GIBI_MESH_RDONLY_DRIVER myGibiMeshDriver(gibifilename, myMesh) ;
00059     myGibiMeshDriver.open() ;
00060     myGibiMeshDriver.read() ;
00061     myGibiMeshDriver.close() ;
00062 
00063     cout << "Impression de MESH : " << endl;
00064     cout << *myMesh;
00065 
00066     cout << "creation du fichier med 22 : " << endl;
00067     int idMed22 = myMesh->addDriver(MED_DRIVER, medfile22, meshName);
00068     myMesh->write(idMed22) ;
00069 
00070     // creation d'un fichier vtk
00071     cout << "creation d'un fichier vtk : " << endl;
00072     int idVtk = myMesh->addDriver(VTK_DRIVER, vtkfile, meshName);
00073     myMesh->write(idVtk) ;
00074     myMesh->removeReference();
00075 
00076     // remontée mémoire du fichier med 22
00077     myMesh= new MESH(MED_DRIVER,medfile22,meshName);
00078 
00079     myMesh->removeReference();
00080 }