polishing vtk2ang.py
This commit is contained in:
parent
e6f1b17149
commit
4bf3b92609
|
@ -18,47 +18,43 @@ scriptID = ' '.join([scriptName,damask.version])
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def getHeader(filename,sizeFastIndex,sizeSlowIndex,stepsize):
|
def getHeader(filename,sizeFastIndex,sizeSlowIndex,stepsize):
|
||||||
"""Returns header for ang file step size in micrometer."""
|
"""Returns header for ang file step size in micrometer."""
|
||||||
return '\n'.join([ \
|
return '\n'.join([
|
||||||
'# TEM_PIXperUM 1.000000', \
|
'# TEM_PIXperUM 1.000000',
|
||||||
'# x-star 1.000000', \
|
'# x-star 1.000000',
|
||||||
'# y-star 1.000000', \
|
'# y-star 1.000000',
|
||||||
'# z-star 1.000000', \
|
'# z-star 1.000000',
|
||||||
'# WorkingDistance 18.000000', \
|
'# WorkingDistance 18.000000',
|
||||||
'#', \
|
'#',
|
||||||
'# Phase 1', \
|
'# Phase 1',
|
||||||
'# MaterialName XX', \
|
'# MaterialName XX',
|
||||||
'# Formula XX', \
|
'# Formula XX',
|
||||||
'# Info', \
|
'# Info',
|
||||||
'# Symmetry 43', \
|
'# Symmetry 43',
|
||||||
'# LatticeConstants 2.870 2.870 2.870 90.000 90.000 90.000', \
|
'# LatticeConstants 2.870 2.870 2.870 90.000 90.000 90.000',
|
||||||
'# NumberFamilies 1', \
|
'# NumberFamilies 1',
|
||||||
'# hklFamilies 1 1 0 1 0.000000 1', \
|
'# hklFamilies 1 1 0 1 0.000000 1',
|
||||||
'# Categories 0 0 0 0 0 ', \
|
'# Categories 0 0 0 0 0 ',
|
||||||
'#', \
|
'#',
|
||||||
'# GRID: SqrGrid', \
|
'# GRID: SqrGrid',
|
||||||
'# XSTEP: ' + str(stepsize*1e6), \
|
'# XSTEP: ' + str(stepsize*1e6),
|
||||||
'# YSTEP: ' + str(stepsize*1e6), \
|
'# YSTEP: ' + str(stepsize*1e6),
|
||||||
'# NCOLS_ODD: ' + str(sizeFastIndex), \
|
'# NCOLS_ODD: ' + str(sizeFastIndex),
|
||||||
'# NCOLS_EVEN: ' + str(sizeFastIndex), \
|
'# NCOLS_EVEN: ' + str(sizeFastIndex),
|
||||||
'# NROWS: ' + str(sizeSlowIndex), \
|
'# NROWS: ' + str(sizeSlowIndex),
|
||||||
'#', \
|
'#',
|
||||||
'# OPERATOR: ' + string.replace('$Id$','\n','\\n'), \
|
'# OPERATOR: ' + string.replace('$Id$','\n','\\n'),
|
||||||
'#', \
|
'#',
|
||||||
'# SAMPLEID: %s'%filename, \
|
'# SAMPLEID: {}'.format(filename),
|
||||||
'#', \
|
'#',
|
||||||
'# SCANID: ', \
|
'# SCANID: ',
|
||||||
'#', \
|
'#',
|
||||||
]) + '\n'
|
]) + '\n'
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def positiveRadians(angle):
|
def positiveRadians(angle):
|
||||||
"""Returns positive angle in radians from angle in degrees."""
|
"""Returns positive angle in radians from angle in degrees."""
|
||||||
angle = math.radians(float(angle))
|
return math.radians(float(angle)) % (2.*math.pi)
|
||||||
while angle < 0.0:
|
|
||||||
angle += 2.0 * math.pi
|
|
||||||
|
|
||||||
return angle
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
@ -230,11 +226,11 @@ for filename in filenames:
|
||||||
# Get bounding box in rotated system (x,y,z)
|
# Get bounding box in rotated system (x,y,z)
|
||||||
|
|
||||||
if options.verbose: sys.stdout.write("\nGETTING BOUNDING BOX IN ROTATED SYSTEM\n")
|
if options.verbose: sys.stdout.write("\nGETTING BOUNDING BOX IN ROTATED SYSTEM\n")
|
||||||
rotatedbox = [[np.inf,-np.inf] for i in range(3)] # bounding box in rotated TSL system
|
rotatedbox = [[np.inf,-np.inf] for i in range(3)] # bounding box in rotated TSL system
|
||||||
for n in range(8): # loop over eight vertices of mesh bounding box
|
for n in range(8): # loop over eight vertices of mesh bounding box
|
||||||
vert = np.array([box[0+(n//1)%2],
|
vert = np.array([box[0+(n//1)%2],
|
||||||
box[2+(n//2)%2],
|
box[2+(n//2)%2],
|
||||||
box[4+(n//4)%2]]) # vertex in mesh system
|
box[4+(n//4)%2]]) # vertex in mesh system
|
||||||
rotatedvert = np.dot(R,vert) # vertex in rotated system
|
rotatedvert = np.dot(R,vert) # vertex in rotated system
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
rotatedbox[i][0] = min(rotatedbox[i][0],rotatedvert[i])
|
rotatedbox[i][0] = min(rotatedbox[i][0],rotatedvert[i])
|
||||||
|
|
Loading…
Reference in New Issue