VPTissue Reference Manual
PolygonUtils.h
Go to the documentation of this file.
1 #ifndef SIMPT_EDITOR_POLYGON_UTILS_H_INCLUDED
2 #define SIMPT_EDITOR_POLYGON_UTILS_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include <QLineF>
23 #include <QPolygonF>
24 
25 namespace SimPT_Editor {
26 
31 {
32 public:
40  static bool IsClockwise(const QPolygonF& polygon);
41 
49  static bool IsSimplePolygon(const QPolygonF& polygon);
50 
58  static QPolygonF OpenPolygon(const QPolygonF &polygon);
59 
68  static QPolygonF Counterclockwise(const QPolygonF &polygon);
69 
77  static double CalculateArea(const QPolygonF& polygon);
78 
87  static std::list<QPolygonF> ClipPolygon(const QPolygonF& polygon1, const QPolygonF& polygon2);
88 
99  static std::list<QPolygonF> SlicePolygon(const QPolygonF& polygon, QLineF cut);
100 
101 private:
110  static int Turn(const QLineF &line1, const QLineF &line2);
111 
112  static constexpr double g_accuracy = 1.0e-12; //Needed for floating-point errors introduced by Qt intersections.
113 };
114 
115 } // namespace
116 
117 #endif // end_of_include_guard
static QPolygonF OpenPolygon(const QPolygonF &polygon)
Opens the polygon, ie.
Namespace for SimPT tissue editor package.
Definition: Cell.h:32
static std::list< QPolygonF > ClipPolygon(const QPolygonF &polygon1, const QPolygonF &polygon2)
Clip a polygon with another polygon and return the intersecting subpolygons.
static QPolygonF Counterclockwise(const QPolygonF &polygon)
Checks if the order of the polygon's points is clockwise and if so, reverts it, else the original pol...
static bool IsClockwise(const QPolygonF &polygon)
Checks whether the vertices of a polygon are ordered clockwise or counterclockwise.
static std::list< QPolygonF > SlicePolygon(const QPolygonF &polygon, QLineF cut)
Slice an open, simple and valid polygon in multiple polygons with a given line.
static double CalculateArea(const QPolygonF &polygon)
Calculate the area of a polygon.
Functions to manipulate polygons.
Definition: PolygonUtils.h:30
static bool IsSimplePolygon(const QPolygonF &polygon)
Checks whether a polygon is simple.