PolygonCalculus.h 1.75 KB
Newer Older
1
#pragma once
2 3


4 5
#include <QPointF>
#include <QPolygonF>
6 7
#include <QVector3D>

8 9


10 11
namespace PolygonCalculus {

12 13
    enum JoinPolygonError { NotSimplePolygon, PolygonJoined, Disjoint, PathSizeLow};

14 15 16
    typedef QList<QVector3D> QVector3DList;
    typedef QList<QPointF> QPointFList;

17 18
    int              closestVertexIndex  (const QPolygonF &polygon, const QPointF &coordinate);
    QPointF          closestVertex       (const QPolygonF &polygon, const QPointF &coordinate);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
19 20
    int              nextVertexIndex     (int pathsize, int index);
    int              previousVertexIndex (int pathsize, int index);
21
    JoinPolygonError join                (QPolygonF polygon1, QPolygonF polygon2, QPolygonF &joinedPolygon);
22 23 24
    bool             isSimplePolygon     (const QPolygonF &polygon);
    bool             hasClockwiseWinding (const QPolygonF &path);
    void             reversePath         (QPolygonF &path);
25
    void             reversePath         (QPointFList &path);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
26 27
    void             offsetPolygon       (QPolygonF &polygon, double offset);
    bool             containsPath        (QPolygonF polygon, const QPointF &c1, const QPointF &c2);
28
    void             decomposeToConvex   (const QPolygonF &polygon, QList<QPolygonF> &convexPolygons);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
29
    bool             shortestPath        (QPolygonF polygon, const QPointF &startVertex, const QPointF &endVertex, QList<QPointF> &shortestPath);
30 31 32 33 34 35 36 37

    QPolygonF toQPolygonF(const QVector3DList &polygon);
    QPolygonF toQPolygonF(const QPointFList &polygon);
    QLineF toQLineF(const QVector3DList &line);
    QPointFList toQPointFList(const QVector3DList &list);
    QPointFList toQPointFList(const QPolygonF &list);
    QVector3DList toQVector3DList(const QPointFList &listF);
    QVector3DList toQVector3DList(const QPolygonF &listF);
38 39
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
40