Polygon hole

Help
Gabriel
2011-02-01
2012-12-12
  • Gabriel

    Gabriel - 2011-02-01

    Hi there.

    First of all, congratulations for this library. It's really handy.

    I have two questions:

    1) After applying clipping to two polygons, using Polygon2DUtils.union(), how do you know what holes were created?

    2) Since this uses GPC, how do you do polygon diff? The original GPC supported difference, intersection exclusive-or and union.

    Thanks in advance.

     
  • David

    David - 2011-02-02

    Hi,

    thanks for your interest in the library, I tried to make it easy to understand, I hope it is….

    concerning your questions :
    1) one solution is to iterate on the set of linear rings composing the polygon, and to test for its orientation. This can be done via the "getSignedArea" method : if negative, the polygon is a hole. I haven't tested it, but this should work. If not, tell me.

    2) concerning the difference, the original GPC supported it, but not the GPCJ (a port of GPC). It should not be that difficult to add it, but I did not take time for it yet…

    Regards,

    David

     
  • David

    David - 2011-07-24

    Hi,

    After some months I've finally found time to add polygon difference. It is now available like other methods the same type, in the Polygon2DUtils class. It works on simple case, but it was not tested very intensively.

    You can check it from the subversion repository at
    svn co https://geom-java.svn.sourceforge.net/svnroot/geom-java/trunk

    It will be included in the next release of javaGeom.

    Regards,
    David

     
  • Sv. Kostadinov

    Sv. Kostadinov - 2012-03-08

    Hello,

    Few days ago I've started using javaGeom for sketching functionality. I would like to know if it is possible to create circulinear (or at least linear) domains with hole inside them and how can I deal with them. Maybe first ring is one direction and the other rings in the boundary are opposite? And to what degree are they supported? What kind of operations I can do on domains with holes?  Please, give me some advices!?

    Regards and 10x for this great library, it is a gemstone! :)

     
  • David

    David - 2012-03-09

    Hi sevarbg,

    and thank you for your interest in the library!

    It is possible to build circulinear domains with holes. The inner representation is as you expect, one CCW ring for outer, several CW rings for inner holes. By the way, order of rings is not relevant in most cases.

    The creation is not straightforward. You first need  to create the boundary, then create the domain. To create the boundary, you can use the class "CirculinearContourArray2D". First create the rings, the create an array of the rings, and call CirculinearContourArray2D with ring array as argument.
    The domain can be created using the class GenericCirculinearDomain2D, with the boundary as argument of the constructor.

    Hope this helps!

    regards,
    David

     

Log in to post a comment.