added some warnings if Mentat or PIL cabability missing

This commit is contained in:
Philip Eisenlohr 2011-08-18 07:52:07 +00:00
parent ff3bac2496
commit 164da22730
1 changed files with 56 additions and 46 deletions

View File

@ -3,14 +3,14 @@
import sys,os,math,re
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
try:
try: # check for Python Image Lib
import Image,ImageDraw
ImageCapability = True
except:
ImageCapability = False
try:
try: # check for MSC.Mentat installation location
file = open('%s/../MSCpath'%os.path.dirname(os.path.realpath(sys.argv[0])))
MSCpath = os.path.normpath(file.readline().strip())
file.close()
@ -32,7 +32,7 @@ for release,subdirs in sorted(releases.items(),reverse=True):
continue
break
try:
try: # check for MSC.Mentat Python interface
from py_mentat import *
MentatCapability = True
except:
@ -309,7 +309,7 @@ def rcbParser(content,M,size,tolerance): # parser for TSL-O
for point in points:
rcData['point'].append(point['coords'])
print "\nfound %i points"%(len(rcData['point']))
print " found %i points"%(len(rcData['point']))
for segment in segments:
rcData['segment'].append(segment)
@ -791,11 +791,14 @@ def fftbuild(rcData, height,xframe,yframe,resolution,extrusion): # bu
# ----------------------- MAIN -------------------------------
parser = OptionParser(option_class=extendedOption, usage='%prog [options] datafile[s]', description = """
what I do...
""")
Produce image, spectral geometry description, and (auto) Mentat procedure from TSL/OIM
reconstructed boundary file
""" + string.replace('$Id: spectral_iterationCount 919 2011-06-15 18:14:05Z MPIE\p.eisenlohr $','\n','\\n')
)
parser.add_option("-o", "--output", action='extend', dest='output', type='string', \
help="type of output [image,mentat,procedure,spectral]")
help="types of output [image,mentat,procedure,spectral]")
parser.add_option("-p", "--port", type="int",\
dest="port",\
help="Mentat connection port")
@ -859,6 +862,7 @@ parser.set_defaults(mesh = 'dt_planar_trimesh')
parser.set_defaults(twoD = False)
(options, args) = parser.parse_args()
if not len(args):
parser.error('no boundary file specified')
@ -873,15 +877,18 @@ except:
options.output = [s.lower() for s in options.output] # lower case
myName = os.path.splitext(args[0])[0]
print "\n",myName
print "\n%s\n"%myName
orientationData = rcbOrientationParser(boundarySegments)
rcData = rcbParser(boundarySegments,options.M,options.size,options.tolerance)
# ----- write image -----
if ImageCapability and 'image' in options.output and options.imgsize > 0:
if 'image' in options.output and options.imgsize > 0:
if ImageCapability:
image(myName,options.imgsize,options.xmargin,options.ymargin,rcData)
else:
print '...no image drawing possible (PIL missing)...'
# ----- write spectral geom -----
@ -895,12 +902,13 @@ if 'spectral' in options.output:
geomFile.write('\n'.join(map(str,fftdata['fftpoints']))+'\n') # write grain indexes, one per line
geomFile.close() # close geom file
print('assigned %i out of %i Fourier points'%(len(fftdata['fftpoints']), int(fftdata['resolution'][0])*int(fftdata['resolution'][1])))
print('assigned %i out of %i Fourier points.'%(len(fftdata['fftpoints']), int(fftdata['resolution'][0])*int(fftdata['resolution'][1])))
# ----- write Mentat procedure -----
if MentatCapability and 'mentat' in options.output:
if 'mentat' in options.output:
if MentatCapability:
rcData['offsetPoints'] = 1+4 # gage definition generates 4 points
rcData['offsetSegments'] = 1+4 # gage definition generates 4 segments
@ -933,6 +941,8 @@ if MentatCapability and 'mentat' in options.output:
py_disconnect()
if 'procedure' in options.output:
output(outputLocals['log'],outputLocals,'Stdout')
else:
print '...no interaction with Mentat possible...'
# ----- write config data to file -----