try to go on despite crappy data (containing dead ends in the segment network)
This commit is contained in:
parent
77df55c998
commit
9d26bfa375
|
@ -9,7 +9,7 @@ scriptName = scriptID.split()[1]
|
||||||
|
|
||||||
|
|
||||||
try: # check for Python Image Lib
|
try: # check for Python Image Lib
|
||||||
import Image,ImageDraw
|
from PIL import Image,ImageDraw
|
||||||
ImageCapability = True
|
ImageCapability = True
|
||||||
except:
|
except:
|
||||||
ImageCapability = False
|
ImageCapability = False
|
||||||
|
@ -257,11 +257,10 @@ def rcbParser(content,M,size,tolerance,idcolumn,segmentcolumn): # parser for T
|
||||||
print "Dead end at segment %i (%f,%f)"%(1+point['segments'][0],boxX[0]+point['coords'][0]/scalePatch,boxY[0]+point['coords'][1]/scalePatch,)
|
print "Dead end at segment %i (%f,%f)"%(1+point['segments'][0],boxX[0]+point['coords'][0]/scalePatch,boxY[0]+point['coords'][1]/scalePatch,)
|
||||||
crappyData = True
|
crappyData = True
|
||||||
|
|
||||||
if crappyData:
|
|
||||||
sys.exit(-1)
|
|
||||||
|
|
||||||
grains = {'draw': [], 'legs': []}
|
grains = {'draw': [], 'legs': []}
|
||||||
|
|
||||||
|
if not crappyData:
|
||||||
|
|
||||||
for pointId,point in enumerate(points):
|
for pointId,point in enumerate(points):
|
||||||
while point['segments']:
|
while point['segments']:
|
||||||
myStart = pointId
|
myStart = pointId
|
||||||
|
@ -282,11 +281,8 @@ def rcbParser(content,M,size,tolerance,idcolumn,segmentcolumn): # parser for T
|
||||||
for peek in points[myEnd]['segments']: # trying in turn all segments emanating from current endPoint
|
for peek in points[myEnd]['segments']: # trying in turn all segments emanating from current endPoint
|
||||||
if peek == myWalk:
|
if peek == myWalk:
|
||||||
continue
|
continue
|
||||||
if segments[peek][0] == myEnd:
|
peekEnd = segments[peek][1] if segments[peek][0] == myEnd else segments[peek][0]
|
||||||
peekEnd = segments[peek][1]
|
peekV = [points[myEnd]['coords'][0]-points[peekEnd]['coords'][0],
|
||||||
else:
|
|
||||||
peekEnd = segments[peek][0]
|
|
||||||
peekV = [points[myEnd]['coords'][0]-points[peekEnd]['coords'][0],\
|
|
||||||
points[myEnd]['coords'][1]-points[peekEnd]['coords'][1]]
|
points[myEnd]['coords'][1]-points[peekEnd]['coords'][1]]
|
||||||
peekLen = math.sqrt(peekV[0]**2+peekV[1]**2)
|
peekLen = math.sqrt(peekV[0]**2+peekV[1]**2)
|
||||||
crossproduct = (myV[0]*peekV[1]-myV[1]*peekV[0])/myLen/peekLen
|
crossproduct = (myV[0]*peekV[1]-myV[1]*peekV[0])/myLen/peekLen
|
||||||
|
@ -344,7 +340,7 @@ def rcbParser(content,M,size,tolerance,idcolumn,segmentcolumn): # parser for T
|
||||||
|
|
||||||
print " found %i grains\n"%(len(rcData['grain']))
|
print " found %i grains\n"%(len(rcData['grain']))
|
||||||
|
|
||||||
rcData['box'] = grains['box']
|
rcData['box'] = grains['box'] if 'box' in grains else []
|
||||||
|
|
||||||
return rcData
|
return rcData
|
||||||
|
|
||||||
|
@ -858,12 +854,12 @@ parser.add_option("-M", "--coordtransformation", type="float", nargs=4, \
|
||||||
parser.add_option("--scatter", type="float",\
|
parser.add_option("--scatter", type="float",\
|
||||||
dest="scatter",\
|
dest="scatter",\
|
||||||
help="orientation scatter %default")
|
help="orientation scatter %default")
|
||||||
parser.add_option("--id", type="int",\
|
|
||||||
dest="idcolumn",\
|
|
||||||
help="column holding the right hand grain ID in the rcb file %default")
|
|
||||||
parser.add_option("--segment", type="int",\
|
parser.add_option("--segment", type="int",\
|
||||||
dest="segmentcolumn",\
|
dest="segmentcolumn",\
|
||||||
help="column holding the first entry for the segment end points in the rcb file %default")
|
help="column holding the first entry for the segment end points in the rcb file [%default]")
|
||||||
|
parser.add_option("--id", type="int",\
|
||||||
|
dest="idcolumn",\
|
||||||
|
help="column holding the right hand grain ID in the rcb file [%default]")
|
||||||
|
|
||||||
parser.set_defaults(output = [])
|
parser.set_defaults(output = [])
|
||||||
parser.set_defaults(size = 1.0)
|
parser.set_defaults(size = 1.0)
|
||||||
|
@ -881,8 +877,8 @@ parser.set_defaults(strainrate = 1.0e-3)
|
||||||
parser.set_defaults(increments = 200)
|
parser.set_defaults(increments = 200)
|
||||||
parser.set_defaults(mesh = 'dt_planar_trimesh')
|
parser.set_defaults(mesh = 'dt_planar_trimesh')
|
||||||
parser.set_defaults(twoD = False)
|
parser.set_defaults(twoD = False)
|
||||||
parser.set_defaults(idcolumn = 13)
|
|
||||||
parser.set_defaults(segmentcolumn = 9)
|
parser.set_defaults(segmentcolumn = 9)
|
||||||
|
parser.set_defaults(idcolumn = 13)
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue