diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/stitches/auto_fill.py | 13 | ||||
| -rw-r--r-- | lib/stitches/guided_fill.py | 2 |
2 files changed, 6 insertions, 9 deletions
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py index 50eea18e..b4d63224 100644 --- a/lib/stitches/auto_fill.py +++ b/lib/stitches/auto_fill.py @@ -380,14 +380,11 @@ def process_travel_edges(graph, fill_stitch_graph, shape, travel_edges): edge = (p1.as_tuple(), p2.as_tuple(), 'travel') - for segment in strtree.query(ls): - # It seems like the STRTree only gives an approximate answer of - # segments that _might_ intersect ls. Refining the result is - # necessary but the STRTree still saves us a ton of time. - if segment.crosses(ls): - start = segment.coords[0] - end = segment.coords[-1] - fill_stitch_graph[start][end]['segment']['underpath_edges'].append(edge) + for segment in strtree.query(ls, predicate='crosses'): + segment_geom = strtree.geometries.take(segment) + start = segment_geom.coords[0] + end = segment_geom.coords[-1] + fill_stitch_graph[start][end]['segment']['underpath_edges'].append(edge) # The weight of a travel edge is the length of the line segment. weight = p1.distance(p2) diff --git a/lib/stitches/guided_fill.py b/lib/stitches/guided_fill.py index e4793838..67ad4ccd 100644 --- a/lib/stitches/guided_fill.py +++ b/lib/stitches/guided_fill.py @@ -268,7 +268,7 @@ def intersect_region_with_grating_guideline(shape, line, row_spacing, num_stagge stitched_line = apply_stitches(offset_line, max_stitch_length, num_staggers, row_spacing, row) intersection = shape.intersection(stitched_line) - if shape_envelope.intersects(stitched_line): + if not intersection.is_empty and shape_envelope.intersects(stitched_line): for segment in take_only_line_strings(intersection).geoms: rows.append(segment.coords[:]) row += direction |
