Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XOR branching/non-manifold result? #35

Open
wassimj opened this issue Dec 26, 2020 · 1 comment
Open

XOR branching/non-manifold result? #35

wassimj opened this issue Dec 26, 2020 · 1 comment

Comments

@wassimj
Copy link

wassimj commented Dec 26, 2020

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)

@wassimj wassimj changed the title XOR brnaching/non-manifold result? XOR branching/non-manifold result? Dec 26, 2020
@GilParnon
Copy link

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]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants