summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2025-04-15 18:27:30 +0200
committerGitHub <noreply@github.com>2025-04-15 18:27:30 +0200
commitf9b249cef51b721a1b1837fedeb446e365a7602b (patch)
tree07cb2ef907d28b72d7603d1d6beab17f57971574 /lib
parentbc0943c6c86374ca80f3f10ffa44773ef87c5f24 (diff)
Do not bridge actual segments (#3669)
Diffstat (limited to 'lib')
-rw-r--r--lib/extensions/fill_to_satin.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/extensions/fill_to_satin.py b/lib/extensions/fill_to_satin.py
index 285688d4..fcb967e5 100644
--- a/lib/extensions/fill_to_satin.py
+++ b/lib/extensions/fill_to_satin.py
@@ -164,7 +164,6 @@ class FillElementToSatin:
self.rung_sections = defaultdict(list) # rung_index: section indices
self.section_rungs = defaultdict(list) # section index: rung indices
self.bridged_rungs = defaultdict(list) # bridge index: rung indices
- self.rung_bridges = defaultdict(list) # rung index: bridge indices
def convert_to_satin(self):
intersection_points, bridges = self._validate_rungs()
@@ -281,7 +280,9 @@ class FillElementToSatin:
continue
rung1 = rung_list[0]
rung2 = rung_list[1]
- segment = self._get_segment(rung1, rung2, intersection_points, line_section_multi)
+ segment = self._get_bridged_segment(rung1, rung2, intersection_points, line_section_multi)
+ if not segment:
+ continue
satin_segments.append(segment)
rung_segments[rung_list[0]].append(segment_index)
rung_segments[rung_list[1]].append(segment_index)
@@ -295,13 +296,16 @@ class FillElementToSatin:
pass
return rung_segments, satin_segments
- def _get_segment(self, rung1, rung2, intersection_points, line_section_multi):
+ def _get_bridged_segment(self, rung1, rung2, intersection_points, line_section_multi):
rung_sections1 = self.rung_sections[rung1]
rung_sections2 = self.rung_sections[rung2]
points1 = self._get_rung_points(rung1, intersection_points)
points2 = self._get_rung_points(rung2, intersection_points)
connected_section = list(set(rung_sections1) & set(rung_sections2))
+ if len(connected_section) > 1:
+ # this is an unnecessarily bridged section, we can savely skip it
+ return
if len(connected_section) == 1:
# do not bridge a segment side if there is an actual section we could use
segment1 = self.line_sections[connected_section[0]]
@@ -450,11 +454,20 @@ class FillElementToSatin:
if section.distance(rung) < 0.01:
self.section_rungs[i].append(j)
self.rung_sections[j].append(i)
+
+ bridged_rungs = defaultdict(list)
for i, bridge in enumerate(bridges):
for j, rung in enumerate(self.rungs):
if bridge.intersects(rung):
- self.bridged_rungs[i].append(j)
- self.rung_bridges[j].append(i)
+ bridged_rungs[i].append(j)
+
+ # for the case that they - for whatever reason -
+ # drew a bridge over the same rungs twice, clean up duplicated bridges
+ seen_bridged_rungs = []
+ for bridge, rungs in bridged_rungs.items():
+ if rungs not in seen_bridged_rungs:
+ self.bridged_rungs[bridge] = rungs
+ seen_bridged_rungs.append(rungs)
def _validate_rungs(self):
''' Returns only valid rungs and bridge section markers'''