typemytype / booleanOperations

Boolean operations on paths
MIT License
39 stars 18 forks source link

exceptions #41

Closed typemytype closed 7 years ago

typemytype commented 7 years ago

It super nice to have some exceptions raised

but its also a hard: fe a contour with 2 line segments, so no area, would raise an exception for the whole glyph. Visually this contour would always disappear.

https://github.com/typemytype/booleanOperations/blob/master/Lib/booleanOperations/booleanOperationManager.py#L41

In some cases a silent fail is nice. Im unsure what else pyclipper.ClipperException is catching when adding a path.

typemytype commented 7 years ago

part of the solution

https://github.com/typemytype/booleanOperations/commit/8dc6c6ac8a372ff919ce9ed0e02ad2bc77f81e63

anthrotype commented 7 years ago

Yeah, I changed from AddPaths (which only raises when all input contours are invalid for clipping) to AddPath in a for loop, so now it raises if any one is invalid. But maybe you're right, it's a bit too much. We can revert to using AddPaths by default if you like, and have an option to raise if any single one is invalid.

My understanding is that subject contours are invalid if they have no area, or if they are open. Clipping paths can be open (unlike subject ones), but we currently do not use the closed=True keyword argument of AddPath and AddPaths, thus we always assume that the input contours are closed (which may not always be).

By the way, do you know the Clipper library also exports a Area method?

https://github.com/greginvm/pyclipper/blob/master/pyclipper/pyclipper.pyx#L279-L291

It should be faster than the pure-python AreaPen as it's written in C++, and should also be accurate since Clipper also uses that to compute the orientation of paths.

anthrotype commented 7 years ago

note that the pyclipper.Area function only works on polygons, not on bezier contours.

typemytype commented 7 years ago

using pyClipper.Area and ignore those would be fine, as those will fail in pyClipper and do nothing the the operation

Using open contours is an option an implementation can handle. The choice not to add them or closing them should be made elsewhere.

typemytype commented 7 years ago

see https://github.com/typemytype/booleanOperations/commit/e65175badaa304578087cf921724fbc53676cc52

anthrotype commented 7 years ago

That's good, thanks

anthrotype commented 7 years ago

should we tag 0.6.3?

It's easy to do from the Github website: https://github.com/typemytype/booleanOperations/releases/new

typemytype commented 7 years ago

Yep, a tag touch would be nice

anthrotype commented 7 years ago

done https://github.com/typemytype/booleanOperations/releases/tag/0.6.3

typemytype commented 7 years ago

Thanks!

On Sat, 17 Dec 2016 at 19:23, Cosimo Lupo notifications@github.com wrote:

done https://github.com/typemytype/booleanOperations/releases/tag/0.6.3

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/typemytype/booleanOperations/issues/41#issuecomment-267778378, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIp1kZIdhSh4V0LTtKZTn9QhgX41YT1ks5rJCiHgaJpZM4LNCxr .