2 # Copyright (C) 2011-2016 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Guillaume Boulant (EDF)
22 from argparse import ArgumentParser
23 parser = ArgumentParser()
24 parser.add_agument("-i", "--imagefile", dest="imagefile",
25 help="image file to convert", metavar="FILE")
26 parser.add_agument("-m", "--medfile", dest="medfile", default=None,
27 help="output med file", metavar="FILE")
28 args = parser.parse_args()
31 if args.imagefile is None:
32 print("The image file must be specified")
34 imagefile = args.imagefile
35 if not os.path.exists(imagefile):
36 print("The image file %s does not exists"%imagefile)
39 if args.medfile is None:
40 basename = os.path.basename(imagefile)
41 medfile = basename[0:len(basename)-3] + "med"
43 medfile = args.medfile
45 print("Convert image file %s to a med field saved in %s"%(imagefile,medfile))
46 from xmedimages import FieldBuilder
47 builder = FieldBuilder()
48 builder.image2med(imagefile,medfile)