Walls And Holes  1
polygon.h
Go to the documentation of this file.
1 #ifndef POLYGON_H
2 #define POLYGON_H
3 
4 #include <QVector2D>
5 #include <QVector>
6 #include <QLineF>
7 #include <QRectF>
8 #include <QPolygonF>
9 
10 #include "triplet.h"
11 
23 {
24 public:
26  BetterPolygon(const QVector<QPointF> &points);
27  BetterPolygon(const QPolygonF &polygon);
28 
29  bool isValid() const;
30 
40  bool chordIsClear(int ind1, int ind2) const;
41 
42  bool connectionIsClear(const BetterPolygon &other, int pointOnThis, int pointOnOther) const;
43 
44  bool overlaps(const BetterPolygon &other) const;
45 
54  QPair<BetterPolygon, BetterPolygon> splitPolygon() const;
55 
66  QPair<BetterPolygon, BetterPolygon> splitPolygon(QPair<int, int> chord) const;
67 
75  QList<Triplet<QPointF, QPointF, QPointF>> triangulate() const;
76 
77  QVector<BetterPolygon> subtract(const BetterPolygon &other) const;
78  QVector<BetterPolygon> intersect(const BetterPolygon &other) const;
79  QVector<BetterPolygon> united(const BetterPolygon &other) const;
80 
81  const QVector<QPointF> &points() const { return mPolygon; }
82  QVector<QPointF> &points() { return mPolygon; }
83 
84  void translate(const QPointF &p) { mPolygon.translate(p); }
85  void translate(float x, float y) { mPolygon.translate(x, y); }
86 
87 private:
88  QPolygonF mPolygon;
89 };
90 
91 #endif // POLYGON_H
QVector< BetterPolygon > united(const BetterPolygon &other) const
Definition: polygon.cpp:360
bool isValid() const
Definition: polygon.cpp:27
QVector< BetterPolygon > intersect(const BetterPolygon &other) const
Definition: polygon.cpp:339
void translate(const QPointF &p)
Definition: polygon.h:84
QVector< QPointF > & points()
Definition: polygon.h:82
BetterPolygon()
Definition: polygon.h:25
bool connectionIsClear(const BetterPolygon &other, int pointOnThis, int pointOnOther) const
Definition: polygon.cpp:83
const QVector< QPointF > & points() const
Definition: polygon.h:81
QPair< BetterPolygon, BetterPolygon > splitPolygon() const
splitPolygon
Definition: polygon.cpp:125
bool chordIsClear(int ind1, int ind2) const
chordIsClear
Definition: polygon.cpp:61
The Polygon class.
Definition: polygon.h:22
QVector< BetterPolygon > subtract(const BetterPolygon &other) const
Definition: polygon.cpp:253
bool overlaps(const BetterPolygon &other) const
Definition: polygon.cpp:108
void translate(float x, float y)
Definition: polygon.h:85
QList< Triplet< QPointF, QPointF, QPointF > > triangulate() const
triangulate
Definition: polygon.cpp:194