On Thu, Sep 27, 2012 at 1:25 AM, 李洋(zeal)
I want to put a self intersect polygon
|\ /| | \ / | | \/ | | /\ | | / \ | |/ \| into a Polygon set ps, But when I use ps += poly to put it, in the ps the polygon has been cut to /| / | / | \ | \ | \|
and the left part doesn't exist anymore. I'm not sure whether I use it in a wrong way, or the library doesn't support this kind of operation?
From there you can do a NOT between the original rectangle and the rectangle with the hole to turn the hole positive and then OR it with
Very few libraries handle self intersecting polygons. This is actually one of Polygon's great strengths. There are three ways to handle self intersection. non-zero winding rule, odd winding rule and positive winding rule. The library does handle self intersecting polygons, just not the way you wanted. Your expectation is that the library applies the non-zero winding rule or the odd winding rule. Polygon uses the positive winding rule. The triangle on the left looks like a hole outside of a polygon to the library and has a winding of -1. Try putting your self intersecting polygon in a vector with a rectangle that is much bigger than it and then do ps += poly_vector and you will get a rectangle with a hole that is the left triangle. the right hand triangle. Regards, Luke