]> SALOME platform Git repositories - modules/med.git/blob - src/MEDOP/exe/image2med/image2med.py
Salome HOME
Merge from V6_main (04/10/2012)
[modules/med.git] / src / MEDOP / exe / image2med / image2med.py
1 #!/usr/bin/env python
2 #  -*- coding: iso-8859-1 -*-
3 #  Copyright (C) 2011  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
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.
9 #
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.
14 #
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
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21 # Author : Guillaume Boulant (EDF) 
22
23 from optparse import OptionParser
24 parser = OptionParser()
25 parser.add_option("-i", "--imagefile", dest="imagefile",
26                   help="image file to convert", metavar="FILE")
27 parser.add_option("-m", "--medfile", dest="medfile", default=None,
28                   help="output med file", metavar="FILE")
29 (options, args) = parser.parse_args()
30
31 import sys, os
32 if options.imagefile is None:
33     print "The image file must be specified"
34     sys.exit()
35 imagefile = options.imagefile
36 if not os.path.exists(imagefile):
37     print "The image file %s does not exists"%imagefile
38     sys.exit()
39
40 if options.medfile is None:
41     basename = os.path.basename(imagefile)
42     medfile = basename[0:len(basename)-3] + "med"
43 else:
44     medfile = options.medfile
45
46 print "Convert image file %s to a med field saved in %s"%(imagefile,medfile)
47 from xmedimages import FieldBuilder
48 builder = FieldBuilder()    
49 builder.image2med(imagefile,medfile)