def __sub__(self, other): """ Subtraction of polygons """ sequence = [] # get raw points lists without duplication first-last points = [dict([["point",p], ["kind",k], ["visited", False]]) for p, k in self.points[:-1]] otherPoints = [dict([["point",p], ["kind",k], ["visited", False]]) for p, k in other.points[:-1]] tmp = [BravePoint(p,k) for p, k in self.points[:-1]] tmp2 = [BravePoint(p,k) for p, k in other.points[:-1]] tmp2.reverse() # useful points = LinkedList() points.load(tmp) points.setEndless(True) otherPoints = LinkedList() otherPoints.load(tmp2) otherPoints.setEndless(True) #pprint(tmp) #pprint(tmp2) p = points.first firstStep = True while p is not points.first or firstStep: firstStep = False d = p.data if d.kind != Kind.outgoing or d.visited: p = p.next continue # brave new polygon! newbies = getPointsUntilExit(points, otherPoints, p.data) #print("newbies= ", newbies) sequence.append(newbies) #print "sequence= ", sequence points.setEndless(False) otherPoints.setEndless(False) #pprint({'points': points.toList(), 'otherPoints': otherPoints.toList()}) result = [] for lol in sequence: tmp = [bp.point for bp in lol] kinds = [Kind.neutral]*len(tmp) poly = Poly(points=zip(tmp, kinds)) result.append(poly) return result