pyclipper
pyclipper copied to clipboard
XOR branching/non-manifold result?
Hi, Intersection, Union, and Difference work just fine, but I am having a hard time figuring out how I should read the output of a simple XOR clip as below. When I try to build a set of polycurves from the output results, my graphics library complains that the points form a branching/non-manifold result. Any help on how to correctly transform the data to a set of closed simple polygons would be appreciated.
import pyclipper
subj = ( ((180, 200), (260, 200), (260, 150), (180, 150)), ((215, 160), (230, 190), (200, 190)) ) clip = ((190, 210), (240, 210), (240, 130), (190, 130))
pc = pyclipper.Pyclipper() pc.AddPath(clip, pyclipper.PT_CLIP, True) pc.AddPaths(subj, pyclipper.PT_SUBJECT, True)
solution = pc.Execute(pyclipper.CT_XOR, pyclipper.PFT_EVENODD, pyclipper.PFT_EVENODD)
If you want it to be closed polygons, the easiest thing is to append the first point onto the end of it. Add one more line solution.append(solution[0]))