PolygonCalculus.h 2.12 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
    enum JoinPolygonError { NotSimplePolygon, PolygonJoined, Disjoint, PathSizeLow, Error};
13

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

18 19
    int              closestVertexIndex  (const QPolygonF &polygon, const QPointF &coordinate);
    QPointF          closestVertex       (const QPolygonF &polygon, const QPointF &coordinate);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
20 21
    int              nextVertexIndex     (int pathsize, int index);
    int              previousVertexIndex (int pathsize, int index);
22
    JoinPolygonError join                (QPolygonF polygon1, QPolygonF polygon2, QPolygonF &joinedPolygon);
23 24 25
    bool             isSimplePolygon     (const QPolygonF &polygon);
    bool             hasClockwiseWinding (const QPolygonF &path);
    void             reversePath         (QPolygonF &path);
26
    void             reversePath         (QPointFList &path);
27
    void             reversePath         (QPointFVector &path);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
28
    void             offsetPolygon       (QPolygonF &polygon, double offset);
29
    // returns true if the line c1-c2 is fully inside the polygon
Valentin Platzgummer's avatar
Valentin Platzgummer committed
30
    bool             containsPath        (QPolygonF polygon, const QPointF &c1, const QPointF &c2);
31 32
    // same as containsPath(), but works only if c1 and c2 are inside the polygon!
    bool             containsPathFast    (QPolygonF polygon, const QPointF &c1, const QPointF &c2);
33
    void             decomposeToConvex   (const QPolygonF &polygon, QList<QPolygonF> &convexPolygons);
34
    bool             shortestPath        (const QPolygonF &polygon, const QPointF &startVertex, const QPointF &endVertex, QVector<QPointF> &shortestPath);
35 36 37 38 39 40 41 42

    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);
43 44
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
45