#pragma once #include #include #include namespace PolygonCalculus { enum JoinPolygonError { NotSimplePolygon, PolygonJoined, Disjoint, PathSizeLow, Error}; typedef QList QVector3DList; typedef QList QPointFList; typedef QVector 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); // returns true if the line c1-c2 is fully inside the polygon bool containsPath (QPolygonF polygon, const QPointF &c1, const QPointF &c2); // same as containsPath(), but works only if c1 and c2 are inside the polygon! bool containsPathFast (QPolygonF polygon, const QPointF &c1, const QPointF &c2); void decomposeToConvex (const QPolygonF &polygon, QList &convexPolygons); bool shortestPath (const QPolygonF &polygon, const QPointF &startVertex, const QPointF &endVertex, QVector &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); }