[Qt-interest] Detecting intersections in a QPainterPath

benswerts at telenet.be benswerts at telenet.be
Tue Aug 10 23:15:23 CEST 2010


Thanks to everyone who replied.

I don't think I can use the QPainterPath::intersects function as it closes any open paths. I also cannot specify any bounds as the points are in floating point format.

I decided to go for a fully customized solution and wrote functions that can detect whether a line intersects with an arc or whether two arcs intersect. The one constraint I have is the fact that the arcs are circular so I could base them on line/circle and circle/circle intersection algorithms. The final algorithm is O(N^2), just like the original version that only worked on linear segments.

Greets,


  Ben

----- Originele e-mail  -----
Van: "Atlant Schmidt" <aschmidt at dekaresearch.com>
Aan: "Ben Swerts" <benswerts at telenet.be>, qt-interest at trolltech.com
Verzonden: Dinsdag 10 augustus 2010 16:51:00 GMT +01:00 Amsterdam / Berlijn / Bern / Rome / Stockholm / Wenen
Onderwerp: RE: [Qt-interest] Detecting intersections in a QPainterPath

Ben:

  To simplify things, are there any bounds we can place
  upon the "problem space"?

  For example, is there a maximum XY rect that will
  encompass all possible paths?

  Asking the question from the opposite direction,
  are the vertices of the paths points specified as
  integer [X,Y] pairs or are they arbitrarily fine-
  pitched floating point pairs?

  If both limits can be applied (so you have a
  bounded space of integer points), we might take
  a different approach than if the space can be either
  arbitrarily large or arbitrarily "fine-grained".

                      Atlant


-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Ben Swerts
Sent: Monday, August 09, 2010 17:07 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Detecting intersections in a QPainterPath

Hello all,

I have a QPainterPath created from a number of line and arc segments. This
path is allowed to be concave but it is not allowed to be self-intersecting.

If the path consists of only line segments this self-intersection test is
easy: check for a bounding intersection (with QLineF::intersect) between all
non-adjacent segments.

If the path also contains arced segments I have no idea how I should check
for intersections. I was kind of hoping the existing QPainterPath API
already has something to solve this.

Many thanks in advance!
Greets,


        Ben

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest

This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.



More information about the Qt-interest-old mailing list