kopia lustrzana https://github.com/inkstitch/inkstitch
Do not bridge actual segments (#3669)
rodzic
bc0943c6c8
commit
f9b249cef5
|
@ -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'''
|
||||
|
|
Ładowanie…
Reference in New Issue