<s> from fontTools . pens . basePen import BasePen <EOL> from flatten import InputContour , OutputContour <EOL> from pyClipper import PolyClipper <EOL> """<STR_LIT>""" <EOL> class BooleanOperationManager ( object ) : <EOL> def _performOperation ( self , operation , subjectContours , clipContours , outPen ) : <EOL> subjectInputContours = [ InputContour ( contour ) for contour in subjectContours if contour and len ( contour ) > <NUM_LIT:1> ] <EOL> clipInputContours = [ InputContour ( contour ) for contour in clipContours if contour and len ( contour ) > <NUM_LIT:1> ] <EOL> inputContours = subjectInputContours + clipInputContours <EOL> clipperContours = [ ] <EOL> for contour in subjectInputContours : <EOL> clipperContours . append ( dict ( coordinates = contour . originalFlat , role = "<STR_LIT>" ) ) <EOL> for contour in clipInputContours : <EOL> clipperContours . append ( dict ( coordinates = contour . originalFlat , role = "<STR_LIT>" ) ) <EOL> clipper = PolyClipper . alloc ( ) . init ( ) <EOL> resultContours = clipper . execute_operation_withOptions_ ( clipperContours , operation , dict ( subjectFillType = "<STR_LIT>" , clipFillType = "<STR_LIT>" ) ) <EOL> convertedContours = [ ] <EOL> for contour in resultContours : <EOL> contour = [ tuple ( point ) for point in contour ] <EOL> convertedContours . append ( contour ) <EOL> resultContours = convertedContours <EOL> outputContours = [ OutputContour ( contour ) for contour in resultContours ] <EOL> for inputContour in inputContours : <EOL> for outputContour in outputContours : <EOL> if outputContour . final : <EOL> break <EOL> if outputContour . reCurveFromEntireInputContour ( inputContour ) : <EOL> break <EOL> for inputContour in inputContours : <EOL> if inputContour . used : <EOL> continue <EOL> for outputContour in outputContours : <EOL> outputContour . reCurveFromInputContourSegments ( inputContour ) <EOL> for outputContour in outputContours : <EOL> outputContour . reCurveSubSegments ( inputContours ) <EOL> for outputContour in outputContours : <EOL> outputContour . drawPoints ( outPen ) <EOL> return outputContours <EOL> def union ( self , contours , outPen ) : <EOL> return self . _performOperation ( "<STR_LIT>" , contours , [ ] , outPen ) <EOL> def difference ( self , subjectContours , clipContours , outPen ) : <EOL> return self . _performOperation ( "<STR_LIT>" , subjectContours , clipContours , outPen ) <EOL> def intersection ( self , subjectContours , clipContours , outPen ) : <EOL> return self . _performOperation ( "<STR_LIT>" , subjectContours , clipContours , outPen ) <EOL> def xor ( self , subjectContours , clipContours , outPen ) : <EOL> return self . _performOperation ( "<STR_LIT>" , subjectContours , clipContours , outPen ) </s>
