added shebang script to make executable, some properties and few improvements. Now giving the bounding surfaces.
This commit is contained in:
parent
dc7a4bb978
commit
7e0c6f420b
|
@ -1,12 +1,16 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import re
|
import re
|
||||||
|
def all_same(items,a):
|
||||||
|
return all(x == a for x in items)
|
||||||
def func(seq):
|
def func(seq):
|
||||||
for x in seq:
|
for x in seq:
|
||||||
try:
|
try:
|
||||||
yield float(x)
|
yield float(x)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
yield x
|
yield x
|
||||||
|
|
||||||
my_geofile = 'polyXtal_5grains.geo'
|
my_geofile = 'polyXtal_5grains.geo'
|
||||||
PointCount = 0
|
PointCount = 0
|
||||||
|
@ -28,8 +32,8 @@ for eachline in lines:
|
||||||
r = re.compile('{(.*?)}')
|
r = re.compile('{(.*?)}')
|
||||||
m = r.search(eachline)
|
m = r.search(eachline)
|
||||||
if m:
|
if m:
|
||||||
a = m.group(1)
|
a = m.group(1)
|
||||||
point.append(list(func(a.split(","))))
|
point.append(list(func(a.split(","))))
|
||||||
|
|
||||||
|
|
||||||
elif eachline.startswith('Line (', 0, 6):
|
elif eachline.startswith('Line (', 0, 6):
|
||||||
|
@ -37,44 +41,70 @@ for eachline in lines:
|
||||||
r = re.compile('{(.*?)}')
|
r = re.compile('{(.*?)}')
|
||||||
m = r.search(eachline)
|
m = r.search(eachline)
|
||||||
if m:
|
if m:
|
||||||
a = m.group(1)
|
a = m.group(1)
|
||||||
line.append(list(func(a.split(","))))
|
line.append(list(func(a.split(","))))
|
||||||
|
|
||||||
elif eachline.startswith('Line Loop', 0, 9):
|
elif eachline.startswith('Line Loop', 0, 9):
|
||||||
LineLoopCount += 1
|
LineLoopCount += 1
|
||||||
r = re.compile('{(.*?)}')
|
r = re.compile('{(.*?)}')
|
||||||
m = r.search(eachline)
|
m = r.search(eachline)
|
||||||
if m:
|
if m:
|
||||||
a = m.group(1)
|
a = m.group(1)
|
||||||
lineloop.append(list(func(a.split(","))))
|
lineloop.append(list(func(a.split(","))))
|
||||||
|
|
||||||
elif eachline.startswith('Plane', 0, len(eachline)):
|
elif eachline.startswith('Plane', 0, len(eachline)):
|
||||||
PlaneSurfaceCount += 1
|
PlaneSurfaceCount += 1
|
||||||
r = re.compile('{(.*?)}')
|
r = re.compile('{(.*?)}')
|
||||||
m = r.search(eachline)
|
m = r.search(eachline)
|
||||||
if m:
|
if m:
|
||||||
a = m.group(1)
|
a = m.group(1)
|
||||||
plane.append(list(func(a.split(","))))
|
plane.append(list(func(a.split(","))))
|
||||||
|
|
||||||
elif eachline.startswith('Surface', 0,len(eachline)):
|
elif eachline.startswith('Surface', 0,len(eachline)):
|
||||||
SurfaceLoopCount += 1
|
SurfaceLoopCount += 1
|
||||||
r = re.compile('{(.*?)}')
|
r = re.compile('{(.*?)}')
|
||||||
m = r.search(eachline)
|
m = r.search(eachline)
|
||||||
if m:
|
if m:
|
||||||
a = m.group(1)
|
a = m.group(1)
|
||||||
surface.append(list(func(a.split(","))))
|
surface.append(list(func(a.split(","))))
|
||||||
|
x_coord = []
|
||||||
|
y_coord = []
|
||||||
|
z_coord = []
|
||||||
|
xp = []
|
||||||
|
xm = []
|
||||||
|
yp = []
|
||||||
|
ym = []
|
||||||
|
zp = []
|
||||||
|
zm = []
|
||||||
|
|
||||||
|
for i,l in enumerate(lineloop):
|
||||||
|
for lines in l:
|
||||||
|
for pts in line[int(abs(lines)-1)]:
|
||||||
|
x_coord.append(point[int(pts)-1][0])
|
||||||
|
y_coord.append(point[int(pts)-1][1])
|
||||||
|
z_coord.append(point[int(pts)-1][2])
|
||||||
|
|
||||||
|
if all_same(x_coord,1.):
|
||||||
|
xp.append(int(i+1))
|
||||||
|
elif all_same(x_coord,0.):
|
||||||
|
xm.append(int(i+1))
|
||||||
|
elif all_same(y_coord,1.):
|
||||||
|
yp.append(int(i+1))
|
||||||
|
elif all_same(y_coord,0.):
|
||||||
|
ym.append(int(i+1))
|
||||||
|
elif all_same(z_coord,1.):
|
||||||
|
zp.append(int(i+1))
|
||||||
|
elif all_same(z_coord,0.):
|
||||||
|
zm.append(int(i+1))
|
||||||
|
x_coord = []
|
||||||
|
y_coord = []
|
||||||
|
z_coord = []
|
||||||
|
|
||||||
|
print 'suraces on x + are ', xp
|
||||||
|
print 'suraces on x - are ', xm
|
||||||
|
print 'suraces on y + are ', yp
|
||||||
|
print 'suraces on y - are ', ym
|
||||||
|
print 'suraces on z + are ', zp
|
||||||
|
print 'suraces on z - are ', zm
|
||||||
|
|
||||||
|
|
||||||
print point
|
|
||||||
print line
|
|
||||||
print 'll'
|
|
||||||
print np.size(lineloop)
|
|
||||||
print lineloop
|
|
||||||
print 'ss'
|
|
||||||
print surface
|
|
||||||
|
|
||||||
#for sn, ll in enumerate(lineloop):
|
|
||||||
# for l in ll:
|
|
||||||
# for points in l[abs(int(l))]:
|
|
||||||
# if point[int(points)-1][0] == float(0):
|
|
||||||
# print 'abc'
|
|
||||||
|
|
Loading…
Reference in New Issue