summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2019-01-04 20:22:10 -0500
committerLex Neva <github.com@lexneva.name>2019-01-04 20:22:10 -0500
commit6a8edfc1cdc19e90b85c4023ef8611f506317e2d (patch)
treef00eb16d1003e75d6579ac7d162168dd5b473fd4 /lib
parent04ed93cb25198d216ea7adef66a1f4a1be854b58 (diff)
fix crash if fill start and end points are very close
Diffstat (limited to 'lib')
-rw-r--r--lib/stitches/auto_fill.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py
index 4a0fbed7..c7e65473 100644
--- a/lib/stitches/auto_fill.py
+++ b/lib/stitches/auto_fill.py
@@ -327,14 +327,16 @@ def get_outline_nodes(graph, outline_index=0):
def find_initial_path(graph, starting_point, ending_point=None):
starting_node = nearest_node_on_outline(graph, starting_point)
- if ending_point is None:
+ if ending_point is not None:
+ ending_node = nearest_node_on_outline(graph, ending_point)
+
+ if ending_point is None or starting_node is ending_node:
# If they didn't give an ending point, pick either neighboring node
# along the outline -- doesn't matter which. We do this because
# the algorithm requires we start with _some_ path.
neighbors = [n for n, keys in graph.adj[starting_node].iteritems() if 'outline' in keys]
return [PathEdge((starting_node, neighbors[0]), "initial")]
else:
- ending_node = nearest_node_on_outline(graph, ending_point)
outline_nodes = get_outline_nodes(graph)
# Multiply the outline_nodes list by 2 (duplicate it) because