commit 50938d91a2b9d720b7422ede6dbf83d97647a14f
parent 7c86f6543ae72cb3ea9d891233318f5e7d05e25a
Author: bkopf <vetlehaf@stud.ntnu.no>
Date: Tue, 20 Nov 2018 12:23:26 +0100
Fix problem with lower rect joints being set to processed when they shouldn't
Diffstat:
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/a2svg.py b/a2svg.py
@@ -183,7 +183,7 @@ class Figure:
"""
Checks if a joint belongs to a rectangle (and if there are subrectangles)
If it does, the rectangles are added as an element, and all associated characters
- are registered as processed.
+ are registered as processed, *except* joints on the rectangles.
"""
def rectangle(self, y_start, x_start):
# Temporary list of processed chars. Must dismiss if this is not a rectangle
@@ -229,7 +229,6 @@ class Figure:
cell = self._figarray[y_test][x]
if cell != '|' and cell != '+':
x_stop = None
- break
if x_stop:
break
# If x_stop is *not* defined, we probably found an x where both 'y's are connected to lines,
@@ -248,19 +247,14 @@ class Figure:
return None
# By this point, we know we have a rectangle, so we can register the
- # entire section as processed
- # TODO : Make readable
+ # entire section as processed (except the bottom line, in case of
+ # sub-rectangles)
+ # TODO : Make Pythonic. (That goes for a lot of this code, though)
for y in range(y_start, y_stop):
for x in range(x_start, x_stop+1):
if [y, x] not in self._process_queue:
self._processed[y][x] = True
- # TESTING
- for row in self._processed:
- for cell in row:
- print("{} ".format('p' if cell else ' '), end="")
- print()
-
new_rect = Rectangle((x_start, y_start), (x_stop, y_stop))
new_rect.extract_text(self)
rect_list = [new_rect]
@@ -271,7 +265,8 @@ class Figure:
# If not, we can register the bottom line as processed
else:
for x in range(x_start, x_stop+1):
- self._processed[y_stop][x] = True
+ if [y_stop, x] not in self._process_queue:
+ self._processed[y_stop][x] = True
return rect_list