Back to index

salome-med  6.5.0
testDriverAscii.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 from libMEDMEM_Swig import *
00025 
00026 import os
00027 
00028 #
00029 #before running this script, please be sure about the path the file fileName
00030 #
00031 
00032 filePath=os.environ["MED_ROOT_DIR"]
00033 filePath=os.path.join(filePath, "share", "salome", "resources", "med")
00034 
00035 medFile = os.path.join(filePath, "test_2D.med")
00036 
00037 asciiFile = "tyst.txt"
00038 
00039 md=MEDFILEBROWSER(medFile)
00040 
00041 nbMeshes = md.getNumberOfMeshes()
00042 
00043 nbFields = md.getNumberOfFields()
00044 
00045 print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)"
00046 f1Name=md.getFieldName(0)
00047 mesh_name=md.getMeshName(f1Name)
00048 mesh=MESH(MED_DRIVER,medFile,mesh_name)
00049 it=md.getFieldIteration(f1Name)[0]
00050 f1=FIELDDOUBLE(MED_DRIVER,medFile,f1Name,it.dt,it.it,mesh)
00051 id2=f1.addDriver(ASCII_DRIVER,asciiFile,"Default Field Name",MED_ECRI)
00052 f1.write(id2)
00053 
00054 print "END of the Pyhton script ..... Ctrl D to exit"