#pragma once


#include <QPointF>
#include <QPolygonF>
#include <QVector3D>



namespace PolygonCalculus {

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

    typedef QList<QVector3D> QVector3DList;
    typedef QList<QPointF> QPointFList;
    typedef QVector<QPointF> QPointFVector;

    int              closestVertexIndex  (const QPolygonF &polygon, const QPointF &coordinate);
    QPointF          closestVertex       (const QPolygonF &polygon, const QPointF &coordinate);
    int              nextVertexIndex     (int pathsize, int index);
    int              previousVertexIndex (int pathsize, int index);
    JoinPolygonError join                (QPolygonF polygon1, QPolygonF polygon2, QPolygonF &joinedPolygon);
    bool             isSimplePolygon     (const QPolygonF &polygon);
    bool             hasClockwiseWinding (const QPolygonF &path);
    void             reversePath         (QPolygonF &path);
    void             reversePath         (QPointFList &path);
    void             reversePath         (QPointFVector &path);
    void             offsetPolygon       (QPolygonF &polygon, double offset);
    bool             containsPath        (QPolygonF polygon, const QPointF &c1, const QPointF &c2);
    void             decomposeToConvex   (const QPolygonF &polygon, QList<QPolygonF> &convexPolygons);
    bool             shortestPath        (QPolygonF polygon, const QPointF &startVertex, const QPointF &endVertex, QList<QPointF> &shortestPath);

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


