1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 #include "MEDMEM_Exception.hxx"
27 #include "MEDMEM_define.hxx"
29 #include "MEDMEM_Mesh.hxx"
30 #include "MEDMEM_Grid.hxx"
31 #include "MEDMEM_Family.hxx"
32 #include "MEDMEM_Support.hxx"
34 #include "MEDMEM_GenDriver.hxx"
35 #include "MEDMEM_MedMeshDriver.hxx"
36 #include "MEDMEM_MedFileBrowser.hxx"
39 using namespace MEDMEM;
40 int main (int argc, char ** argv)
43 cout << "Usage: " << argv[0] << "<input med file> <output med file>" << endl;
46 string filenameIN = argv[1] ;
47 string filenameOUT = argv[2] ;
49 MEDFILEBROWSER myMed(filenameIN);
51 // we read all meshes in filenameIN
55 MESSAGE_MED("Read all meshes :") ;
56 int NumberOfMeshes = myMed.getNumberOfMeshes() ;
57 MESSAGE_MED("Number of meshes : "<<NumberOfMeshes) ;
58 vector<string> meshNames = myMed.getMeshNames() ;
59 for (int i=0; i<NumberOfMeshes; i++)
61 GMESH* mesh = myMed.isStructuredMesh( meshNames[i] ) ? (GMESH*) new GRID : (GMESH*) new MESH;
62 int drv = mesh->addDriver(MED_DRIVER, filenameIN, meshNames[i] );
64 MESSAGE_MED(" - Mesh "<<i+1<<", named "<<meshNames[i]<<" read !");
65 MED_MESH_WRONLY_DRIVER myMeshDriver(filenameOUT,mesh);
66 MESSAGE_MED("After declaration of MED_MESH_DRIVER");
67 myMeshDriver.setMeshName(meshNames[i]);
68 MESSAGE_MED("After setMeshName");
70 MESSAGE_MED("After open");
71 myMeshDriver.write() ;
72 MESSAGE_MED("After write");
73 myMeshDriver.close() ;
74 MESSAGE_MED("After close");
75 mesh->removeReference();
78 } catch (MEDEXCEPTION& ex){
79 MESSAGE_MED(ex.what()) ;