|
Boost Users : |
Subject: Re: [Boost-users] [Polygon] How to put self intersect polygon into PolygonSet
From: Luke Simonson (simoluk_at_[hidden])
Date: 2012-09-27 18:30:26
On Thu, Sep 27, 2012 at 1:25 AM, ææ´(zeal) <li.y-neu_at_[hidden]> wrote:
> 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?
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.
>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
the right hand triangle.
Regards,
Luke
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net