Union clipping not working

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Union clipping not working

Hunk
Hello

I have two areas which you can see on the follow picture



As Points

Blue:  
2.5 , 4 / 2.5 , 1 / 2 , 1 / 2 , 4 / 0,4 / 0,0 / 7,0 / 7,5 / 2,5 / 2 , 4
red:
2, 5 / 0 , 5 / 0 , 4 / 2,  4

i expect as solution the outside area
0,0 7,0 7,4 0 ,4
and the obstacle inside

but the output polygon vector has only the size 1

0,4 / 0,0 / 7,0 /7,5 /0,5

but i dont understand why ...

is the problem the touch point(2,4) on polygon blue?
Reply | Threaded
Open this post in threaded view
|

Re: Union clipping not working

Barend
Hi,

Hunk wrote On 22-10-2013 11:40:
Hello

I have two areas which you can see on the follow picture

<http://boost-geometry.203548.n3.nabble.com/file/n4025672/union_.png> 

As Points 

Blue:   
2.5 , 4 / 2.5 , 1 / 2 , 1 / 2 , 4 / 0,4 / 0,0 / 7,0 / 7,5 / 2,5 / 2 , 4
red:
2, 5 / 0 , 5 / 0 , 4 / 2,  4

i expect as solution the outside area 
0,0 7,0 7,4 0 ,4
and the obstacle inside

but the output polygon vector has only the size 1

0,4 / 0,0 / 7,0 /7,5 /0,5

but i dont understand why ...

is the problem the touch point(2,4) on polygon blue?

Nope, the problem is somewhere in your code. I don't see your code so I cannot see what it is, but probably your polygon-definitions (CCW/CCW, Open/Closed) do not correspond to the input you specify. You can always call "correct".

This code works for me:
    boost::geometry::read_wkt("POLYGON((2.5 4 , 2.5   1 , 2   1 , 2   4 , 0 4 , 0 0 , 7 0 , 7 5 , 2 5 , 2 4, 2.5 4))", green);
    boost::geometry::read_wkt("POLYGON((2  5 , 0   5 , 0   4 , 2   4))", blue);

    boost::geometry::correct(green);
    boost::geometry::correct(blue);


and delivers:


The orange line is the union. Colors are different because I adapted a standard doumentation sample.
http://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/geometry/reference/algorithms/union_.html


Another option is (remembering your previous mail about REGISTER_RING) that you consider a ring as a polygon. That is not the case. The ring is a simple geometry without any holes. You can output a union to a ring, but any hole is than (by design) discarded. A ring cannot have holes, by definition.

Regards, Barend


_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|

Re: Union clipping not working

Hunk
you are right

I registered my type only as Ring not as polygon.

It is possible to set my own polygon with my ring type? For environment ccw directed and for obstacles cw?

Is there an easy way to register my rings as polygon?

I only want to know if the union polygon gets a hole or not
Reply | Threaded
Open this post in threaded view
|

Re: Union clipping not working

Barend
Hi Hunk,


> you are right
>
> I registered my type only as Ring not as polygon.
>
> It is possible to set my own polygon with my ring type? For environment ccw
> directed and for obstacles cw?
>
> Is there an easy way to register my rings as polygon?


Yes. But not  macro. Because of the interior rings, this is more complex. See e.g.
http://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/geometry/examples.html also recently discussed on this list.



>
> I only want to know if the union polygon gets a hole or not

Why then not use boost::geometry::model::polygon, as output.

Another option ( trick) is doing an intersection too. If p and q are areas of input rings, and i and u are areas of intersection and union, u = p + q - i. If that does not hold, the union must have a hole.

Regards, Barend

Sent from iPad
>


_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry