Results 1 to 4 of 4

Thread: Qt4 : QPolygonF, how to recognize donuts ?

  1. #1
    Join Date
    Jun 2009
    Posts
    6
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Qt4 : QPolygonF, how to recognize donuts ?

    hello,

    P and Q are two QPolygonF, with Q strictly included in P. (think about donut, Q is the hole)

    This instruction :

    Qt Code:
    1. PmQ = P.subtracted(Q)
    To copy to clipboard, switch view to plain text mode 

    provides a new polygon PmQ, I can easily break down to obtain two polygons, say A and B. One is P, other is Q.

    Later on, I need two recognize
    1. - does PmQ comes from subtraction or union of two polygons ?
    2. - which one is the hole ? Is it A or B ?


    As I do this a lot of times, I'd like to avoid testing if A is included in B or B included in A.

    Is there a simple solution ?

    Thanks for your answer.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4 : QPolygonF, how to recognize donuts ?

    The hole is the one which has its bounding rectangle contained in the bounding rectangle of the other polygon.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    puiseux (25th November 2014)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt4 : QPolygonF, how to recognize donuts ?

    Qt's polygon classes do not support representing an object with a disconnected hole. The result of the subtraction is likely not what you are expecting.

  5. #4
    Join Date
    Jun 2009
    Posts
    6
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Qt4 : QPolygonF, how to recognize donuts ?

    As far as i use it, QPolygonF union, subtraction, intersection give (almost) what I'm expected.
    If two polygons P, Q have a non empty intersection, P.subtracted(Q) provides the real P \ Q if Q not entirely included in P.
    If Q is include in P, the result is what i expect, provided i can interpret the result.
    Results in other cases are sufficient for my use.
    There are some approximations but if I need more precision, I've found GEOS.
    Anyway, thanks for your answer and for your great work in Qt.

Similar Threads

  1. Scaling QPolygon or QPolygonF
    By tuxit in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2011, 17:19
  2. Limitations to QPolygonF?
    By roband915 in forum Qt Programming
    Replies: 12
    Last Post: 24th May 2011, 15:55
  3. QPolygonF precision?! is it possible?!
    By fatecasino in forum Newbie
    Replies: 11
    Last Post: 27th January 2011, 03:36
  4. Error in QPolygonF::subtracted
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2010, 02:27
  5. Sorting QPolygonF
    By giusepped in forum Qt Programming
    Replies: 3
    Last Post: 7th January 2009, 09:34

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.