diff options
| author | Kaalleen <reni@allenka.de> | 2023-07-09 10:05:24 +0200 |
|---|---|---|
| committer | Kaalleen <reni@allenka.de> | 2023-07-09 10:05:24 +0200 |
| commit | b01870890b07c8e9ac4c843fac9461c7086f31f7 (patch) | |
| tree | 08fc7cd8eb3d4244fc4328cc833d386182cfd331 | |
| parent | f1b63d8efefbcf8923d997cc0da18e4329fbe77e (diff) | |
avoid duplicated nodes
transform issue
| -rw-r--r-- | lib/elements/satin_column.py | 17 | ||||
| -rw-r--r-- | lib/extensions/convert_to_satin.py | 6 |
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index cc0cda9f..8975a4ba 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -698,7 +698,7 @@ class SatinColumn(EmbroideryElement): new SatinColumn's node will not be in the SVG document. """ - return self._csp_to_satin(self.csp) + return self._csp_to_satin(self.csp, True) def split(self, split_point): """Split a satin into two satins at the specified point @@ -814,13 +814,12 @@ class SatinColumn(EmbroideryElement): def _path_list_to_satins(self, path_list): return self._csp_to_satin(line_strings_to_csp(path_list)) - def _csp_to_satin(self, csp): + def _csp_to_satin(self, csp, remove_transform=False): node = deepcopy(self.node) d = paths.CubicSuperPath(csp).to_path() node.set("d", d) - # we've already applied the transform, so get rid of it - if node.get("transform"): + if remove_transform and node.get("transform"): del node.attrib["transform"] return SatinColumn(node) @@ -843,14 +842,16 @@ class SatinColumn(EmbroideryElement): # weird non-satin things, give up and don't merge return self - rails[0].extend(other_rails[0]) - rails[1].extend(other_rails[1]) + # remove first node of each other rail before merging (avoid duplicated nodes) + rails[0].extend(other_rails[0][1:]) + rails[1].extend(other_rails[1][1:]) rungs = [self.flatten_subpath(rung) for rung in self.rungs] other_rungs = [satin.flatten_subpath(rung) for rung in satin.rungs] - # add a rung at the end of my satin - rungs.append([rails[0][-1], rails[1][-1]]) + # add a rung in between the two satins and extend it just a litte to ensure it is crossing the rails + new_rung = shgeo.LineString([other_rails[0][0], other_rails[1][0]]) + rungs.append(list(shaffinity.scale(new_rung, 1.2, 1.2).coords)) # add on the other satin's rungs rungs.extend(other_rungs) diff --git a/lib/extensions/convert_to_satin.py b/lib/extensions/convert_to_satin.py index 03a4d6e4..c579e9b4 100644 --- a/lib/extensions/convert_to_satin.py +++ b/lib/extensions/convert_to_satin.py @@ -319,10 +319,8 @@ class ConvertToSatin(InkstitchExtension): # Rotate 90 degrees left to make a normal vector. normal = tangent.rotate_left() - # Travel 75% of the stroke width left and right to make the rung's - # endpoints. This means the rung's length is 150% of the stroke - # width. - offset = normal * stroke_width * 0.75 + # Extend the rungs by an offset value to make sure they will cross the rails + offset = normal * (stroke_width / 2) * 1.2 rung_start = rung_center + offset rung_end = rung_center - offset |
