diff --git a/Lib/booleanOperations/flatten.py b/Lib/booleanOperations/flatten.py index 68e602e..6b5100f 100644 --- a/Lib/booleanOperations/flatten.py +++ b/Lib/booleanOperations/flatten.py @@ -147,7 +147,7 @@ def __init__(self, points=None, previousOnCurve=None, willBeReversed=False): self.scaledPreviousOnCurve = _scaleSinglePoint(previousOnCurve, scale=clipperScale) self.used = False self.flat = [] - # if the bcps are equal to the oncurves convert the segment to a line segment. + # if the bcps are equal to the oncurves, or are aligned with them, convert the segment to a line segment. # otherwise this causes an error when flattening. if self.segmentType == "curve": if previousOnCurve == points[0].coordinates and points[1].coordinates == points[-1].coordinates: @@ -162,6 +162,11 @@ def __init__(self, points=None, previousOnCurve=None, willBeReversed=False): oncurve = points[-1] oncurve.segmentType = "line" self.points = points = [oncurve] + elif (_pointOnLine(previousOnCurve, points[-1].coordinates, points[0].coordinates) and + _pointOnLine(previousOnCurve, points[-1].coordinates, points[1].coordinates)): + oncurve = points[-1] + oncurve.segmentType = "line" + self.points = points = [oncurve] # its a reversed segment the flat points will be set later on in the InputContour if willBeReversed: return