fix bug in contour scanner

This commit is contained in:
Mario Voigt 2021-06-22 12:10:49 +02:00
parent 1d3716225f
commit 24429c67f1

View File

@ -859,25 +859,26 @@ class ContourScannerAndTrimmer(inkex.EffectExtension):
if so.remove_subsplit_collinear is True: if so.remove_subsplit_collinear is True:
if so.show_debug is True: self.msg("filtering collinear overlapping lines / duplicate lines") if so.show_debug is True: self.msg("filtering collinear overlapping lines / duplicate lines")
output_set, dropped_ids = self.filter_collinear(subSplitLineArray) if len(subSplitLineArray) > 0:
for subSplitLine in subSplitLineArray: output_set, dropped_ids = self.filter_collinear(subSplitLineArray)
ssl_id = subSplitLine.get('id') for subSplitLine in subSplitLineArray:
if ssl_id in dropped_ids: ssl_id = subSplitLine.get('id')
ssl_parent = subSplitLine.getparent() if ssl_id in dropped_ids:
subSplitLine.delete() #delete the line ssl_parent = subSplitLine.getparent()
subSplitLine.delete() #delete the line
#and delete the containg group if empty
if ssl_parent is not None and len(ssl_parent) == 0: #and delete the containg group if empty
if self.options.show_debug is True: if ssl_parent is not None and len(ssl_parent) == 0:
self.msg("Deleting group {}".format(ssl_parent.get('id'))) if self.options.show_debug is True:
ssl_parent.delete() self.msg("Deleting group {}".format(ssl_parent.get('id')))
# and now we replace the overlapping items with the new merged output ssl_parent.delete()
for output in output_set: # and now we replace the overlapping items with the new merged output
if output['id'] == subSplitLine.attrib['id']: for output in output_set:
#self.msg(output['p0']) if output['id'] == subSplitLine.attrib['id']:
subSplitLine.attrib['d'] = line.attrib['d'] = 'M {},{} L {},{}'.format( #self.msg(output['p0'])
output['p0'][0], output['p0'][1], output['p1'][0], output['p1'][1]) #we set the path of trimLine using 'd' attribute because if we use trimLine.path the decimals get cut off unwantedly subSplitLine.attrib['d'] = line.attrib['d'] = 'M {},{} L {},{}'.format(
#subSplitLine.path = line.path = [['M', output['p0']], ['L', output['p1']]] output['p0'][0], output['p0'][1], output['p1'][0], output['p1'][1]) #we set the path of trimLine using 'd' attribute because if we use trimLine.path the decimals get cut off unwantedly
#subSplitLine.path = line.path = [['M', output['p0']], ['L', output['p1']]]
''' '''
now we intersect the sub split lines to find the global intersection points using Bentley-Ottmann algorithm (contains self-intersections too!) now we intersect the sub split lines to find the global intersection points using Bentley-Ottmann algorithm (contains self-intersections too!)