diff options
Diffstat (limited to 'lib/stitches/auto_fill.py')
| -rw-r--r-- | lib/stitches/auto_fill.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py index b5157a5a..485f51e5 100644 --- a/lib/stitches/auto_fill.py +++ b/lib/stitches/auto_fill.py @@ -8,11 +8,12 @@ from shapely import geometry as shgeo from shapely.ops import snap from shapely.strtree import STRtree -from .fill import intersect_region_with_grating, stitch_row -from .running_stitch import running_stitch from ..debug import debug from ..svg import PIXELS_PER_MM -from ..utils.geometry import Point as InkstitchPoint, line_string_to_point_list +from ..utils.geometry import Point as InkstitchPoint +from ..utils.geometry import line_string_to_point_list +from .fill import intersect_region_with_grating, stitch_row +from .running_stitch import running_stitch class PathEdge(object): @@ -82,7 +83,7 @@ def which_outline(shape, coords): point = shgeo.Point(*coords) outlines = list(shape.boundary) - outline_indices = range(len(outlines)) + outline_indices = list(range(len(outlines))) closest = min(outline_indices, key=lambda index: outlines[index].distance(point)) return closest @@ -175,7 +176,7 @@ def insert_node(graph, shape, point): if key == "outline": edges.append(((start, end), data)) - edge, data = min(edges, key=lambda (edge, data): shgeo.LineString(edge).distance(projected_point)) + edge, data = min(edges, key=lambda edge_data: shgeo.LineString(edge_data[0]).distance(projected_point)) graph.remove_edge(*edge, key="outline") graph.add_edge(edge[0], node, key="outline", **data) @@ -204,7 +205,7 @@ def add_boundary_travel_nodes(graph, shape): if length > 1: # Just plot a point every pixel, that should be plenty of # resolution. A pixel is around a quarter of a millimeter. - for i in xrange(1, int(length)): + for i in range(1, int(length)): subpoint = segment.interpolate(i) graph.add_node((subpoint.x, subpoint.y), projection=outline.project(subpoint), outline=outline_index) @@ -480,7 +481,7 @@ def find_stitch_path(graph, travel_graph, starting_point=None, ending_point=None graph = graph.copy() if not starting_point: - starting_point = graph.nodes.keys()[0] + starting_point = list(graph.nodes.keys())[0] starting_node = nearest_node(graph, starting_point) |
