Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpathclipper.cpp File Reference

(f8f23c43feb2fb233a8f047cd1b82259498d9aeb)

#include "qpathclipper_p.h"
#include <private/qbezier_p.h>
#include <private/qdatabuffer_p.h>
#include <private/qnumeric_p.h>
#include <qmath.h>
#include <algorithm>
#include <qdebug.h>
+ Include dependency graph for qpathclipper.cpp:

Go to the source code of this file.

Classes

struct  QIntersection
 
class  QIntersectionFinder
 
class  QKdPointTree
 
struct  QKdPointTree::Node
 
class  QKdPointFinder
 
struct  QCrossingEdge
 

Functions

static QT_BEGIN_NAMESPACE bool fuzzyIsNull (qreal d)
 
static bool comparePoints (const QPointF &a, const QPointF &b)
 
static qreal dot (const QPointF &a, const QPointF &b)
 
static void normalize (double &x, double &y)
 
 Q_DECLARE_TYPEINFO (QIntersection, Q_PRIMITIVE_TYPE)
 
template<typename T >
void qTraverseKdPointTree (QKdPointTree::Node &node, T &t, int depth=0)
 
static qreal component (const QPointF &point, unsigned int i)
 
static bool isLine (const QBezier &bezier)
 
static int commonEdge (const QWingedEdge &list, int a, int b)
 
static double computeAngle (const QPointF &v)
 
static void addLineTo (QPainterPath &path, const QPointF &point)
 
static void add (QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
 
static void clear (QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
 
template<typename InputIterator >
InputIterator qFuzzyFind (InputIterator first, InputIterator last, qreal val)
 
static bool fuzzyCompare (qreal a, qreal b)
 
static void traverse (QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
 
 Q_DECLARE_TYPEINFO (QCrossingEdge, Q_PRIMITIVE_TYPE)
 
static bool bool_op (bool a, bool b, QPathClipper::Operation op)
 
static QList< QCrossingEdgefindCrossings (const QWingedEdge &list, qreal y)
 

Function Documentation

◆ add()

static void add ( QPainterPath & path,
const QWingedEdge & list,
int edge,
QPathEdge::Traversal traversal )
static

Definition at line 1274 of file qpathclipper.cpp.

References QPathEdge::flag, QPathEdge::Forward, QPathEdge::LeftTraversal, and QPathEdge::vertex().

+ Here is the call graph for this function:

◆ addLineTo()

static void addLineTo ( QPainterPath & path,
const QPointF & point )
static

Definition at line 1252 of file qpathclipper.cpp.

◆ bool_op()

static bool bool_op ( bool a,
bool b,
QPathClipper::Operation op )
static

Definition at line 1705 of file qpathclipper.cpp.

◆ clear()

static void clear ( QWingedEdge & list,
int edge,
QPathEdge::Traversal traversal )
static

Definition at line 1427 of file qpathclipper.cpp.

References QPathEdge::Forward, and QPathEdge::LeftTraversal.

◆ commonEdge()

static int commonEdge ( const QWingedEdge & list,
int a,
int b )
static

◆ comparePoints()

static bool comparePoints ( const QPointF & a,
const QPointF & b )
inlinestatic

Definition at line 40 of file qpathclipper.cpp.

◆ component()

static qreal component ( const QPointF & point,
unsigned int i )
inlinestatic

Definition at line 626 of file qpathclipper.cpp.

◆ computeAngle()

static double computeAngle ( const QPointF & v)
static

Definition at line 1121 of file qpathclipper.cpp.

References normalize().

+ Here is the call graph for this function:

◆ dot()

static qreal dot ( const QPointF & a,
const QPointF & b )
static

Definition at line 47 of file qpathclipper.cpp.

◆ findCrossings()

static QList< QCrossingEdge > findCrossings ( const QWingedEdge & list,
qreal y )
static

Definition at line 1747 of file qpathclipper.cpp.

◆ fuzzyCompare()

static bool fuzzyCompare ( qreal a,
qreal b )
static

Definition at line 1452 of file qpathclipper.cpp.

◆ fuzzyIsNull()

static QT_BEGIN_NAMESPACE bool fuzzyIsNull ( qreal d)
inlinestatic

The algorithm is as follows:

  1. Find all intersections between the two paths (including self-intersections), and build a winged edge structure of non-intersecting parts.
  2. While there are more unhandled edges:
    1. Pick a y-coordinate from an unhandled edge.
    2. Intersect the horizontal line at y-coordinate with all edges.
    3. Traverse intersections left to right deciding whether each subpath should be added or not.
    4. If the subpath should be added, traverse the winged-edge structure and add the edges to a separate winged edge structure.
    5. Mark all edges in subpaths crossing the horizontal line as handled.

(Optional) Simplify the resulting winged edge structure by merging shared edges.

  1. Convert the resulting winged edge structure to a painter path.

Definition at line 32 of file qpathclipper.cpp.

◆ isLine()

static bool isLine ( const QBezier & bezier)
static

Definition at line 855 of file qpathclipper.cpp.

◆ normalize()

static void normalize ( double & x,
double & y )
static

Definition at line 52 of file qpathclipper.cpp.

Referenced by computeAngle().

+ Here is the caller graph for this function:

◆ Q_DECLARE_TYPEINFO() [1/2]

Q_DECLARE_TYPEINFO ( QCrossingEdge ,
Q_PRIMITIVE_TYPE  )

◆ Q_DECLARE_TYPEINFO() [2/2]

Q_DECLARE_TYPEINFO ( QIntersection ,
Q_PRIMITIVE_TYPE  )

◆ qFuzzyFind()

template<typename InputIterator >
InputIterator qFuzzyFind ( InputIterator first,
InputIterator last,
qreal val )

Definition at line 1445 of file qpathclipper.cpp.

◆ qTraverseKdPointTree()

template<typename T >
void qTraverseKdPointTree ( QKdPointTree::Node & node,
T & t,
int depth = 0 )

◆ traverse()

static void traverse ( QWingedEdge & list,
int edge,
QPathEdge::Traversal traversal )
static

Definition at line 1671 of file qpathclipper.cpp.

References QPathEdge::flag, QPathEdge::Forward, and QPathEdge::LeftTraversal.