diff options
| author | Lex Neva <github.com@lexneva.name> | 2020-02-15 21:13:20 -0500 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2020-03-16 23:00:19 -0400 |
| commit | 46dbe4668ea4a2d2ad2ad370f5e96ee89a4eadd2 (patch) | |
| tree | c56c2cf039bd3269c7092b0f7961d16e83fa3967 /lib/stitches | |
| parent | c81c11eb53c9e326812e6baa3390f5019be2abcd (diff) | |
actually split outline edge
Diffstat (limited to 'lib/stitches')
| -rw-r--r-- | lib/stitches/auto_fill.py | 11 |
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) |
