1 /*
2     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef KOSMINDOORMAP_SCENEGEOMETRY_P_H
8 #define KOSMINDOORMAP_SCENEGEOMETRY_P_H
9 
10 #include "kosmindoormap_export.h"
11 
12 class QLineF;
13 class QPainterPath;
14 class QPointF;
15 class QPolygonF;
16 
17 namespace KOSMIndoorMap {
18 
19 /** Geometry related functions.
20  *  @internal only exported for unit tests
21  */
22 namespace SceneGeometry
23 {
24     /** Centroid of a polygon.
25      *  @see https://en.wikipedia.org/wiki/Polygon#Centroid
26      */
27     KOSMINDOORMAP_EXPORT QPointF polygonCentroid(const QPolygonF &poly);
28 
29     /** Returns the lengths of the given polyline. */
30     double polylineLength(const QPolygonF &poly);
31 
32     /** Returns the point at equal distance between the ends on the given polygon. */
33     KOSMINDOORMAP_EXPORT QPointF polylineMidPoint(const QPolygonF &poly);
34 
35     /** Rotation angle for a label placed at the middle of @p path. */
36     KOSMINDOORMAP_EXPORT double polylineMidPointAngle(const QPolygonF &path);
37 
38     /** Returns the outer polygon of a painter path.
39      *  @note This is not generic, but makes assumptions about the painter path
40      *  structure that happen to hold of OSM input data.
41      */
42     void outerPolygonFromPath(const QPainterPath &path, QPolygonF &poly);
43 
44     /** Computes the distance of the given line to the given point. */
45     KOSMINDOORMAP_EXPORT double distanceToLine(const QLineF &line, QPointF p);
46 }
47 
48 }
49 
50 #endif // KOSMINDOORMAP_SCENEGEOMETRY_P_H
51