void tst_QPainterPath::testToFillPolygons() { QPainterPath path; path.lineTo(QPointF(0, 50)); path.lineTo(QPointF(50, 50)); path.moveTo(QPointF(70, 50)); path.lineTo(QPointF(70, 100)); path.lineTo(QPointF(40, 100)); const QList<QPolygonF> polygons = path.toFillPolygons(); QCOMPARE(polygons.size(), 2); QCOMPARE(polygons.first().count(QPointF(70, 50)), 0); }
QList<QPointF> Geometry::pathToPoints(QPainterPath const &path) { qreal const polygonIsPointCondition = 0.001; QList<QPolygonF> polygons = path.toFillPolygons(); QList<QPointF> result; foreach (QPolygonF const &polygon, polygons) { if (square(polygon) < polygonIsPointCondition) { result << polygon[0]; } else { return QList<QPointF>(); } } return result; }