- Bugfix: sometimes ( not very often ) sortChunks would end up in an infinite loop.

There is a bug in the way chunks are sorted.  Did not find the source of
the problem but found a temporary solution which is to not to sort the
remainding chunks.  Looks like its at the most 3 chunks that don't get
sorted based on the test cases tried.  Only seems to happen on
complicated patterns.
pull/10/head
Jeff Doyle (nfz) 2015-12-19 18:16:31 -04:00
rodzic 7c4882d90c
commit 24f3e0938d
1 zmienionych plików z 18 dodań i 6 usunięć

Wyświetl plik

@ -1564,15 +1564,27 @@ def sortChunks(chunks,o):
ch = getClosest(o,pos,chunks) ch = getClosest(o,pos,chunks)
# break # break
#pass; #pass;
if ch!=None:#found next chunk, append it to list if ch is not None:#found next chunk, append it to list
ch.sorted=True ch.sorted = True
ch.adaptdist(pos,o) ch.adaptdist(pos, o)
print(ch) print(ch)
chunks.remove(ch) chunks.remove(ch)
sortedchunks.append(ch) sortedchunks.append(ch)
lastch=ch lastch = ch
pos=lastch.points[-1] pos = lastch.points[-1]
i-=1 else:
# can't find chunks close enough and still some chunks left
# to be sorted. For now just move the remaining chunks over to
# the sorted list.
# This fixes an infinite loop condition that occurs sometimes.
# This is a bandaid fix: need to find the root cause of this problem
# suspect it has to do with the sorted flag?
print("no chunks found closest. Chunks not sorted: ", len(chunks))
sortedchunks.extend(chunks)
chunks[:] = []
i -= 1
''' '''
if i<-200: if i<-200:
for ch in chunks: for ch in chunks: