summaryrefslogtreecommitdiff
path: root/lib/stitches/auto_fill.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stitches/auto_fill.py')
-rw-r--r--lib/stitches/auto_fill.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py
index b5f20afb..dbbef136 100644
--- a/lib/stitches/auto_fill.py
+++ b/lib/stitches/auto_fill.py
@@ -156,18 +156,21 @@ def build_fill_stitch_graph(shape, angle, row_spacing, end_row_spacing, starting
return graph
-def insert_node(graph, shape, node):
+def insert_node(graph, shape, point):
"""Add node to graph, splitting one of the outline edges"""
- node = nearest_node(graph, tuple(node))
- point = shgeo.Point(node)
+ point = tuple(point)
+ outline = which_outline(shape, point)
+ projection = project(shape, point, outline)
+ projected_point = list(shape.boundary)[outline].interpolate(projection)
+ node = (projected_point.x, projected_point.y)
edges = []
for start, end, key, data in graph.edges(keys=True, data=True):
if key == "outline":
edges.append(((start, end), data))
- edge, data = min(edges, key=lambda (edge, data): shgeo.LineString(edge).distance(point))
+ edge, data = min(edges, key=lambda (edge, data): shgeo.LineString(edge).distance(projected_point))
graph.remove_edge(*edge, key="outline")
graph.add_edge(edge[0], node, key="outline", **data)