1 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2009-2013 CEA/DEN, EDF R&D, OPEN CASCADE
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Erwan ADAM (CEA), Anthony GEAY (CEA)
24 from MEDLoader import *
26 def convert(file_in, driver_in, driver_out, format=1, file_out=None):
32 if driver_out == "GIBI":
34 elif driver_out == "MED":
37 msg = "Driver out %s is unknown"%(driver_out)
38 raise NotImplementedError(msg)
42 if driver_in == "GIBI":
43 sr = SauvReader.New(file_in)
44 mfd= sr.loadInMEDFileDS()
46 elif driver_in == "MED":
47 mfd = MEDFileData(file_in)
50 raise NotImplementedError("Driver in %s is unknown"%(driver_in))
54 if driver_out == "GIBI":
56 sw.setMEDFileDS(mfd,0);#0 ?
60 from sys import platform
61 if platform in ["win32"]:
65 content = content.replace("IFOUR -1", "IFOUR 2")
66 content = content.replace("IFOMOD -1", "IFOMOD 2")
67 f = open(file_out, "w")
72 cmd += ' -e "s/IFOUR -1/IFOUR 2/g"'
73 cmd += ' -e "s/IFOMOD -1/IFOMOD 2/g"'
74 # cmd += ' -e "s/IECHO 1/IECHO 0/g"'
75 cmd += ' %s > .dummy'%(file_out)
77 cmd += ' mv -f .dummy %s'%(file_out)
84 from castemlauncher import CastemLauncher
86 dgibi_stream += "OPTI REST FORMAT '%s' ;\n"%(file_out)
87 dgibi_stream += "REST FORMAT;\n"
88 file_out = file_out.replace('__format__', '')
89 dgibi_stream += "OPTI SAUV '%s' ;\n"%(file_out)
90 dgibi_stream += "SAUV ;\n"
91 cl = CastemLauncher(dgibi_stream)
92 cl.addTmpFiles(file_out+'__format__', "UTILNOTI", "UTILPROC")
96 elif driver_out == "MED":
100 raise NotImplementedError("Driver in %s is unknown"%(driver_in))
105 convert(arg, "GIBI", "MED")
113 if arg.find('--format') == 0:
116 value = arg.split("=")[1]
129 convert(arg, "MED", "GIBI", format)